periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 TU Dresden
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 "cfg_timer_tim5.h"
27 #include "cfg_usb_otg_fs_u5.h"
28 #include "clk_conf.h"
29 #include "periph_cpu.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
39 static const uart_conf_t uart_config[] = {
40  {
41  .dev = USART1,
42  .rcc_mask = RCC_APB2ENR_USART1EN,
43  .rx_pin = GPIO_PIN(PORT_A, 10),
44  .tx_pin = GPIO_PIN(PORT_A, 9),
45  .rx_af = GPIO_AF7,
46  .tx_af = GPIO_AF7,
47  .bus = APB2,
48  .irqn = USART1_IRQn,
49  .type = STM32_USART,
50  .clk_src = 0, /* Use APB clock */
51  },
52  {
53  .dev = LPUART1,
54  .rcc_mask = RCC_APB3ENR_LPUART1EN,
55  .rx_pin = GPIO_PIN(PORT_G, 8),
56  .tx_pin = GPIO_PIN(PORT_G, 7),
57  .rx_af = GPIO_AF8,
58  .tx_af = GPIO_AF8,
59  .bus = APB3,
60  .irqn = LPUART1_IRQn,
61  .type = STM32_LPUART,
62  .clk_src = 0, /* Use APB clock */
63  },
64 };
65 
66 #define UART_0_ISR (isr_usart1)
67 #define UART_1_ISR (isr_lpuart1)
68 
69 #define UART_NUMOF ARRAY_SIZE(uart_config)
76 static const spi_conf_t spi_config[] = {
77  {
78  .dev = SPI1,
79  .mosi_pin = GPIO_PIN(PORT_A, 7), /* Arduino D11 */
80  .miso_pin = GPIO_PIN(PORT_A, 6), /* Arduino D12 */
81  .sclk_pin = GPIO_PIN(PORT_A, 5), /* Arduino D13 */
82  .cs_pin = GPIO_UNDEF,
83  .mosi_af = GPIO_AF5,
84  .miso_af = GPIO_AF5,
85  .sclk_af = GPIO_AF5,
86  .cs_af = GPIO_AF5,
87  .rccmask = RCC_APB2ENR_SPI1EN,
88  .apbbus = APB2,
89  },
90 };
91 
92 #define SPI_NUMOF ARRAY_SIZE(spi_config)
99 static const i2c_conf_t i2c_config[] = {
100  {
101  .dev = I2C1,
102  .speed = I2C_SPEED_NORMAL,
103  .scl_pin = GPIO_PIN(PORT_B, 8),
104  .sda_pin = GPIO_PIN(PORT_B, 9),
105  .scl_af = GPIO_AF4,
106  .sda_af = GPIO_AF4,
107  .bus = APB1,
108  .rcc_mask = RCC_APB1ENR1_I2C1EN,
109  .rcc_sw_mask = RCC_CCIPR1_I2C1SEL_1,
110  .irqn = I2C1_ER_IRQn,
111  },
112  {
113  .dev = I2C2,
114  .speed = I2C_SPEED_NORMAL,
115  .scl_pin = GPIO_PIN(PORT_F, 1),
116  .sda_pin = GPIO_PIN(PORT_F, 0),
117  .scl_af = GPIO_AF4,
118  .sda_af = GPIO_AF4,
119  .bus = APB1,
120  .rcc_mask = RCC_APB1ENR1_I2C2EN,
121  .rcc_sw_mask = RCC_CCIPR1_I2C2SEL_1,
122  .irqn = I2C2_ER_IRQn,
123  },
124 };
125 
126 #define I2C_0_ISR isr_i2c1_er
127 #define I2C_1_ISR isr_i2c2_er
128 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
146 static const pwm_conf_t pwm_config[] = {
147  { .dev = TIM2,
148  .rcc_mask = RCC_APB1ENR1_TIM2EN,
149  .chan = { { .pin = GPIO_PIN(PORT_A, 0) /* CN10 D32 */, .cc_chan = 0 },
150  { .pin = GPIO_PIN(PORT_A, 1) /* CN10 A8 */, .cc_chan = 1 },
151  { .pin = GPIO_PIN(PORT_A, 2) /* CN9 A1 */, .cc_chan = 2 },
152  { .pin = GPIO_PIN(PORT_A, 3) /* CN9 A0 */, .cc_chan = 3 } },
153  .af = GPIO_AF1,
154  .bus = APB1 },
155  { .dev = TIM3,
156  .rcc_mask = RCC_APB1ENR1_TIM3EN,
157  .chan = { { .pin = GPIO_PIN(PORT_B, 4) /* CN7 D25 */, .cc_chan = 0 },
158  { .pin = GPIO_PIN(PORT_B, 5) /* CN7 D22 */, .cc_chan = 1 },
159  { .pin = GPIO_PIN(PORT_B, 0) /* CN9 A3 */, .cc_chan = 2 },
160  { .pin = GPIO_PIN(PORT_B, 1) /* CN10 A6 */, .cc_chan = 3 } },
161  .af = GPIO_AF2,
162  .bus = APB1 },
163  { .dev = TIM4,
164  .rcc_mask = RCC_APB1ENR1_TIM4EN,
165  .chan = { { .pin = GPIO_PIN(PORT_D, 12) /* CN7 D19 */, .cc_chan = 0 },
166  { .pin = GPIO_PIN(PORT_B, 7) /* Blue LD2 */, .cc_chan = 1 },
167  { .pin = GPIO_PIN(PORT_D, 14) /* CN7 D10 */, .cc_chan = 2 },
168  { .pin = GPIO_PIN(PORT_D, 15) /* CN7 D9 */, .cc_chan = 3 } },
169  .af = GPIO_AF2,
170  .bus = APB1 },
171 };
172 
173 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
174 
177 #ifdef __cplusplus
178 }
179 #endif
180 
@ PORT_B
port B
Definition: periph_cpu.h:47
@ PORT_G
port G
Definition: periph_cpu.h:52
@ PORT_F
port F
Definition: periph_cpu.h:51
@ 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 pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:221
Common configuration for STM32 Timer peripheral based on TIM5.
Common configuration for STM32 OTG FS peripheral for U5 family.
@ 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_AF4
use alternate function 4
Definition: cpu_gpio.h:105
@ GPIO_AF8
use alternate function 8
Definition: cpu_gpio.h:110
@ GPIO_AF7
use alternate function 7
Definition: cpu_gpio.h:108
@ STM32_LPUART
STM32 Low-power UART (LPUART) module type.
Definition: cpu_uart.h:38
@ STM32_USART
STM32 USART module type.
Definition: cpu_uart.h:37
@ 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
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
UART device configuration.
Definition: periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:218