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 
9 #pragma once
10 
21 /* This board provides an LSE */
22 #ifndef CONFIG_BOARD_HAS_LSE
23 #define CONFIG_BOARD_HAS_LSE 1
24 #endif
25 
26 /* This board provides an HSE */
27 #ifndef CONFIG_BOARD_HAS_HSE
28 #define CONFIG_BOARD_HAS_HSE 1
29 #endif
30 
31 #include "periph_cpu.h"
32 #include "clk_conf.h"
33 #include "cfg_i2c1_pb8_pb9.h"
34 #include "cfg_rtt_default.h"
35 #include "cfg_timer_tim2.h"
36 #include "cfg_usb_otg_fs.h"
37 #include "mii.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
47 static const dma_conf_t dma_config[] = {
48  { .stream = 4 }, /* DMA1 Stream 4 - USART3_TX */
49  { .stream = 14 }, /* DMA2 Stream 6 - USART6_TX */
50  { .stream = 6 }, /* DMA1 Stream 6 - USART2_TX */
51  { .stream = 10 }, /* DMA2 Stream 2 - SPI1_RX */
52  { .stream = 13 }, /* DMA2 Stream 5 - SPI1_TX */
53  { .stream = 11 }, /* DMA2 Stream 3 - SPI4_RX */
54  { .stream = 12 }, /* DMA2 Stream 4 - SPI4_TX */
55  { .stream = 8 }, /* DMA2 Stream 0 - ETH_TX */
56 };
57 
58 #define DMA_0_ISR isr_dma1_stream4
59 #define DMA_1_ISR isr_dma2_stream6
60 #define DMA_2_ISR isr_dma1_stream6
61 
62 #define DMA_3_ISR isr_dma2_stream2
63 #define DMA_4_ISR isr_dma2_stream5
64 #define DMA_5_ISR isr_dma2_stream3
65 #define DMA_6_ISR isr_dma2_stream4
66 
67 #define DMA_7_ISR isr_dma2_stream0
68 
69 #define DMA_NUMOF ARRAY_SIZE(dma_config)
76 static const pwm_conf_t pwm_config[] = {
77  {
78  .dev = TIM1,
79  .rcc_mask = RCC_APB2ENR_TIM1EN,
80  .chan = { { .pin = GPIO_PIN(PORT_E, 9) /* D6 CN10-4 */, .cc_chan = 0},
81  { .pin = GPIO_PIN(PORT_E, 11) /* D5 CN10-6 */, .cc_chan = 1},
82  { .pin = GPIO_PIN(PORT_E, 13) /* D3 CN10-10 */, .cc_chan = 2},
83  { .pin = GPIO_PIN(PORT_E, 14) /* D38 CN10-28 */, .cc_chan = 3} },
84  .af = GPIO_AF1,
85  .bus = APB2
86  },
87  {
88  .dev = TIM4,
89  .rcc_mask = RCC_APB1ENR_TIM4EN,
90  .chan = { { .pin = GPIO_PIN(PORT_D, 12) /* D29 CN10-21 */, .cc_chan = 0},
91  { .pin = GPIO_PIN(PORT_D, 13) /* D28 CN10-19 */, .cc_chan = 1},
92  { .pin = GPIO_PIN(PORT_D, 14) /* D10 CN7-16 */, .cc_chan = 2},
93  { .pin = GPIO_PIN(PORT_D, 15) /* D9 CN7-18 */, .cc_chan = 3} },
94  .af = GPIO_AF2,
95  .bus = APB1
96  },
97 };
98 
99 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
106 static const uart_conf_t uart_config[] = {
107  {
108  .dev = USART3,
109  .rcc_mask = RCC_APB1ENR_USART3EN,
110  .rx_pin = GPIO_PIN(PORT_D, 9),
111  .tx_pin = GPIO_PIN(PORT_D, 8),
112  .rx_af = GPIO_AF7,
113  .tx_af = GPIO_AF7,
114  .bus = APB1,
115  .irqn = USART3_IRQn,
116 #ifdef MODULE_PERIPH_DMA
117  .dma = 0,
118  .dma_chan = 7
119 #endif
120  },
121  {
122  .dev = USART6,
123  .rcc_mask = RCC_APB2ENR_USART6EN,
124  .rx_pin = GPIO_PIN(PORT_G, 9),
125  .tx_pin = GPIO_PIN(PORT_G, 14),
126  .rx_af = GPIO_AF8,
127  .tx_af = GPIO_AF8,
128  .bus = APB2,
129  .irqn = USART6_IRQn,
130 #ifdef MODULE_PERIPH_DMA
131  .dma = 1,
132  .dma_chan = 5
133 #endif
134  },
135  {
136  .dev = USART2,
137  .rcc_mask = RCC_APB1ENR_USART2EN,
138  .rx_pin = GPIO_PIN(PORT_D, 6),
139  .tx_pin = GPIO_PIN(PORT_D, 5),
140  .rx_af = GPIO_AF7,
141  .tx_af = GPIO_AF7,
142  .bus = APB1,
143  .irqn = USART2_IRQn,
144 #ifdef MODULE_PERIPH_DMA
145  .dma = 2,
146  .dma_chan = 4
147 #endif
148  }
149 };
150 
151 #define UART_0_ISR (isr_usart3)
152 #define UART_1_ISR (isr_usart6)
153 #define UART_2_ISR (isr_usart2)
154 
155 #define UART_NUMOF ARRAY_SIZE(uart_config)
162 static const spi_conf_t spi_config[] = {
163  {
164  .dev = SPI1,
165  /* PA7 is the default MOSI pin, as it is required for compatibility with
166  * Arduino(ish) shields. Sadly, it is also connected to the RMII_DV of
167  * Ethernet PHY. We work around this by remapping the MOSI to PB5 when
168  * the on-board Ethernet PHY is used.
169  */
170 #ifdef MODULE_PERIPH_ETH
171  .mosi_pin = GPIO_PIN(PORT_B, 5),
172 #else
173  .mosi_pin = GPIO_PIN(PORT_A, 7),
174 #endif
175  .miso_pin = GPIO_PIN(PORT_A, 6),
176  .sclk_pin = GPIO_PIN(PORT_A, 5),
177  .cs_pin = SPI_CS_UNDEF,
178  .mosi_af = GPIO_AF5,
179  .miso_af = GPIO_AF5,
180  .sclk_af = GPIO_AF5,
181  .cs_af = GPIO_AF5,
182  .rccmask = RCC_APB2ENR_SPI1EN,
183  .apbbus = APB2,
184 #ifdef MODULE_PERIPH_DMA
185  .tx_dma = 4,
186  .tx_dma_chan = 3,
187  .rx_dma = 3,
188  .rx_dma_chan = 3,
189 #endif
190  },
191  {
192  .dev = SPI4,
193  .mosi_pin = GPIO_PIN(PORT_E, 6),
194  .miso_pin = GPIO_PIN(PORT_E, 5),
195  .sclk_pin = GPIO_PIN(PORT_E, 2),
196  .cs_pin = SPI_CS_UNDEF,
197  .mosi_af = GPIO_AF5,
198  .miso_af = GPIO_AF5,
199  .sclk_af = GPIO_AF5,
200  .cs_af = GPIO_AF5,
201  .rccmask = RCC_APB2ENR_SPI4EN,
202  .apbbus = APB2,
203 #ifdef MODULE_PERIPH_DMA
204  .tx_dma = 6,
205  .tx_dma_chan = 5,
206  .rx_dma = 5,
207  .rx_dma_chan = 5,
208 #endif
209  }
210 };
211 
212 #define SPI_NUMOF ARRAY_SIZE(spi_config)
219 static const eth_conf_t eth_config = {
220  .mode = RMII,
222  .dma = 7,
223  .dma_chan = 8,
224  .phy_addr = 0x00,
225  .pins = {
226  GPIO_PIN(PORT_G, 13),
227  GPIO_PIN(PORT_B, 13),
228  GPIO_PIN(PORT_G, 11),
229  GPIO_PIN(PORT_C, 4),
230  GPIO_PIN(PORT_C, 5),
231  GPIO_PIN(PORT_A, 7),
232  GPIO_PIN(PORT_C, 1),
233  GPIO_PIN(PORT_A, 2),
234  GPIO_PIN(PORT_A, 1),
235  }
236 };
237 
238 #define ETH_DMA_ISR isr_dma2_stream0
239 
242 #ifdef __cplusplus
243 }
244 #endif
245 
@ PORT_B
port B
Definition: periph_cpu.h:47
@ PORT_G
port G
Definition: periph_cpu.h:52
@ PORT_C
port C
Definition: periph_cpu.h:48
@ PORT_E
port E
Definition: periph_cpu.h:50
@ PORT_A
port A
Definition: periph_cpu.h:46
@ PORT_D
port D
Definition: periph_cpu.h:49
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:45
static const uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:38
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:96
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:221
Common configuration for STM32 I2C.
Common configuration for STM32 Timer peripheral based on TIM2.
Common configuration for STM32 OTG FS peripheral.
@ RMII
Configuration for RMII.
Definition: cpu_eth.h:36
@ GPIO_AF1
use alternate function 1
Definition: cpu_gpio.h:102
@ GPIO_AF2
use alternate function 2
Definition: cpu_gpio.h:103
@ GPIO_AF5
use alternate function 5
Definition: cpu_gpio.h:106
@ GPIO_AF8
use alternate function 8
Definition: cpu_gpio.h:110
@ GPIO_AF7
use alternate function 7
Definition: cpu_gpio.h:108
#define SPI_CS_UNDEF
Define value for unused CS line.
Definition: periph_cpu.h:362
@ APB1
Advanced Peripheral Bus 1
Definition: periph_cpu.h:78
@ APB2
Advanced Peripheral Bus 2
Definition: periph_cpu.h:79
#define MII_BMCR_FULL_DPLX
Set for full duplex.
Definition: mii.h:68
#define MII_BMCR_SPEED_100
Set speed to 100 Mbps.
Definition: mii.h:72
Interface definition for MII/RMII h.
DMA configuration.
Definition: cpu_dma.h:31
int stream
DMA stream on stm32f2/4/7, channel on others STM32F2/4/7:
Definition: cpu_dma.h:54
Ethernet Peripheral configuration.
Definition: cpu_eth.h:43
eth_mode_t mode
Select configuration mode.
Definition: cpu_eth.h:44
PWM device configuration.
mini_timer_t * dev
Timer used.
SPI device configuration.
Definition: periph_cpu.h:336
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:337
UART device configuration.
Definition: periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:218