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 
19 /* Add specific clock configuration (HSE, LSE) for this board here */
20 #ifndef CONFIG_BOARD_HAS_LSE
21 #define CONFIG_BOARD_HAS_LSE 1
22 #endif
23 
24 /* This board provides a 32MHz HSE oscillator */
25 #ifndef CONFIG_BOARD_HAS_HSE
26 #define CONFIG_BOARD_HAS_HSE 1
27 #endif
28 
29 #ifndef CONFIG_CLOCK_HSE
30 #define CONFIG_CLOCK_HSE MHZ(32)
31 #endif
32 
33 #include "periph_cpu.h"
34 #include "clk_conf.h"
35 #include "cfg_rtt_default.h"
36 #include "cfg_timer_tim2.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
46 static const uart_conf_t uart_config[] = {
47  {
48  .dev = USART1,
49  .rcc_mask = RCC_APB2ENR_USART1EN,
50  .rx_pin = GPIO_PIN(PORT_B, 7),
51  .tx_pin = GPIO_PIN(PORT_B, 6),
52  .rx_af = GPIO_AF7,
53  .tx_af = GPIO_AF7,
54  .bus = APB2,
55  .irqn = USART1_IRQn,
56  .type = STM32_USART,
57  .clk_src = 0, /* Use APB clock */
58  },
59  {
60  .dev = USART2,
61  .rcc_mask = RCC_APB1ENR1_USART2EN,
62  .rx_pin = GPIO_PIN(PORT_A, 3),
63  .tx_pin = GPIO_PIN(PORT_A, 2),
64  .rx_af = GPIO_AF7,
65  .tx_af = GPIO_AF7,
66  .bus = APB1,
67  .irqn = USART2_IRQn,
68  .type = STM32_USART,
69  .clk_src = 0, /* Use APB clock */
70  },
71  {
72  .dev = LPUART1,
73  .rcc_mask = RCC_APB1ENR2_LPUART1EN,
74  .rx_pin = GPIO_PIN(PORT_C, 1),
75  .tx_pin = GPIO_PIN(PORT_C, 0),
76  .rx_af = GPIO_AF8,
77  .tx_af = GPIO_AF8,
78  .bus = APB12,
79  .irqn = LPUART1_IRQn,
80  .type = STM32_LPUART,
81  .clk_src = 0, /* Use APB clock */
82  },
83 };
84 
85 #define UART_0_ISR isr_usart1
86 #define UART_1_ISR isr_usart2
87 #define UART_2_ISR isr_lpuart1
88 
89 #define UART_NUMOF ARRAY_SIZE(uart_config)
95 static const spi_conf_t spi_config[] = {
96  {
97  .dev = SUBGHZSPI, /* Internally connected to Sub-GHz radio Modem */
98  .mosi_pin = GPIO_UNDEF,
99  .miso_pin = GPIO_UNDEF,
100  .sclk_pin = GPIO_UNDEF,
101  .cs_pin = SPI_CS_UNDEF,
102  .mosi_af = GPIO_AF_UNDEF,
103  .miso_af = GPIO_AF_UNDEF,
104  .sclk_af = GPIO_AF_UNDEF,
105  .cs_af = GPIO_AF_UNDEF,
106  .rccmask = RCC_APB3ENR_SUBGHZSPIEN,
107  .apbbus = APB3,
108  },
109 /* SUBGHZ DEBUG PINS use the SPI1 pins */
110 #if !IS_ACTIVE(CONFIG_STM32_WLX5XX)
111  {
112  .dev = SPI2,
113  .mosi_pin = GPIO_PIN(PORT_A, 10),
114  .miso_pin = GPIO_PIN(PORT_B, 14),
115  .sclk_pin = GPIO_PIN(PORT_B, 13),
116  .cs_pin = SPI_CS_UNDEF,
117  .mosi_af = GPIO_AF5,
118  .miso_af = GPIO_AF5,
119  .sclk_af = GPIO_AF5,
120  .cs_af = GPIO_AF5,
121  .rccmask = RCC_APB1ENR1_SPI2EN,
122  .apbbus = APB1,
123  }
124 #endif
125 };
126 
127 #define SPI_NUMOF ARRAY_SIZE(spi_config)
134 static const i2c_conf_t i2c_config[] = {
135  {
136  .dev = I2C2,
137  .speed = I2C_SPEED_NORMAL,
138  .scl_pin = GPIO_PIN(PORT_B, 15),
139  .sda_pin = GPIO_PIN(PORT_A, 15),
140  .scl_af = GPIO_AF4,
141  .sda_af = GPIO_AF4,
142  .bus = APB1,
143  .rcc_mask = RCC_APB1ENR1_I2C2EN,
144  .rcc_sw_mask = RCC_CCIPR_I2C2SEL_1, /* HSI (16 MHz) */
145  .irqn = I2C2_ER_IRQn,
146  }
147 };
148 
149 #define I2C_1_ISR isr_i2c2_er
150 
151 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
158 static const adc_conf_t adc_config[] = {
159  { GPIO_PIN(PORT_B, 3), 2 },
160  { GPIO_PIN(PORT_B, 4), 3 },
161  { GPIO_UNDEF, 14 }, /* VBAT */
162 };
163 
164 #define VBAT_ADC ADC_LINE(2)
165 #define ADC_NUMOF ARRAY_SIZE(adc_config)
168 #ifdef __cplusplus
169 }
170 #endif
171 
@ PORT_B
port B
Definition: periph_cpu.h:44
@ PORT_C
port C
Definition: periph_cpu.h:45
@ PORT_A
port A
Definition: periph_cpu.h:43
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:42
#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
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:247
Common configuration for STM32 Timer peripheral based on TIM2.
@ 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_AF_UNDEF
an UNDEF value definition, e.g.
Definition: cpu_gpio.h:120
@ 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
#define SPI_CS_UNDEF
Define value for unused CS line.
Definition: periph_cpu.h:362
@ 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:274
ADC device configuration.
Definition: periph_cpu.h:374
I2C configuration structure.
Definition: periph_cpu.h:295
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:296
SPI device configuration.
Definition: periph_cpu.h:333
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:334
UART device configuration.
Definition: periph_cpu.h:214
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:215