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)
67 
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)
97 
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)
124 
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)
180 
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)
228 
237 static const adc_conf_t adc_config[] = {
238  {GPIO_PIN(PORT_A, 3), 0, 3},
239  {GPIO_PIN(PORT_C, 0), 1, 0}
240 };
241 
242 #define ADC_NUMOF ARRAY_SIZE(adc_config)
243 
249 static const eth_conf_t eth_config = {
250  .mode = RMII,
251  .addr = { 0 },
253  .dma = 6,
254  .dma_chan = 8,
255  .phy_addr = 0x00,
256  .pins = {
257  GPIO_PIN(PORT_G, 13),
258  GPIO_PIN(PORT_B, 13),
259  GPIO_PIN(PORT_G, 11),
260  GPIO_PIN(PORT_C, 4),
261  GPIO_PIN(PORT_C, 5),
262  GPIO_PIN(PORT_A, 7),
263  GPIO_PIN(PORT_C, 1),
264  GPIO_PIN(PORT_A, 2),
265  GPIO_PIN(PORT_A, 1),
266  }
267 };
268 
269 #define ETH_DMA_ISR isr_dma2_stream0
270 
273 #ifdef __cplusplus
274 }
275 #endif
276 
277 #endif /* PERIPH_CONF_H */
278 
GPIO_AF8
@ GPIO_AF8
use alternate function 8
Definition: periph_cpu_common.h:94
PORT_E
@ PORT_E
port E
Definition: periph_cpu.h:40
PORT_C
@ PORT_C
port C
Definition: periph_cpu.h:38
pwm_conf_t::dev
mini_timer_t * dev
Timer used.
Definition: periph_cpu_common.h:154
GPIO_AF5
@ GPIO_AF5
use alternate function 5
Definition: periph_cpu_common.h:91
PORT_A
@ PORT_A
port A
Definition: periph_cpu.h:36
PORT_D
@ PORT_D
port D
Definition: periph_cpu.h:39
dma_conf_t::stream
int stream
DMA stream on stm32f2/4/7, channel on others STM32F2/4/7:
Definition: periph_cpu.h:443
cfg_usb_otg_fs.h
Common configuration for STM32 OTG FS peripheral.
pwm_conf_t
PWM device configuration.
Definition: periph_cpu_common.h:153
eth_conf_t::mode
eth_mode_t mode
Select configuration mode.
Definition: periph_cpu.h:1051
GPIO_UNDEF
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
Definition: periph_cpu_common.h:52
uart_conf_t
UART device configuration.
Definition: periph_cpu.h:166
mii.h
Interface definition for MII/RMII h.
GPIO_AF1
@ GPIO_AF1
use alternate function 1
Definition: periph_cpu_common.h:87
MII_BMCR_FULL_DPLX
#define MII_BMCR_FULL_DPLX
Set for full duplex.
Definition: mii.h:68
uart_conf_t::dev
cc2538_uart_t * dev
pointer to the used UART device
Definition: periph_cpu.h:167
MII_BMCR_SPEED_100
#define MII_BMCR_SPEED_100
Set speed to 100 Mbps.
Definition: mii.h:72
timer_conf_t
Timer configuration.
Definition: periph_cpu.h:288
eth_conf_t
Ethernet Peripheral configuration.
Definition: periph_cpu.h:1050
GPIO_AF7
@ GPIO_AF7
use alternate function 7
Definition: periph_cpu_common.h:93
adc_conf_t
ADC device configuration.
Definition: periph_cpu.h:74
GPIO_PIN
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:35
RMII
@ RMII
Configuration for RMII.
Definition: periph_cpu.h:1043
APB2
@ APB2
APB2 bus.
Definition: periph_cpu.h:177
dma_conf_t
DMA configuration.
Definition: periph_cpu.h:420
GPIO_AF2
@ GPIO_AF2
use alternate function 2
Definition: periph_cpu_common.h:88
timer_conf_t::dev
uint32_t dev
Address of timer base.
Definition: periph_cpu.h:112
cfg_i2c1_pb8_pb9.h
Common configuration for STM32 I2C.
PORT_B
@ PORT_B
port B
Definition: periph_cpu.h:37
spi_conf_t::dev
SPI_Type * dev
SPI device to use.
Definition: periph_cpu.h:465
PORT_G
@ PORT_G
port G
Definition: periph_cpu.h:42
spi_conf_t
SPI configuration structure type.
Definition: periph_cpu.h:273
APB1
@ APB1
APB1 bus.
Definition: periph_cpu.h:176