periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2017 OTA keys S.A.
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
21 #ifndef PERIPH_CONF_H
22 #define PERIPH_CONF_H
23 
24 /* This board provides an LSE */
25 #ifndef CONFIG_BOARD_HAS_LSE
26 #define CONFIG_BOARD_HAS_LSE 1
27 #endif
28 
29 /* This board provides an HSE */
30 #ifndef CONFIG_BOARD_HAS_HSE
31 #define CONFIG_BOARD_HAS_HSE 1
32 #endif
33 
34 #include "periph_cpu.h"
35 #include "clk_conf.h"
36 #include "cfg_i2c1_pb8_pb9.h"
37 #include "cfg_usb_otg_fs.h"
38 #include "mii.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
48 static const dma_conf_t dma_config[] = {
49  { .stream = 10 }, /* DMA2 Stream 2 - SPI1_RX */
50  { .stream = 11 }, /* DMA2 Stream 3 - SPI1_TX */
51  { .stream = 3 }, /* DMA1 Stream 3 - SPI2_RX/USART3_TX */
52  { .stream = 4 }, /* DMA1 Stream 4 - SPI2_TX */
53  { .stream = 14 }, /* DMA2 Stream 6 - USART6_TX */
54  { .stream = 6 }, /* DMA1 Stream 6 - USART2_TX */
55  { .stream = 8 }, /* DMA2 Stream 0 - ETH_TX */
56 };
57 
58 #define DMA_0_ISR isr_dma2_stream2
59 #define DMA_1_ISR isr_dma2_stream3
60 #define DMA_2_ISR isr_dma1_stream3
61 #define DMA_3_ISR isr_dma1_stream4
62 #define DMA_4_ISR isr_dma2_stream6
63 #define DMA_5_ISR isr_dma1_stream6
64 #define DMA_6_ISR isr_dma2_stream0
65 
66 #define DMA_NUMOF ARRAY_SIZE(dma_config)
73 static const pwm_conf_t pwm_config[] = {
74  {
75  .dev = TIM1,
76  .rcc_mask = RCC_APB2ENR_TIM1EN,
77  .chan = { { .pin = GPIO_PIN(PORT_E, 9) /* D6 */, .cc_chan = 0},
78  { .pin = GPIO_PIN(PORT_E, 11) /* D5 */, .cc_chan = 1},
79  { .pin = GPIO_PIN(PORT_E, 13) /* D3 */, .cc_chan = 2},
80  { .pin = GPIO_UNDEF, .cc_chan = 0} },
81  .af = GPIO_AF1,
82  .bus = APB2
83  },
84  {
85  .dev = TIM4,
86  .rcc_mask = RCC_APB1ENR_TIM4EN,
87  .chan = { { .pin = GPIO_PIN(PORT_D, 15) /* D9 */, .cc_chan = 3},
88  { .pin = GPIO_UNDEF, .cc_chan = 0},
89  { .pin = GPIO_UNDEF, .cc_chan = 0},
90  { .pin = GPIO_UNDEF, .cc_chan = 0} },
91  .af = GPIO_AF2,
92  .bus = APB1
93  },
94 };
95 
96 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
103 static const timer_conf_t timer_config[] = {
104  {
105  .dev = TIM2,
106  .max = 0xffffffff,
107  .rcc_mask = RCC_APB1ENR_TIM2EN,
108  .bus = APB1,
109  .irqn = TIM2_IRQn
110  },
111  {
112  .dev = TIM5,
113  .max = 0xffffffff,
114  .rcc_mask = RCC_APB1ENR_TIM5EN,
115  .bus = APB1,
116  .irqn = TIM5_IRQn
117  }
118 };
119 
120 #define TIMER_0_ISR isr_tim2
121 #define TIMER_1_ISR isr_tim5
122 
123 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
130 static const uart_conf_t uart_config[] = {
131  {
132  .dev = USART3,
133  .rcc_mask = RCC_APB1ENR_USART3EN,
134  .rx_pin = GPIO_PIN(PORT_D, 9),
135  .tx_pin = GPIO_PIN(PORT_D, 8),
136  .rx_af = GPIO_AF7,
137  .tx_af = GPIO_AF7,
138  .bus = APB1,
139  .irqn = USART3_IRQn,
140 #ifdef MODULE_PERIPH_DMA
141  .dma = 2,
142  .dma_chan = 4
143 #endif
144  },
145  {
146  .dev = USART6,
147  .rcc_mask = RCC_APB2ENR_USART6EN,
148  .rx_pin = GPIO_PIN(PORT_G, 9),
149  .tx_pin = GPIO_PIN(PORT_G, 14),
150  .rx_af = GPIO_AF8,
151  .tx_af = GPIO_AF8,
152  .bus = APB2,
153  .irqn = USART6_IRQn,
154 #ifdef MODULE_PERIPH_DMA
155  .dma = 4,
156  .dma_chan = 5
157 #endif
158  },
159  {
160  .dev = USART2,
161  .rcc_mask = RCC_APB1ENR_USART2EN,
162  .rx_pin = GPIO_PIN(PORT_D, 6),
163  .tx_pin = GPIO_PIN(PORT_D, 5),
164  .rx_af = GPIO_AF7,
165  .tx_af = GPIO_AF7,
166  .bus = APB1,
167  .irqn = USART2_IRQn,
168 #ifdef MODULE_PERIPH_DMA
169  .dma = 5,
170  .dma_chan = 4
171 #endif
172  },
173 };
174 
175 #define UART_0_ISR (isr_usart3)
176 #define UART_1_ISR (isr_usart6)
177 #define UART_2_ISR (isr_usart2)
178 
179 #define UART_NUMOF ARRAY_SIZE(uart_config)
186 static const spi_conf_t spi_config[] = {
187  {
188  .dev = SPI1,
189  .mosi_pin = GPIO_PIN(PORT_A, 7),
190  .miso_pin = GPIO_PIN(PORT_A, 6),
191  .sclk_pin = GPIO_PIN(PORT_A, 5),
192  .cs_pin = GPIO_PIN(PORT_A, 4),
193  .mosi_af = GPIO_AF5,
194  .miso_af = GPIO_AF5,
195  .sclk_af = GPIO_AF5,
196  .cs_af = GPIO_AF5,
197  .rccmask = RCC_APB2ENR_SPI1EN,
198  .apbbus = APB2,
199 #ifdef MODULE_PERIPH_DMA
200  .tx_dma = 1,
201  .tx_dma_chan = 3,
202  .rx_dma = 0,
203  .rx_dma_chan = 3,
204 #endif
205  },
206  {
207  .dev = SPI2,
208  .mosi_pin = GPIO_PIN(PORT_B, 15),
209  .miso_pin = GPIO_PIN(PORT_C, 2),
210  .sclk_pin = GPIO_PIN(PORT_B, 13),
211  .cs_pin = GPIO_PIN(PORT_B, 12),
212  .mosi_af = GPIO_AF5,
213  .miso_af = GPIO_AF5,
214  .sclk_af = GPIO_AF5,
215  .cs_af = GPIO_AF5,
216  .rccmask = RCC_APB1ENR_SPI2EN,
217  .apbbus = APB1,
218 #ifdef MODULE_PERIPH_DMA
219  .tx_dma = 3,
220  .tx_dma_chan = 0,
221  .rx_dma = 2,
222  .rx_dma_chan = 0,
223 #endif
224  }
225 };
226 
227 #define SPI_NUMOF ARRAY_SIZE(spi_config)
251 static const adc_conf_t adc_config[] = {
252  { .pin = GPIO_PIN(PORT_A, 3), .dev = 0, .chan = 3 }, /* ADC123_IN3 */
253  { .pin = GPIO_PIN(PORT_C, 0), .dev = 0, .chan = 10 }, /* ADC123_IN10 */
254  { .pin = GPIO_PIN(PORT_C, 3), .dev = 0, .chan = 13 }, /* ADC123_IN13 */
255  { .pin = GPIO_PIN(PORT_F, 3), .dev = 2, .chan = 9 }, /* ADC3_IN9 */
256  { .pin = GPIO_PIN(PORT_F, 5), .dev = 2, .chan = 15 }, /* ADC3_IN15 */
257  { .pin = GPIO_PIN(PORT_F, 10), .dev = 2, .chan = 8 }, /* ADC3_IN8 */
258  { .pin = GPIO_UNDEF, .dev = 0, .chan = 18 }, /* VBAT */
259 };
260 
264 #define VBAT_ADC ADC_LINE(6)
265 
269 #define ADC_NUMOF ARRAY_SIZE(adc_config)
270 
277 static const eth_conf_t eth_config = {
278  .mode = RMII,
280  .dma = 6,
281  .dma_chan = 8,
282  .phy_addr = 0x00,
283  .pins = {
284  GPIO_PIN(PORT_G, 13),
285  GPIO_PIN(PORT_B, 13),
286  GPIO_PIN(PORT_G, 11),
287  GPIO_PIN(PORT_C, 4),
288  GPIO_PIN(PORT_C, 5),
289  GPIO_PIN(PORT_A, 7),
290  GPIO_PIN(PORT_C, 1),
291  GPIO_PIN(PORT_A, 2),
292  GPIO_PIN(PORT_A, 1),
293  }
294 };
295 
296 #define ETH_DMA_ISR isr_dma2_stream0
297 
300 #ifdef __cplusplus
301 }
302 #endif
303 
304 #endif /* PERIPH_CONF_H */
@ PORT_B
port B
Definition: periph_cpu.h:48
@ PORT_G
port G
Definition: periph_cpu.h:53
@ PORT_C
port C
Definition: periph_cpu.h:49
@ PORT_F
port F
Definition: periph_cpu.h:52
@ PORT_E
port E
Definition: periph_cpu.h:51
@ PORT_A
port A
Definition: periph_cpu.h:47
@ PORT_D
port D
Definition: periph_cpu.h:50
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:46
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
static const uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:39
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:97
static const timer_conf_t timer_config[]
All timers on board.
Definition: periph_conf.h:40
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:251
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:222
Common configuration for STM32 I2C.
Common configuration for STM32 OTG FS peripheral.
@ RMII
Configuration for RMII.
Definition: cpu_eth.h:37
@ GPIO_AF1
use alternate function 1
Definition: cpu_gpio.h:103
@ GPIO_AF2
use alternate function 2
Definition: cpu_gpio.h:104
@ GPIO_AF5
use alternate function 5
Definition: cpu_gpio.h:107
@ GPIO_AF8
use alternate function 8
Definition: cpu_gpio.h:111
@ GPIO_AF7
use alternate function 7
Definition: cpu_gpio.h:109
@ APB1
Advanced Peripheral Bus 1
Definition: periph_cpu.h:79
@ APB2
Advanced Peripheral Bus 2
Definition: periph_cpu.h:80
#define MII_BMCR_FULL_DPLX
Set for full duplex.
Definition: mii.h:69
#define MII_BMCR_SPEED_100
Set speed to 100 Mbps.
Definition: mii.h:73
Interface definition for MII/RMII h.
ADC device configuration.
Definition: periph_cpu.h:379
gpio_t pin
pin connected to the channel
Definition: periph_cpu.h:288
DMA configuration.
Definition: cpu_dma.h:32
int stream
DMA stream on stm32f2/4/7, channel on others STM32F2/4/7:
Definition: cpu_dma.h:55
Ethernet Peripheral configuration.
Definition: cpu_eth.h:44
eth_mode_t mode
Select configuration mode.
Definition: cpu_eth.h:45
PWM device configuration.
mini_timer_t * dev
Timer used.
SPI device configuration.
Definition: periph_cpu.h:337
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:338
Timer device configuration.
Definition: periph_cpu.h:264
TC0_t * dev
Pointer to the used as Timer device.
Definition: periph_cpu.h:265
UART device configuration.
Definition: periph_cpu.h:218
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:219