periph_conf.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2019 Benjamin Valentin
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
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 /* The HSE provides a 25MHz clock */
32 #ifndef CONFIG_CLOCK_HSE
33 #define CONFIG_CLOCK_HSE MHZ(25)
34 #endif
35 
36 #include "clk_conf.h"
37 #include "cfg_i2c1_pb8_pb9.h"
38 #include "cfg_timer_tim5.h"
39 #include "cfg_usb_otg_fs.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
49 static const uart_conf_t uart_config[] = {
50  {
51  .dev = USART2,
52  .rcc_mask = RCC_APB1ENR_USART2EN,
53  .rx_pin = GPIO_PIN(PORT_A, 3),
54  .tx_pin = GPIO_PIN(PORT_A, 2),
55  .rx_af = GPIO_AF7,
56  .tx_af = GPIO_AF7,
57  .bus = APB1,
58  .irqn = USART2_IRQn,
59 #ifdef MODULE_PERIPH_DMA
60  .dma = DMA_STREAM_UNDEF,
61  .dma_chan = UINT8_MAX,
62 #endif
63  },
64  {
65  .dev = USART1,
66  .rcc_mask = RCC_APB2ENR_USART1EN,
67  .rx_pin = GPIO_PIN(PORT_A, 10),
68  .tx_pin = GPIO_PIN(PORT_A, 9),
69  .rx_af = GPIO_AF7,
70  .tx_af = GPIO_AF7,
71  .bus = APB2,
72  .irqn = USART1_IRQn,
73 #ifdef MODULE_PERIPH_DMA
74  .dma = DMA_STREAM_UNDEF,
75  .dma_chan = UINT8_MAX,
76 #endif
77  },
78 };
79 
80 /* assign ISR vector names */
81 #define UART_0_ISR isr_usart2
82 #define UART_1_ISR isr_usart1
83 
84 /* deduct number of defined UART interfaces */
85 #define UART_NUMOF ARRAY_SIZE(uart_config)
91 static const pwm_conf_t pwm_config[] = {
92  {
93  .dev = TIM2,
94  .rcc_mask = RCC_APB1ENR_TIM2EN,
95  .chan = { { .pin = GPIO_PIN(PORT_A, 15), .cc_chan = 0 },
96  { .pin = GPIO_PIN(PORT_B, 3), /* D3 */ .cc_chan = 1 },
97  { .pin = GPIO_PIN(PORT_B, 10), /* D6 */ .cc_chan = 2 },
98  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
99  .af = GPIO_AF1,
100  .bus = APB1
101  },
102  {
103  .dev = TIM3,
104  .rcc_mask = RCC_APB1ENR_TIM3EN,
105  .chan = { { .pin = GPIO_PIN(PORT_B, 4), /* D5 */ .cc_chan = 0 },
106  { .pin = GPIO_PIN(PORT_C, 7), /* D9 */ .cc_chan = 1 },
107  { .pin = GPIO_PIN(PORT_C, 8), .cc_chan = 2 },
108  { .pin = GPIO_PIN(PORT_C, 9), .cc_chan = 3 } },
109  .af = GPIO_AF2,
110  .bus = APB1
111  },
112 };
113 
114 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
121 static const spi_conf_t spi_config[] = {
122  { /* U3 - SPI flash */
123  .dev = SPI1,
124  .mosi_pin = GPIO_PIN(PORT_A, 7),
125  .miso_pin = GPIO_PIN(PORT_A, 6),
126  .sclk_pin = GPIO_PIN(PORT_A, 5),
127  .cs_pin = GPIO_PIN(PORT_A, 4),
128  .mosi_af = GPIO_AF5,
129  .miso_af = GPIO_AF5,
130  .sclk_af = GPIO_AF5,
131  .cs_af = GPIO_AF5,
132  .rccmask = RCC_APB2ENR_SPI1EN,
133  .apbbus = APB2
134  },
135  {
136  .dev = SPI2,
137  .mosi_pin = GPIO_PIN(PORT_B, 15),
138  .miso_pin = GPIO_PIN(PORT_B, 14),
139  .sclk_pin = GPIO_PIN(PORT_B, 13),
140  .cs_pin = GPIO_PIN(PORT_B, 12),
141  .mosi_af = GPIO_AF5,
142  .miso_af = GPIO_AF5,
143  .sclk_af = GPIO_AF5,
144  .cs_af = GPIO_AF5,
145  .rccmask = RCC_APB1ENR_SPI2EN,
146  .apbbus = APB1
147  },
148  {
149  .dev = SPI3,
150  .mosi_pin = GPIO_PIN(PORT_B, 5),
151  .miso_pin = GPIO_PIN(PORT_B, 4),
152  .sclk_pin = GPIO_PIN(PORT_B, 3),
153  .cs_pin = GPIO_PIN(PORT_A, 15),
154  .mosi_af = GPIO_AF6,
155  .miso_af = GPIO_AF6,
156  .sclk_af = GPIO_AF6,
157  .cs_af = GPIO_AF6,
158  .rccmask = RCC_APB1ENR_SPI3EN,
159  .apbbus = APB1
160  },
161 };
162 
163 #define SPI_NUMOF ARRAY_SIZE(spi_config)
175 static const adc_conf_t adc_config[] = {
176  {GPIO_PIN(PORT_A, 0), 0, 0},
177  {GPIO_PIN(PORT_A, 1), 0, 1},
178  {GPIO_PIN(PORT_A, 4), 0, 4},
179  {GPIO_PIN(PORT_B, 0), 0, 8},
180  {GPIO_UNDEF, 0, 18} /* VBAT */
181 };
182 
183 #define VBAT_ADC ADC_LINE(4)
184 #define ADC_NUMOF ARRAY_SIZE(adc_config)
187 #ifdef __cplusplus
188 }
189 #endif
190 
@ 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:35
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:93
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:247
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:218
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_AF6
use alternate function 6
Definition: cpu_gpio.h:107
@ 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
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