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