periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Freie Universität Berlin
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 
21 #ifndef PERIPH_CONF_H
22 #define PERIPH_CONF_H
23 
24 /* Add specific clock configuration (HSE, LSE) for this board here */
25 #ifndef CONFIG_BOARD_HAS_LSE
26 #define CONFIG_BOARD_HAS_LSE 1
27 #endif
28 
29 /* This board provides a 32MHz HSE oscillator */
30 #ifndef CONFIG_BOARD_HAS_HSE
31 #define CONFIG_BOARD_HAS_HSE 1
32 #endif
33 
34 #ifndef CONFIG_CLOCK_HSE
35 #define CONFIG_CLOCK_HSE MHZ(32)
36 #endif
37 
38 #include "periph_cpu.h"
39 #include "clk_conf.h"
40 #include "cfg_rtt_default.h"
41 #include "cfg_timer_tim2.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
51 static const uart_conf_t uart_config[] = {
52  {
53  .dev = LPUART1,
54  .rcc_mask = RCC_APB1ENR2_LPUART1EN,
55  .rx_pin = GPIO_PIN(PORT_A, 3),
56  .tx_pin = GPIO_PIN(PORT_A, 2),
57  .rx_af = GPIO_AF8,
58  .tx_af = GPIO_AF8,
59  .bus = APB12,
60  .irqn = LPUART1_IRQn,
61  .type = STM32_LPUART,
62  .clk_src = 0, /* Use APB clock */
63  },
64  {
65  .dev = USART1,
66  .rcc_mask = RCC_APB2ENR_USART1EN,
67  .rx_pin = GPIO_PIN(PORT_B, 7),
68  .tx_pin = GPIO_PIN(PORT_B, 6),
69  .rx_af = GPIO_AF7,
70  .tx_af = GPIO_AF7,
71  .bus = APB2,
72  .irqn = USART1_IRQn,
73  .type = STM32_USART,
74  .clk_src = 0, /* Use APB clock */
75  },
76 };
77 
78 #define UART_0_ISR (isr_lpuart1)
79 #define UART_1_ISR (isr_usart1)
80 
81 #define UART_NUMOF ARRAY_SIZE(uart_config)
88 static const spi_conf_t spi_config[] = {
89  {
90  .dev = SUBGHZSPI, /* Internally connected to Sub-GHz radio Modem */
91  .mosi_pin = GPIO_UNDEF,
92  .miso_pin = GPIO_UNDEF,
93  .sclk_pin = GPIO_UNDEF,
94  .cs_pin = SPI_CS_UNDEF,
95  .mosi_af = GPIO_AF_UNDEF,
96  .miso_af = GPIO_AF_UNDEF,
97  .sclk_af = GPIO_AF_UNDEF,
98  .cs_af = GPIO_AF_UNDEF,
99  .rccmask = RCC_APB3ENR_SUBGHZSPIEN,
100  .apbbus = APB3,
101  },
102 /* SUBGHZ DEBUG PINS use the SPI1 pins */
103 #if !IS_ACTIVE(CONFIG_STM32_WLX5XX_SUBGHZ_DEBUG)
104  {
105  .dev = SPI1,
106  .mosi_pin = GPIO_PIN(PORT_A, 7),
107  .miso_pin = GPIO_PIN(PORT_A, 6),
108  .sclk_pin = GPIO_PIN(PORT_A, 5),
109  .cs_pin = SPI_CS_UNDEF,
110  .mosi_af = GPIO_AF5,
111  .miso_af = GPIO_AF5,
112  .sclk_af = GPIO_AF5,
113  .cs_af = GPIO_AF5,
114  .rccmask = RCC_APB2ENR_SPI1EN,
115  .apbbus = APB2,
116  }
117 #endif
118 };
119 
120 #define SPI_NUMOF ARRAY_SIZE(spi_config)
125 #define ARDUINO_SPI_D11D12D13 SPI_DEV(1)
132 static const i2c_conf_t i2c_config[] = {
133  {
134  .dev = I2C2,
135  .speed = I2C_SPEED_NORMAL,
136  .scl_pin = GPIO_PIN(PORT_A, 12),
137  .sda_pin = GPIO_PIN(PORT_A, 11),
138  .scl_af = GPIO_AF4,
139  .sda_af = GPIO_AF4,
140  .bus = APB1,
141  .rcc_mask = RCC_APB1ENR1_I2C2EN,
142  .rcc_sw_mask = RCC_CCIPR_I2C2SEL_1, /* HSI (16 MHz) */
143  .irqn = I2C2_ER_IRQn,
144  }
145 };
146 
147 #define I2C_1_ISR isr_i2c2_er
148 
149 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
177 static const adc_conf_t adc_config[] = {
178  {GPIO_PIN(PORT_B, 1), .chan = 5}, /* ADC1_IN5 */
179  {GPIO_PIN(PORT_B, 2), .chan = 4}, /* ADC1_IN4 */
180  {GPIO_PIN(PORT_A, 10), .chan = 6}, /* ADC1_IN6 */
181  {GPIO_PIN(PORT_B, 4), .chan = 3}, /* ADC1_IN3 */
182  {GPIO_PIN(PORT_B, 14), .chan = 1}, /* ADC1_IN1 */
183  {GPIO_PIN(PORT_B, 13), .chan = 0}, /* ADC1_IN0 */
184  {GPIO_UNDEF, .chan = 14}, /* VBAT see datasheet point 3.20.3 */
185 };
186 
187 #define ADC_NUMOF ARRAY_SIZE(adc_config)
188 
189 #define VBAT_ADC ADC_LINE(6)
192 #ifdef __cplusplus
193 }
194 #endif
195 
196 #endif /* PERIPH_CONF_H */
@ PORT_B
port B
Definition: periph_cpu.h:48
@ PORT_A
port A
Definition: periph_cpu.h:47
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:46
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
static const uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:39
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:97
static const i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:69
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:251
Common configuration for STM32 Timer peripheral based on TIM2.
@ GPIO_AF5
use alternate function 5
Definition: cpu_gpio.h:107
@ GPIO_AF4
use alternate function 4
Definition: cpu_gpio.h:106
@ GPIO_AF8
use alternate function 8
Definition: cpu_gpio.h:111
@ GPIO_AF_UNDEF
an UNDEF value definition, e.g.
Definition: cpu_gpio.h:121
@ GPIO_AF7
use alternate function 7
Definition: cpu_gpio.h:109
@ STM32_LPUART
STM32 Low-power UART (LPUART) module type.
Definition: cpu_uart.h:39
@ STM32_USART
STM32 USART module type.
Definition: cpu_uart.h:38
#define SPI_CS_UNDEF
Define value for unused CS line.
Definition: periph_cpu.h:363
@ APB1
Advanced Peripheral Bus 1
Definition: periph_cpu.h:79
@ APB2
Advanced Peripheral Bus 2
Definition: periph_cpu.h:80
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:278
ADC device configuration.
Definition: periph_cpu.h:379
I2C configuration structure.
Definition: periph_cpu.h:299
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:300
SPI device configuration.
Definition: periph_cpu.h:337
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:338
UART device configuration.
Definition: periph_cpu.h:218
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:219