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