periph_conf.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2021 Inria
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
18 /* Add specific clock configuration (HSE, LSE) for this board here */
19 #ifndef CONFIG_BOARD_HAS_LSE
20 #define CONFIG_BOARD_HAS_LSE 1
21 #endif
22 
23 #include "periph_cpu.h"
24 #include "clk_conf.h"
25 #include "cfg_timer_tim5.h"
26 #include "cfg_usb_otg_fs_u5.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
36 static const uart_conf_t uart_config[] = {
37  {
38  .dev = USART1,
39  .rcc_mask = RCC_APB2ENR_USART1EN,
40  .rx_pin = GPIO_PIN(PORT_A, 10),
41  .tx_pin = GPIO_PIN(PORT_A, 9),
42  .rx_af = GPIO_AF7,
43  .tx_af = GPIO_AF7,
44  .bus = APB2,
45  .irqn = USART1_IRQn,
46  .type = STM32_USART,
47  .clk_src = 0, /* Use APB clock */
48  },
49  { /* Connected to Arduino D0/D1 and STMOD+2 */
50  .dev = USART3,
51  .rcc_mask = RCC_APB1ENR1_USART3EN,
52  .rx_pin = GPIO_PIN(PORT_D, 9),
53  .tx_pin = GPIO_PIN(PORT_D, 8),
54  .rx_af = GPIO_AF7,
55  .tx_af = GPIO_AF7,
56  .bus = APB1,
57  .irqn = USART3_IRQn,
58  .type = STM32_USART,
59  .clk_src = 0, /* Use APB clock */
60  },
61  { /* Connected to STMOD+1 */
62  .dev = USART2,
63  .rcc_mask = RCC_APB1ENR1_USART2EN,
64  .rx_pin = GPIO_PIN(PORT_A, 3),
65  .tx_pin = GPIO_PIN(PORT_A, 2),
66  .rx_af = GPIO_AF7,
67  .tx_af = GPIO_AF7,
68  .bus = APB1,
69  .irqn = USART2_IRQn,
70  .type = STM32_USART,
71  .clk_src = 0, /* Use APB clock */
72  },
73  { /* Connected to Wireless */
74  .dev = UART4,
75  .rcc_mask = RCC_APB1ENR1_UART4EN,
76  .rx_pin = GPIO_PIN(PORT_C, 11),
77  .tx_pin = GPIO_PIN(PORT_C, 10),
78  .rx_af = GPIO_AF7,
79  .tx_af = GPIO_AF7,
80  .bus = APB1,
81  .irqn = UART4_IRQn,
82  .type = STM32_USART,
83  .clk_src = 0, /* Use APB clock */
84  },
85 };
86 
87 #define UART_0_ISR (isr_usart1)
88 #define UART_1_ISR (isr_usart3)
89 #define UART_2_ISR (isr_usart2)
90 #define UART_3_ISR (isr_uart4)
91 
92 #define UART_NUMOF ARRAY_SIZE(uart_config)
99 static const spi_conf_t spi_config[] = {
100  {
101  .dev = SPI1,
102  .mosi_pin = GPIO_PIN(PORT_E, 15), /* Arduino D11 */
103  .miso_pin = GPIO_PIN(PORT_E, 14), /* Arduino D12 */
104  .sclk_pin = GPIO_PIN(PORT_E, 13), /* Arduino D13 */
105  .cs_pin = GPIO_UNDEF,
106  .mosi_af = GPIO_AF5,
107  .miso_af = GPIO_AF5,
108  .sclk_af = GPIO_AF5,
109  .cs_af = GPIO_AF5,
110  .rccmask = RCC_APB2ENR_SPI1EN,
111  .apbbus = APB2,
112  },
113  { /* Connected to wireless */
114  .dev = SPI2,
115  .mosi_pin = GPIO_PIN(PORT_D, 4),
116  .miso_pin = GPIO_PIN(PORT_D, 3),
117  .sclk_pin = GPIO_PIN(PORT_D, 1),
118  .cs_pin = GPIO_PIN(PORT_B, 12),
119  .mosi_af = GPIO_AF5,
120  .miso_af = GPIO_AF5,
121  .sclk_af = GPIO_AF5,
122  .cs_af = GPIO_AF5,
123  .rccmask = RCC_APB1ENR1_SPI2EN,
124  .apbbus = APB1,
125  },
126  { /* Connected to STMOD+ 2 */
127  .dev = SPI3,
128  .mosi_pin = GPIO_PIN(PORT_D, 6),
129  .miso_pin = GPIO_PIN(PORT_G, 10),
130  .sclk_pin = GPIO_PIN(PORT_G, 9),
131  .cs_pin = GPIO_PIN(PORT_G, 12),
132  .mosi_af = GPIO_AF5,
133  .miso_af = GPIO_AF5,
134  .sclk_af = GPIO_AF5,
135  .cs_af = GPIO_AF5,
136  .rccmask = RCC_APB3ENR_SPI3EN,
137  .apbbus = APB3,
138  },
139 };
140 
141 #define SPI_NUMOF ARRAY_SIZE(spi_config)
148 static const i2c_conf_t i2c_config[] = {
149  {
150  .dev = I2C1,
151  .speed = I2C_SPEED_NORMAL,
152  .scl_pin = GPIO_PIN(PORT_B, 8),
153  .sda_pin = GPIO_PIN(PORT_B, 9),
154  .scl_af = GPIO_AF4,
155  .sda_af = GPIO_AF4,
156  .bus = APB1,
157  .rcc_mask = RCC_APB1ENR1_I2C1EN,
158  .rcc_sw_mask = RCC_CCIPR1_I2C1SEL_1,
159  .irqn = I2C1_ER_IRQn,
160  },
161  {
162  .dev = I2C2,
163  .speed = I2C_SPEED_NORMAL,
164  .scl_pin = GPIO_PIN(PORT_H, 4),
165  .sda_pin = GPIO_PIN(PORT_H, 5),
166  .scl_af = GPIO_AF4,
167  .sda_af = GPIO_AF4,
168  .bus = APB1,
169  .rcc_mask = RCC_APB1ENR1_I2C2EN,
170  .rcc_sw_mask = RCC_CCIPR1_I2C2SEL_1,
171  .irqn = I2C2_ER_IRQn,
172  },
173 };
174 
175 #define I2C_0_ISR isr_i2c1_er
176 #define I2C_1_ISR isr_i2c2_er
177 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
180 #ifdef __cplusplus
181 }
182 #endif
183 
@ PORT_B
port B
Definition: periph_cpu.h:47
@ 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
@ PORT_H
port H
Definition: periph_cpu.h:51
#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 i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:65
Common configuration for STM32 Timer peripheral based on TIM5.
Common configuration for STM32 OTG FS peripheral for U5 family.
@ GPIO_AF5
use alternate function 5
Definition: cpu_gpio.h:106
@ GPIO_AF4
use alternate function 4
Definition: cpu_gpio.h:105
@ GPIO_AF7
use alternate function 7
Definition: cpu_gpio.h:108
@ 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
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