periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Inria
3  * Copyright (C) 2017 OTA keys S.A.
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
10 #pragma once
11 
23 /* This board provides an LSE */
24 #ifndef CONFIG_BOARD_HAS_LSE
25 #define CONFIG_BOARD_HAS_LSE 1
26 #endif
27 
28 /* This board provides an HSE */
29 #ifndef CONFIG_BOARD_HAS_HSE
30 #define CONFIG_BOARD_HAS_HSE 1
31 #endif
32 
33 #include "periph_cpu.h"
34 #include "clk_conf.h"
35 #include "cfg_i2c1_pb8_pb9.h"
36 #include "cfg_rtt_default.h"
37 #include "cfg_timer_tim5.h"
38 #include "cfg_usb_otg_fs.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
48 static const dma_conf_t dma_config[] = {
49  { .stream = 11 }, /* DMA2 Stream 3 - SPI1_TX */
50  { .stream = 10 }, /* DMA2 Stream 2 - SPI1_RX */
51  { .stream = 3 }, /* DMA1 Stream 3 - UART3_TX */
52  { .stream = 15 }, /* DMA2 Stream 7 - UART6_TX */
53  { .stream = 6 }, /* DMA1 Stream 6 - UART2_TX */
54 };
55 
56 #define DMA_0_ISR isr_dma2_stream3
57 #define DMA_1_ISR isr_dma2_stream2
58 #define DMA_2_ISR isr_dma1_stream3
59 #define DMA_3_ISR isr_dma2_stream7
60 #define DMA_4_ISR isr_dma1_stream6
61 
62 #define DMA_NUMOF ARRAY_SIZE(dma_config)
69 static const uart_conf_t uart_config[] = {
70  {
71  .dev = USART3,
72  .rcc_mask = RCC_APB1ENR_USART3EN,
73  .rx_pin = GPIO_PIN(PORT_D, 9),
74  .tx_pin = GPIO_PIN(PORT_D, 8),
75  .rx_af = GPIO_AF7,
76  .tx_af = GPIO_AF7,
77  .bus = APB1,
78  .irqn = USART3_IRQn,
79 #ifdef MODULE_PERIPH_DMA
80  .dma = 2,
81  .dma_chan = 4,
82 #endif
83  },
84  {
85  .dev = USART6,
86  .rcc_mask = RCC_APB2ENR_USART6EN,
87  .rx_pin = GPIO_PIN(PORT_G, 9),
88  .tx_pin = GPIO_PIN(PORT_G, 14),
89  .rx_af = GPIO_AF8,
90  .tx_af = GPIO_AF8,
91  .bus = APB2,
92  .irqn = USART6_IRQn,
93 #ifdef MODULE_PERIPH_DMA
94  .dma = 3,
95  .dma_chan = 5,
96 #endif
97  },
98  {
99  .dev = USART2,
100  .rcc_mask = RCC_APB1ENR_USART2EN,
101  .rx_pin = GPIO_PIN(PORT_D, 6),
102  .tx_pin = GPIO_PIN(PORT_D, 5),
103  .rx_af = GPIO_AF7,
104  .tx_af = GPIO_AF7,
105  .bus = APB1,
106  .irqn = USART2_IRQn,
107 #ifdef MODULE_PERIPH_DMA
108  .dma = 4,
109  .dma_chan = 4,
110 #endif
111  },
112 };
113 
114 #define UART_0_ISR (isr_usart3)
115 #define UART_1_ISR (isr_usart6)
116 #define UART_2_ISR (isr_usart2)
117 
118 #define UART_NUMOF ARRAY_SIZE(uart_config)
125 static const pwm_conf_t pwm_config[] = {
126  {
127  .dev = TIM1,
128  .rcc_mask = RCC_APB2ENR_TIM1EN,
129  .chan = { { .pin = GPIO_PIN(PORT_E, 9) /* D6 */, .cc_chan = 0},
130  { .pin = GPIO_PIN(PORT_E, 11) /* D5 */, .cc_chan = 1},
131  { .pin = GPIO_PIN(PORT_E, 13) /* D3 */, .cc_chan = 2},
132  { .pin = GPIO_UNDEF, .cc_chan = 0} },
133  .af = GPIO_AF1,
134  .bus = APB2
135  },
136  {
137  .dev = TIM4,
138  .rcc_mask = RCC_APB1ENR_TIM4EN,
139  .chan = { { .pin = GPIO_PIN(PORT_D, 15) /* D9 */, .cc_chan = 3},
140  { .pin = GPIO_UNDEF, .cc_chan = 0},
141  { .pin = GPIO_UNDEF, .cc_chan = 0},
142  { .pin = GPIO_UNDEF, .cc_chan = 0} },
143  .af = GPIO_AF2,
144  .bus = APB1
145  },
146 };
147 
148 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
155 static const spi_conf_t spi_config[] = {
156  {
157  .dev = SPI1,
158  .mosi_pin = GPIO_PIN(PORT_A, 7),
159  .miso_pin = GPIO_PIN(PORT_A, 6),
160  .sclk_pin = GPIO_PIN(PORT_A, 5),
161  .cs_pin = GPIO_PIN(PORT_A, 4),
162  .mosi_af = GPIO_AF5,
163  .miso_af = GPIO_AF5,
164  .sclk_af = GPIO_AF5,
165  .cs_af = GPIO_AF5,
166  .rccmask = RCC_APB2ENR_SPI1EN,
167  .apbbus = APB2,
168 #ifdef MODULE_PERIPH_DMA
169  .tx_dma = 0,
170  .tx_dma_chan = 3,
171  .rx_dma = 1,
172  .rx_dma_chan = 3,
173 #endif
174  }
175 };
176 
177 #define SPI_NUMOF ARRAY_SIZE(spi_config)
190 static const adc_conf_t adc_config[] = {
191  {GPIO_PIN(PORT_A, 3), 0, 3},
192  {GPIO_PIN(PORT_C, 0), 0, 10},
193  {GPIO_PIN(PORT_C, 3), 0, 13},
194  {GPIO_PIN(PORT_C, 1), 0, 11},
195  {GPIO_PIN(PORT_C, 4), 0, 14},
196  {GPIO_PIN(PORT_C, 5), 0, 15},
197  {GPIO_UNDEF, 0, 18}, /* VBAT */
198 };
199 
200 #define VBAT_ADC ADC_LINE(6)
201 #define ADC_NUMOF ARRAY_SIZE(adc_config)
208 #ifndef RTT_FREQUENCY
209 #define RTT_FREQUENCY (4096)
210 #endif
213 #ifdef __cplusplus
214 }
215 #endif
216 
@ 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
#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.
Common configuration for STM32 OTG FS peripheral.
@ 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
@ 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.
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