periph_conf.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2017 Inria
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
18 /* Add specific clock configuration (HSE, LSE) for this board here */
19 #ifndef CONFIG_BOARD_HAS_LSE
20 #define CONFIG_BOARD_HAS_LSE 1
21 #endif
22 
23 #include "periph_cpu.h"
24 #include "clk_conf.h"
25 #include "cfg_rtt_default.h"
26 #include "cfg_usb_otg_fs.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
36 static const dma_conf_t dma_config[] = {
37  { .stream = 1 }, /* DMA1 Channel 2 - SPI1_RX */
38  { .stream = 2 }, /* DMA1 Channel 3 - SPI1_TX */
39  { .stream = 3 }, /* DMA1 Channel 4 - USART1_TX / SPI2_RX */
40  { .stream = 4 }, /* DMA1 Channel 5 - SPI2_TX */
41  { .stream = 8 }, /* DMA2 Channel 1 - SPI3_RX */
42  { .stream = 9 }, /* DMA2 Channel 2 - SPI3_TX */
43  { .stream = 10 }, /* DMA2 Channel 3 - UART4_TX */
44 };
45 
46 #define DMA_0_ISR isr_dma1_channel2
47 #define DMA_1_ISR isr_dma1_channel3
48 #define DMA_2_ISR isr_dma1_channel4
49 #define DMA_3_ISR isr_dma1_channel5
50 #define DMA_4_ISR isr_dma2_channel1
51 #define DMA_5_ISR isr_dma2_channel2
52 #define DMA_6_ISR isr_dma2_channel3
53 
54 #define DMA_NUMOF ARRAY_SIZE(dma_config)
61 static const timer_conf_t timer_config[] = {
62  {
63  .dev = TIM5,
64  .max = 0xffffffff,
65  .rcc_mask = RCC_APB1ENR1_TIM5EN,
66  .bus = APB1,
67  .irqn = TIM5_IRQn
68  }
69 };
70 
71 #define TIMER_0_ISR isr_tim5
72 
73 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
80 static const uart_conf_t uart_config[] = {
81  {
82  .dev = USART1,
83  .rcc_mask = RCC_APB2ENR_USART1EN,
84  .rx_pin = GPIO_PIN(PORT_B, 7),
85  .tx_pin = GPIO_PIN(PORT_B, 6),
86  .rx_af = GPIO_AF7,
87  .tx_af = GPIO_AF7,
88  .bus = APB2,
89  .irqn = USART1_IRQn,
90  .type = STM32_USART,
91  .clk_src = 0, /* Use APB clock */
92 #ifdef MODULE_PERIPH_DMA
93  .dma = 2,
94  .dma_chan = 2
95 #endif
96  },
97  {
98  .dev = UART4,
99  .rcc_mask = RCC_APB1ENR1_UART4EN,
100  .rx_pin = GPIO_PIN(PORT_A, 1),
101  .tx_pin = GPIO_PIN(PORT_A, 0),
102  .rx_af = GPIO_AF8,
103  .tx_af = GPIO_AF8,
104  .bus = APB1,
105  .irqn = UART4_IRQn,
106  .type = STM32_USART,
107  .clk_src = 0, /* Use APB clock */
108 #ifdef MODULE_PERIPH_DMA
109  .dma = 6,
110  .dma_chan = 2
111 #endif
112  }
113 };
114 
115 #define UART_0_ISR (isr_usart1)
116 #define UART_1_ISR (isr_uart4)
117 
118 #define UART_NUMOF ARRAY_SIZE(uart_config)
125 static const pwm_conf_t pwm_config[] = {
126  {
127  .dev = TIM2,
128  .rcc_mask = RCC_APB1ENR1_TIM2EN,
129  .chan = { { .pin = GPIO_PIN(PORT_A, 15), .cc_chan = 0}, /* D9 */
130  { .pin = GPIO_UNDEF, .cc_chan = 0},
131  { .pin = GPIO_UNDEF, .cc_chan = 0},
132  { .pin = GPIO_UNDEF, .cc_chan = 0} },
133  .af = GPIO_AF1,
134  .bus = APB1
135  }
136 };
137 
138 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
145 static const spi_conf_t spi_config[] = {
146  {
147  .dev = SPI1,
148  .mosi_pin = GPIO_PIN(PORT_A, 7),
149  .miso_pin = GPIO_PIN(PORT_A, 6),
150  .sclk_pin = GPIO_PIN(PORT_A, 5),
151  .cs_pin = SPI_CS_UNDEF,
152  .mosi_af = GPIO_AF5,
153  .miso_af = GPIO_AF5,
154  .sclk_af = GPIO_AF5,
155  .cs_af = GPIO_AF5,
156  .rccmask = RCC_APB2ENR_SPI1EN,
157  .apbbus = APB2,
158 #ifdef MODULE_PERIPH_DMA
159  .tx_dma = 1,
160  .tx_dma_chan = 1,
161  .rx_dma = 0,
162  .rx_dma_chan = 1,
163 #endif
164  },
165  {
166  .dev = SPI2,
167  .mosi_pin = GPIO_PIN(PORT_D, 4),
168  .miso_pin = GPIO_PIN(PORT_D, 3),
169  .sclk_pin = GPIO_PIN(PORT_D, 1),
170  .cs_pin = SPI_CS_UNDEF,
171  .mosi_af = GPIO_AF5,
172  .miso_af = GPIO_AF5,
173  .sclk_af = GPIO_AF5,
174  .cs_af = GPIO_AF5,
175  .rccmask = RCC_APB1ENR1_SPI2EN,
176  .apbbus = APB1,
177 #ifdef MODULE_PERIPH_DMA
178  .tx_dma = 3,
179  .tx_dma_chan = 1,
180  .rx_dma = 2,
181  .rx_dma_chan = 1,
182 #endif
183  },
184  {
185  .dev = SPI3,
186  .mosi_pin = GPIO_PIN(PORT_C, 12),
187  .miso_pin = GPIO_PIN(PORT_C, 11),
188  .sclk_pin = GPIO_PIN(PORT_C, 10),
189  .cs_pin = SPI_CS_UNDEF,
190  .mosi_af = GPIO_AF6,
191  .miso_af = GPIO_AF6,
192  .sclk_af = GPIO_AF6,
193  .cs_af = GPIO_AF6,
194  .rccmask = RCC_APB1ENR1_SPI3EN,
195  .apbbus = APB1,
196 #ifdef MODULE_PERIPH_DMA
197  .tx_dma = 5,
198  .tx_dma_chan = 3,
199  .rx_dma = 4,
200  .rx_dma_chan = 3,
201 #endif
202  }
203 };
204 
205 #define SPI_NUMOF ARRAY_SIZE(spi_config)
212 static const i2c_conf_t i2c_config[] = {
213  {
214  .dev = I2C1,
215  .speed = I2C_SPEED_NORMAL,
216  .scl_pin = GPIO_PIN(PORT_B, 8),
217  .sda_pin = GPIO_PIN(PORT_B, 9),
218  .scl_af = GPIO_AF4,
219  .sda_af = GPIO_AF4,
220  .bus = APB1,
221  .rcc_mask = RCC_APB1ENR1_I2C1EN,
222  .rcc_sw_mask = RCC_CCIPR_I2C1SEL_1, /* HSI (16 MHz) */
223  .irqn = I2C1_ER_IRQn,
224  },
225  {
226  .dev = I2C2,
227  .speed = I2C_SPEED_NORMAL,
228  .scl_pin = GPIO_PIN(PORT_B, 10),
229  .sda_pin = GPIO_PIN(PORT_B, 11),
230  .scl_af = GPIO_AF4,
231  .sda_af = GPIO_AF4,
232  .bus = APB1,
233  .rcc_mask = RCC_APB1ENR1_I2C2EN,
234  .rcc_sw_mask = RCC_CCIPR_I2C2SEL_1, /* HSI (16 MHz) */
235  .irqn = I2C2_ER_IRQn,
236  },
237 };
238 
239 #define I2C_0_ISR isr_i2c1_er
240 #define I2C_1_ISR isr_i2c2_er
241 
242 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
245 #ifdef __cplusplus
246 }
247 #endif
248 
@ PORT_B
port B
Definition: periph_cpu.h:47
@ PORT_C
port C
Definition: periph_cpu.h:48
@ 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
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
static const uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:35
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:93
static const i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:65
static const timer_conf_t timer_config[]
All timers on board.
Definition: periph_conf.h:36
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:218
Common configuration for STM32 OTG FS peripheral.
@ GPIO_AF1
use alternate function 1
Definition: cpu_gpio.h:102
@ GPIO_AF5
use alternate function 5
Definition: cpu_gpio.h:106
@ GPIO_AF4
use alternate function 4
Definition: cpu_gpio.h:105
@ GPIO_AF8
use alternate function 8
Definition: cpu_gpio.h:110
@ GPIO_AF6
use alternate function 6
Definition: cpu_gpio.h:107
@ GPIO_AF7
use alternate function 7
Definition: cpu_gpio.h:108
@ STM32_USART
STM32 USART module type.
Definition: cpu_uart.h:37
#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
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:277
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
I2C configuration structure.
Definition: periph_cpu.h:298
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:299
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
Timer device configuration.
Definition: periph_cpu.h:263
TC0_t * dev
Pointer to the used as Timer device.
Definition: periph_cpu.h:264
UART device configuration.
Definition: periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:218