periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 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 /* 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_timer_tim5.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
44 static const dma_conf_t dma_config[] = {
45  { .stream = 11 }, /* DMA2 Stream 3 - SPI1_TX */
46  { .stream = 10 }, /* DMA2 Stream 2 - SPI1_RX */
47  { .stream = 4 }, /* DMA1 Stream 4 - SPI2_TX */
48  { .stream = 3 }, /* DMA1 Stream 3 - SPI2_RX */
49  { .stream = 5 }, /* DMA1 Stream 5 - SPI3_TX */
50  { .stream = 0 }, /* DMA1 Stream 0 - SPI3_RX */
51 };
52 
53 #define DMA_0_ISR isr_dma2_stream3
54 #define DMA_1_ISR isr_dma2_stream2
55 #define DMA_2_ISR isr_dma1_stream4
56 #define DMA_3_ISR isr_dma1_stream3
57 #define DMA_4_ISR isr_dma1_stream5
58 #define DMA_5_ISR isr_dma1_stream0
59 
60 #define DMA_NUMOF ARRAY_SIZE(dma_config)
67 static const uart_conf_t uart_config[] = {
68  {
69  .dev = USART2,
70  .rcc_mask = RCC_APB1ENR_USART2EN,
71  .rx_pin = GPIO_PIN(PORT_A, 3),
72  .tx_pin = GPIO_PIN(PORT_A, 2),
73  .rx_af = GPIO_AF7,
74  .tx_af = GPIO_AF7,
75  .bus = APB1,
76  .irqn = USART2_IRQn,
77 #ifdef MODULE_PERIPH_DMA
78  .dma = DMA_STREAM_UNDEF,
79  .dma_chan = UINT8_MAX,
80 #endif
81  },
82  {
83  .dev = USART1,
84  .rcc_mask = RCC_APB2ENR_USART1EN,
85  .rx_pin = GPIO_PIN(PORT_A, 10),
86  .tx_pin = GPIO_PIN(PORT_A, 9),
87  .rx_af = GPIO_AF7,
88  .tx_af = GPIO_AF7,
89  .bus = APB2,
90  .irqn = USART1_IRQn,
91 #ifdef MODULE_PERIPH_DMA
92  .dma = DMA_STREAM_UNDEF,
93  .dma_chan = UINT8_MAX,
94 #endif
95  },
96  {
97  .dev = USART3,
98  .rcc_mask = RCC_APB1ENR_USART3EN,
99  .rx_pin = GPIO_PIN(PORT_C, 11),
100  .tx_pin = GPIO_PIN(PORT_C, 10),
101  .rx_af = GPIO_AF7,
102  .tx_af = GPIO_AF7,
103  .bus = APB1,
104  .irqn = USART3_IRQn,
105 #ifdef MODULE_PERIPH_DMA
106  .dma = DMA_STREAM_UNDEF,
107  .dma_chan = UINT8_MAX,
108 #endif
109  },
110 };
111 
112 #define UART_0_ISR (isr_usart2)
113 #define UART_1_ISR (isr_usart1)
114 #define UART_2_ISR (isr_usart3)
115 
116 #define UART_NUMOF ARRAY_SIZE(uart_config)
123 static const pwm_conf_t pwm_config[] = {
124  {
125  .dev = TIM2,
126  .rcc_mask = RCC_APB1ENR_TIM2EN,
127  .chan = { { .pin = GPIO_PIN(PORT_A, 15), .cc_chan = 0},
128  { .pin = GPIO_PIN(PORT_B, 3), .cc_chan = 1},
129  { .pin = GPIO_PIN(PORT_B, 10), .cc_chan = 2},
130  { .pin = GPIO_PIN(PORT_B, 2), .cc_chan = 3} },
131  .af = GPIO_AF1,
132  .bus = APB1
133  },
134  {
135  .dev = TIM8,
136  .rcc_mask = RCC_APB2ENR_TIM8EN,
137  .chan = { { .pin = GPIO_PIN(PORT_C, 6), .cc_chan = 0},
138  { .pin = GPIO_PIN(PORT_C, 7), .cc_chan = 1},
139  { .pin = GPIO_PIN(PORT_C, 8), .cc_chan = 2},
140  { .pin = GPIO_PIN(PORT_C, 9), .cc_chan = 3} },
141  .af = GPIO_AF3,
142  .bus = APB2
143  },
144 };
145 
146 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
153 static const qdec_conf_t qdec_config[] = {
154  {
155  .dev = TIM3,
156  .max = 0xffffffff,
157  .rcc_mask = RCC_APB1ENR_TIM3EN,
158  .chan = { { .pin = GPIO_PIN(PORT_A, 6), .cc_chan = 0 },
159  { .pin = GPIO_PIN(PORT_A, 7), .cc_chan = 1 } },
160  .af = GPIO_AF2,
161  .bus = APB1,
162  .irqn = TIM3_IRQn
163  },
164  {
165  .dev = TIM4,
166  .max = 0xffffffff,
167  .rcc_mask = RCC_APB1ENR_TIM4EN,
168  .chan = { { .pin = GPIO_PIN(PORT_B, 6), .cc_chan = 0 },
169  { .pin = GPIO_PIN(PORT_B, 7), .cc_chan = 1 } },
170  .af = GPIO_AF2,
171  .bus = APB1,
172  .irqn = TIM4_IRQn
173  },
174 };
175 
176 #define QDEC_0_ISR isr_tim3
177 #define QDEC_1_ISR isr_tim4
178 
179 #define QDEC_NUMOF ARRAY_SIZE(qdec_config)
186 static const spi_conf_t spi_config[] = {
187  {
188  .dev = SPI1,
189  .mosi_pin = GPIO_PIN(PORT_A, 7),
190  .miso_pin = GPIO_PIN(PORT_A, 6),
191  .sclk_pin = GPIO_PIN(PORT_A, 5),
192  .cs_pin = GPIO_PIN(PORT_A, 4),
193  .mosi_af = GPIO_AF5,
194  .miso_af = GPIO_AF5,
195  .sclk_af = GPIO_AF5,
196  .cs_af = GPIO_AF5,
197  .rccmask = RCC_APB2ENR_SPI1EN,
198  .apbbus = APB2,
199 #ifdef MODULE_PERIPH_DMA
200  .tx_dma = 0,
201  .tx_dma_chan = 3,
202  .rx_dma = 1,
203  .rx_dma_chan = 3,
204 #endif
205  },
206  {
207  .dev = SPI2,
208  .mosi_pin = GPIO_PIN(PORT_B, 15),
209  .miso_pin = GPIO_PIN(PORT_B, 14),
210  .sclk_pin = GPIO_PIN(PORT_B, 13),
211  .cs_pin = GPIO_PIN(PORT_B, 12),
212  .mosi_af = GPIO_AF5,
213  .miso_af = GPIO_AF5,
214  .sclk_af = GPIO_AF5,
215  .cs_af = GPIO_AF5,
216  .rccmask = RCC_APB1ENR_SPI2EN,
217  .apbbus = APB1,
218 #ifdef MODULE_PERIPH_DMA
219  .tx_dma = 2,
220  .tx_dma_chan = 0,
221  .rx_dma = 3,
222  .rx_dma_chan = 0,
223 #endif
224  },
225  {
226  .dev = SPI3,
227  .mosi_pin = GPIO_PIN(PORT_C, 12),
228  .miso_pin = GPIO_PIN(PORT_C, 11),
229  .sclk_pin = GPIO_PIN(PORT_C, 10),
230  .cs_pin = GPIO_UNDEF,
231  .mosi_af = GPIO_AF6,
232  .miso_af = GPIO_AF6,
233  .sclk_af = GPIO_AF6,
234  .cs_af = GPIO_AF6,
235  .rccmask = RCC_APB1ENR_SPI3EN,
236  .apbbus = APB1,
237 #ifdef MODULE_PERIPH_DMA
238  .tx_dma = 4,
239  .tx_dma_chan = 0,
240  .rx_dma = 5,
241  .rx_dma_chan = 0,
242 #endif
243  }
244 };
245 
246 #define SPI_NUMOF ARRAY_SIZE(spi_config)
259 static const adc_conf_t adc_config[] = {
260  {GPIO_PIN(PORT_A, 0), 0, 0},
261  {GPIO_PIN(PORT_A, 1), 0, 1},
262  {GPIO_PIN(PORT_A, 4), 0, 4},
263  {GPIO_PIN(PORT_B, 0), 0, 8},
264  {GPIO_PIN(PORT_C, 1), 0, 11},
265  {GPIO_PIN(PORT_C, 0), 0, 10},
266  {GPIO_UNDEF, 0, 18}, /* VBAT */
267 };
268 
269 #define VBAT_ADC ADC_LINE(6)
270 #define ADC_NUMOF ARRAY_SIZE(adc_config)
273 #ifdef __cplusplus
274 }
275 #endif
276 
@ 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
#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 adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:250
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 TIM5.
@ 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_AF6
use alternate function 6
Definition: cpu_gpio.h:107
@ GPIO_AF3
use alternate function 3
Definition: cpu_gpio.h:104
@ GPIO_AF7
use alternate function 7
Definition: cpu_gpio.h:108
@ APB1
Advanced Peripheral Bus 1
Definition: periph_cpu.h:78
@ APB2
Advanced Peripheral Bus 2
Definition: periph_cpu.h:79
ADC device configuration.
Definition: periph_cpu.h:377
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
PWM device configuration.
mini_timer_t * dev
Timer used.
Quadrature decoder configuration struct.
TIM_TypeDef * dev
Timer used.
Definition: cpu_qdec.h:49
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