Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
19
20/* Add specific clock configuration (HSE, LSE) for this board here */
21#ifndef CONFIG_BOARD_HAS_LSE
22#define CONFIG_BOARD_HAS_LSE 1
23#endif
24
25/* This board provides a 32MHz HSE oscillator */
26#ifndef CONFIG_BOARD_HAS_HSE
27#define CONFIG_BOARD_HAS_HSE 1
28#endif
29
30#ifndef CONFIG_CLOCK_HSE
31#define CONFIG_CLOCK_HSE MHZ(32)
32#endif
33
34#include "periph_cpu.h"
35#include "clk_conf.h"
36#include "cfg_rtt_default.h"
37#include "cfg_timer_tim2.h"
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
47static const uart_conf_t uart_config[] = {
48 {
49 .dev = LPUART1,
50 .rcc_mask = RCC_APB1ENR2_LPUART1EN,
51 .rx_pin = GPIO_PIN(PORT_A, 3),
52 .tx_pin = GPIO_PIN(PORT_A, 2),
53 .rx_af = GPIO_AF8,
54 .tx_af = GPIO_AF8,
55 .bus = APB12,
56 .irqn = LPUART1_IRQn,
57 .type = STM32_LPUART,
58 .clk_src = 0, /* Use APB clock */
59 },
60 {
61 .dev = USART1,
62 .rcc_mask = RCC_APB2ENR_USART1EN,
63 .rx_pin = GPIO_PIN(PORT_B, 7),
64 .tx_pin = GPIO_PIN(PORT_B, 6),
65 .rx_af = GPIO_AF7,
66 .tx_af = GPIO_AF7,
67 .bus = APB2,
68 .irqn = USART1_IRQn,
69 .type = STM32_USART,
70 .clk_src = 0, /* Use APB clock */
71 },
72};
73
74#define UART_0_ISR (isr_lpuart1)
75#define UART_1_ISR (isr_usart1)
76
77#define UART_NUMOF ARRAY_SIZE(uart_config)
79
84static const spi_conf_t spi_config[] = {
85 {
86 .dev = SUBGHZSPI, /* Internally connected to Sub-GHz radio Modem */
87 .mosi_pin = GPIO_UNDEF,
88 .miso_pin = GPIO_UNDEF,
89 .sclk_pin = GPIO_UNDEF,
90 .cs_pin = SPI_CS_UNDEF,
91 .mosi_af = GPIO_AF_UNDEF,
92 .miso_af = GPIO_AF_UNDEF,
93 .sclk_af = GPIO_AF_UNDEF,
94 .cs_af = GPIO_AF_UNDEF,
95 .rccmask = RCC_APB3ENR_SUBGHZSPIEN,
96 .apbbus = APB3,
97 },
98/* SUBGHZ DEBUG PINS use the SPI1 pins */
99#if !IS_ACTIVE(CONFIG_STM32_WLX5XX_SUBGHZ_DEBUG)
100 {
101 .dev = SPI1,
102 .mosi_pin = GPIO_PIN(PORT_A, 7),
103 .miso_pin = GPIO_PIN(PORT_A, 6),
104 .sclk_pin = GPIO_PIN(PORT_A, 5),
105 .cs_pin = SPI_CS_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#endif
114};
115
116#define SPI_NUMOF ARRAY_SIZE(spi_config)
121#define ARDUINO_SPI_D11D12D13 SPI_DEV(1)
123
128static const i2c_conf_t i2c_config[] = {
129 {
130 .dev = I2C2,
131 .speed = I2C_SPEED_NORMAL,
132 .scl_pin = GPIO_PIN(PORT_A, 12),
133 .sda_pin = GPIO_PIN(PORT_A, 11),
134 .scl_af = GPIO_AF4,
135 .sda_af = GPIO_AF4,
136 .bus = APB1,
137 .rcc_mask = RCC_APB1ENR1_I2C2EN,
138 .rcc_sw_mask = RCC_CCIPR_I2C2SEL_1, /* HSI (16 MHz) */
139 .irqn = I2C2_ER_IRQn,
140 }
141};
142
143#define I2C_1_ISR isr_i2c2_er
144
145#define I2C_NUMOF ARRAY_SIZE(i2c_config)
147
173static const adc_conf_t adc_config[] = {
174 {GPIO_PIN(PORT_B, 1), .chan = 5}, /* ADC1_IN5 */
175 {GPIO_PIN(PORT_B, 2), .chan = 4}, /* ADC1_IN4 */
176 {GPIO_PIN(PORT_A, 10), .chan = 6}, /* ADC1_IN6 */
177 {GPIO_PIN(PORT_B, 4), .chan = 3}, /* ADC1_IN3 */
178 {GPIO_PIN(PORT_B, 14), .chan = 1}, /* ADC1_IN1 */
179 {GPIO_PIN(PORT_B, 13), .chan = 0}, /* ADC1_IN0 */
180 {GPIO_UNDEF, .chan = 14}, /* VBAT see datasheet point 3.20.3 */
181};
182
183#define ADC_NUMOF ARRAY_SIZE(adc_config)
184
185#define VBAT_ADC ADC_LINE(6)
187
188#ifdef __cplusplus
189}
190#endif
191
@ PORT_B
port B
Definition periph_cpu.h:44
@ 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.
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:274
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
ADC device configuration.
Definition periph_cpu.h:374
I2C configuration structure.
Definition periph_cpu.h:295
SPI device configuration.
Definition periph_cpu.h:333
UART device configuration.
Definition periph_cpu.h:214