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 
9 #pragma once
10 
23 /* Add specific clock configuration (HSE, LSE) for this board here */
24 #ifndef CONFIG_BOARD_HAS_LSE
25 #define CONFIG_BOARD_HAS_LSE 1
26 #endif
27 
28 /* This board provides a 32MHz HSE oscillator */
29 #ifndef CONFIG_BOARD_HAS_HSE
30 #define CONFIG_BOARD_HAS_HSE 1
31 #endif
32 
33 #ifndef CONFIG_CLOCK_HSE
34 #define CONFIG_CLOCK_HSE MHZ(32)
35 #endif
36 
37 #include "periph_cpu.h"
38 #include "clk_conf.h"
39 #include "cfg_rtt_default.h"
40 #include "cfg_timer_tim2.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
50 static const uart_conf_t uart_config[] = {
51  {
52  .dev = LPUART1,
53  .rcc_mask = RCC_APB1ENR2_LPUART1EN,
54  .rx_pin = GPIO_PIN(PORT_A, 3),
55  .tx_pin = GPIO_PIN(PORT_A, 2),
56  .rx_af = GPIO_AF8,
57  .tx_af = GPIO_AF8,
58  .bus = APB12,
59  .irqn = LPUART1_IRQn,
60  .type = STM32_LPUART,
61  .clk_src = 0, /* Use APB clock */
62  },
63  {
64  .dev = USART1,
65  .rcc_mask = RCC_APB2ENR_USART1EN,
66  .rx_pin = GPIO_PIN(PORT_B, 7),
67  .tx_pin = GPIO_PIN(PORT_B, 6),
68  .rx_af = GPIO_AF7,
69  .tx_af = GPIO_AF7,
70  .bus = APB2,
71  .irqn = USART1_IRQn,
72  .type = STM32_USART,
73  .clk_src = 0, /* Use APB clock */
74  },
75 };
76 
77 #define UART_0_ISR (isr_lpuart1)
78 #define UART_1_ISR (isr_usart1)
79 
80 #define UART_NUMOF ARRAY_SIZE(uart_config)
87 static const spi_conf_t spi_config[] = {
88  {
89  .dev = SUBGHZSPI, /* Internally connected to Sub-GHz radio Modem */
90  .mosi_pin = GPIO_UNDEF,
91  .miso_pin = GPIO_UNDEF,
92  .sclk_pin = GPIO_UNDEF,
93  .cs_pin = SPI_CS_UNDEF,
94  .mosi_af = GPIO_AF_UNDEF,
95  .miso_af = GPIO_AF_UNDEF,
96  .sclk_af = GPIO_AF_UNDEF,
97  .cs_af = GPIO_AF_UNDEF,
98  .rccmask = RCC_APB3ENR_SUBGHZSPIEN,
99  .apbbus = APB3,
100  },
101 /* SUBGHZ DEBUG PINS use the SPI1 pins */
102 #if !IS_ACTIVE(CONFIG_STM32_WLX5XX_SUBGHZ_DEBUG)
103  {
104  .dev = SPI1,
105  .mosi_pin = GPIO_PIN(PORT_A, 7),
106  .miso_pin = GPIO_PIN(PORT_A, 6),
107  .sclk_pin = GPIO_PIN(PORT_A, 5),
108  .cs_pin = SPI_CS_UNDEF,
109  .mosi_af = GPIO_AF5,
110  .miso_af = GPIO_AF5,
111  .sclk_af = GPIO_AF5,
112  .cs_af = GPIO_AF5,
113  .rccmask = RCC_APB2ENR_SPI1EN,
114  .apbbus = APB2,
115  }
116 #endif
117 };
118 
119 #define SPI_NUMOF ARRAY_SIZE(spi_config)
124 #define ARDUINO_SPI_D11D12D13 SPI_DEV(1)
131 static const i2c_conf_t i2c_config[] = {
132  {
133  .dev = I2C2,
134  .speed = I2C_SPEED_NORMAL,
135  .scl_pin = GPIO_PIN(PORT_A, 12),
136  .sda_pin = GPIO_PIN(PORT_A, 11),
137  .scl_af = GPIO_AF4,
138  .sda_af = GPIO_AF4,
139  .bus = APB1,
140  .rcc_mask = RCC_APB1ENR1_I2C2EN,
141  .rcc_sw_mask = RCC_CCIPR_I2C2SEL_1, /* HSI (16 MHz) */
142  .irqn = I2C2_ER_IRQn,
143  }
144 };
145 
146 #define I2C_1_ISR isr_i2c2_er
147 
148 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
176 static const adc_conf_t adc_config[] = {
177  {GPIO_PIN(PORT_B, 1), .chan = 5}, /* ADC1_IN5 */
178  {GPIO_PIN(PORT_B, 2), .chan = 4}, /* ADC1_IN4 */
179  {GPIO_PIN(PORT_A, 10), .chan = 6}, /* ADC1_IN6 */
180  {GPIO_PIN(PORT_B, 4), .chan = 3}, /* ADC1_IN3 */
181  {GPIO_PIN(PORT_B, 14), .chan = 1}, /* ADC1_IN1 */
182  {GPIO_PIN(PORT_B, 13), .chan = 0}, /* ADC1_IN0 */
183  {GPIO_UNDEF, .chan = 14}, /* VBAT see datasheet point 3.20.3 */
184 };
185 
186 #define ADC_NUMOF ARRAY_SIZE(adc_config)
187 
188 #define VBAT_ADC ADC_LINE(6)
191 #ifdef __cplusplus
192 }
193 #endif
194 
@ PORT_B
port B
Definition: periph_cpu.h:47
@ 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: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 adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:250
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:277
ADC device configuration.
Definition: periph_cpu.h:377
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