periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Freie Universität Berlin
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 
19 #ifndef PERIPH_CONF_H
20 #define PERIPH_CONF_H
21 
22 /* This board provides an LSE */
23 #ifndef CONFIG_BOARD_HAS_LSE
24 #define CONFIG_BOARD_HAS_LSE 1
25 #endif
26 
27 /* This board provides an HSE */
28 #ifndef CONFIG_BOARD_HAS_HSE
29 #define CONFIG_BOARD_HAS_HSE 1
30 #endif
31 
32 #include "periph_cpu.h"
34 #include "cfg_i2c1_pb8_pb9.h"
35 #include "cfg_rtt_default.h"
36 #include "cfg_timer_tim2.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 = 4 }, /* DMA1 Stream 4 - USART3_TX */
50  { .stream = 14 }, /* DMA2 Stream 6 - USART6_TX */
51  { .stream = 6 }, /* DMA1 Stream 6 - USART2_TX */
52  { .stream = 10 }, /* DMA2 Stream 2 - SPI1_RX */
53  { .stream = 13 }, /* DMA2 Stream 5 - SPI1_TX */
54  { .stream = 11 }, /* DMA2 Stream 3 - SPI4_RX */
55  { .stream = 12 }, /* DMA2 Stream 4 - SPI4_TX */
56  { .stream = 8 }, /* DMA2 Stream 0 - ETH_TX */
57 };
58 
59 #define DMA_0_ISR isr_dma1_stream4
60 #define DMA_1_ISR isr_dma2_stream6
61 #define DMA_2_ISR isr_dma1_stream6
62 
63 #define DMA_3_ISR isr_dma2_stream2
64 #define DMA_4_ISR isr_dma2_stream5
65 #define DMA_5_ISR isr_dma2_stream3
66 #define DMA_6_ISR isr_dma2_stream4
67 
68 #define DMA_7_ISR isr_dma2_stream0
69 
70 #define DMA_NUMOF ARRAY_SIZE(dma_config)
71 
77 static const pwm_conf_t pwm_config[] = {
78  {
79  .dev = TIM1,
80  .rcc_mask = RCC_APB2ENR_TIM1EN,
81  .chan = { { .pin = GPIO_PIN(PORT_E, 9) /* D6 CN10-4 */, .cc_chan = 0},
82  { .pin = GPIO_PIN(PORT_E, 11) /* D5 CN10-6 */, .cc_chan = 1},
83  { .pin = GPIO_PIN(PORT_E, 13) /* D3 CN10-10 */, .cc_chan = 2},
84  { .pin = GPIO_PIN(PORT_E, 14) /* D38 CN10-28 */, .cc_chan = 3} },
85  .af = GPIO_AF1,
86  .bus = APB2
87  },
88  {
89  .dev = TIM4,
90  .rcc_mask = RCC_APB1ENR_TIM4EN,
91  .chan = { { .pin = GPIO_PIN(PORT_D, 12) /* D29 CN10-21 */, .cc_chan = 0},
92  { .pin = GPIO_PIN(PORT_D, 13) /* D28 CN10-19 */, .cc_chan = 1},
93  { .pin = GPIO_PIN(PORT_D, 14) /* D10 CN7-16 */, .cc_chan = 2},
94  { .pin = GPIO_PIN(PORT_D, 15) /* D9 CN7-18 */, .cc_chan = 3} },
95  .af = GPIO_AF2,
96  .bus = APB1
97  },
98 };
99 
100 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
101 
107 static const uart_conf_t uart_config[] = {
108  {
109  .dev = USART3,
110  .rcc_mask = RCC_APB1ENR_USART3EN,
111  .rx_pin = GPIO_PIN(PORT_D, 9),
112  .tx_pin = GPIO_PIN(PORT_D, 8),
113  .rx_af = GPIO_AF7,
114  .tx_af = GPIO_AF7,
115  .bus = APB1,
116  .irqn = USART3_IRQn,
117 #ifdef MODULE_PERIPH_DMA
118  .dma = 0,
119  .dma_chan = 7
120 #endif
121  },
122  {
123  .dev = USART6,
124  .rcc_mask = RCC_APB2ENR_USART6EN,
125  .rx_pin = GPIO_PIN(PORT_G, 9),
126  .tx_pin = GPIO_PIN(PORT_G, 14),
127  .rx_af = GPIO_AF8,
128  .tx_af = GPIO_AF8,
129  .bus = APB2,
130  .irqn = USART6_IRQn,
131 #ifdef MODULE_PERIPH_DMA
132  .dma = 1,
133  .dma_chan = 5
134 #endif
135  },
136  {
137  .dev = USART2,
138  .rcc_mask = RCC_APB1ENR_USART2EN,
139  .rx_pin = GPIO_PIN(PORT_D, 6),
140  .tx_pin = GPIO_PIN(PORT_D, 5),
141  .rx_af = GPIO_AF7,
142  .tx_af = GPIO_AF7,
143  .bus = APB1,
144  .irqn = USART2_IRQn,
145 #ifdef MODULE_PERIPH_DMA
146  .dma = 2,
147  .dma_chan = 4
148 #endif
149  }
150 };
151 
152 #define UART_0_ISR (isr_usart3)
153 #define UART_1_ISR (isr_usart6)
154 #define UART_2_ISR (isr_usart2)
155 
156 #define UART_NUMOF ARRAY_SIZE(uart_config)
157 
163 static const spi_conf_t spi_config[] = {
164  {
165  .dev = SPI1,
166  /* PA7 is the default MOSI pin, as it is required for compatibility with
167  * Arduino(ish) shields. Sadly, it is also connected to the RMII_DV of
168  * Ethernet PHY. We work around this by remapping the MOSI to PB5 when
169  * the on-board Ethernet PHY is used.
170  */
171 #ifdef MODULE_PERIPH_ETH
172  .mosi_pin = GPIO_PIN(PORT_B, 5),
173 #else
174  .mosi_pin = GPIO_PIN(PORT_A, 7),
175 #endif
176  .miso_pin = GPIO_PIN(PORT_A, 6),
177  .sclk_pin = GPIO_PIN(PORT_A, 5),
178  .cs_pin = GPIO_UNDEF,
179  .mosi_af = GPIO_AF5,
180  .miso_af = GPIO_AF5,
181  .sclk_af = GPIO_AF5,
182  .cs_af = GPIO_AF5,
183  .rccmask = RCC_APB2ENR_SPI1EN,
184  .apbbus = APB2,
185 #ifdef MODULE_PERIPH_DMA
186  .tx_dma = 4,
187  .tx_dma_chan = 3,
188  .rx_dma = 3,
189  .rx_dma_chan = 3,
190 #endif
191  },
192  {
193  .dev = SPI4,
194  .mosi_pin = GPIO_PIN(PORT_E, 6),
195  .miso_pin = GPIO_PIN(PORT_E, 5),
196  .sclk_pin = GPIO_PIN(PORT_E, 2),
197  .cs_pin = GPIO_UNDEF,
198  .mosi_af = GPIO_AF5,
199  .miso_af = GPIO_AF5,
200  .sclk_af = GPIO_AF5,
201  .cs_af = GPIO_AF5,
202  .rccmask = RCC_APB2ENR_SPI4EN,
203  .apbbus = APB2,
204 #ifdef MODULE_PERIPH_DMA
205  .tx_dma = 6,
206  .tx_dma_chan = 5,
207  .rx_dma = 5,
208  .rx_dma_chan = 5,
209 #endif
210  }
211 };
212 
213 #define SPI_NUMOF ARRAY_SIZE(spi_config)
214 
220 static const eth_conf_t eth_config = {
221  .mode = RMII,
222  .addr = { 0 },
224  .dma = 7,
225  .dma_chan = 8,
226  .phy_addr = 0x00,
227  .pins = {
228  GPIO_PIN(PORT_G, 13),
229  GPIO_PIN(PORT_B, 13),
230  GPIO_PIN(PORT_G, 11),
231  GPIO_PIN(PORT_C, 4),
232  GPIO_PIN(PORT_C, 5),
233  GPIO_PIN(PORT_A, 7),
234  GPIO_PIN(PORT_C, 1),
235  GPIO_PIN(PORT_A, 2),
236  GPIO_PIN(PORT_A, 1),
237  }
238 };
239 
240 #define ETH_DMA_ISR isr_dma2_stream0
241 
244 #ifdef __cplusplus
245 }
246 #endif
247 
248 #endif /* PERIPH_CONF_H */
249 
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
cfg_clock_default_216.h
Default STM32F7 clock configuration for 216MHz boards.
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
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
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
cfg_timer_tim2.h
Common configuration for STM32 Timer peripheral based on TIM2.
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