Loading...
Searching...
No Matches
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
44extern "C" {
45#endif
46
51static 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)
88static 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)
132static 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)
152#ifdef __cplusplus
153}
154#endif
155
156#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.
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:278
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 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