Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Inria
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18/* Add specific clock configuration (HSE, LSE) for this board here */
19#ifndef CONFIG_BOARD_HAS_LSE
20#define CONFIG_BOARD_HAS_LSE 1
21#endif
22
23#ifndef CONFIG_BOARD_HAS_HSE
24#define CONFIG_BOARD_HAS_HSE 1
25#endif
26
27#ifndef CONFIG_CLOCK_HSE
28#define CONFIG_CLOCK_HSE MHZ(32)
29#endif
30
31/* EXTAHB (HCLK2) max freq 32 Mhz*/
32#define CLOCK_EXTAHB_DIV RCC_EXTCFGR_C2HPRE_3
33#define CLOCK_EXTAHB (CLOCK_CORECLOCK / 2)
34
35#include "periph_cpu.h"
36#include "clk_conf.h"
37#include "cfg_i2c1_pb8_pb9.h"
38#include "cfg_rtt_default.h"
39#include "cfg_timer_tim2.h"
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
49static const uart_conf_t uart_config[] = {
50 {
51 .dev = USART1,
52 .rcc_mask = RCC_APB2ENR_USART1EN,
53 .rx_pin = GPIO_PIN(PORT_B, 7),
54 .tx_pin = GPIO_PIN(PORT_B, 6),
55 .rx_af = GPIO_AF7,
56 .tx_af = GPIO_AF7,
57 .bus = APB2,
58 .irqn = USART1_IRQn,
59 .type = STM32_USART,
60 .clk_src = 0, /* Use APB clock */
61 },
62 {
63 .dev = LPUART1,
64 .rcc_mask = RCC_APB1ENR2_LPUART1EN,
65 .rx_pin = GPIO_PIN(PORT_A, 3),
66 .tx_pin = GPIO_PIN(PORT_A, 2),
67 .rx_af = GPIO_AF8,
68 .tx_af = GPIO_AF8,
69 .bus = APB12,
70 .irqn = LPUART1_IRQn,
71 .type = STM32_LPUART,
72 .clk_src = 0, /* Use APB clock */
73 },
74};
75
76#define UART_0_ISR (isr_usart1)
77#define UART_1_ISR (isr_lpuart1)
78
79#define UART_NUMOF ARRAY_SIZE(uart_config)
81
86static const spi_conf_t spi_config[] = {
87 {
88 .dev = SPI1,
89 .mosi_pin = GPIO_PIN(PORT_A, 7),
90 .miso_pin = GPIO_PIN(PORT_A, 6),
91 .sclk_pin = GPIO_PIN(PORT_A, 5),
92 .cs_pin = SPI_CS_UNDEF,
93 .mosi_af = GPIO_AF5,
94 .miso_af = GPIO_AF5,
95 .sclk_af = GPIO_AF5,
96 .cs_af = GPIO_AF5,
97 .rccmask = RCC_APB2ENR_SPI1EN,
98 .apbbus = APB2,
99 }
100};
101
102#define SPI_NUMOF ARRAY_SIZE(spi_config)
104
120static const pwm_conf_t pwm_config[] = {
121 {
122 .dev = TIM1,
123 .rcc_mask = RCC_APB2ENR_TIM1EN,
124 .chan = { { .pin = GPIO_PIN(PORT_A, 8) /* CN9 D6 */, .cc_chan = 0},
125 { .pin = GPIO_PIN(PORT_A, 9) /* CN5 D9 */, .cc_chan = 1},
126 { .pin = GPIO_PIN(PORT_A, 10) /* CN9 D3 */, .cc_chan = 2},
127 { .pin = GPIO_PIN(PORT_A, 11) /* CC10 14 */, .cc_chan = 3} },
128 .af = GPIO_AF1,
129 .bus = APB2
130 },
131};
132
133#define PWM_NUMOF ARRAY_SIZE(pwm_config)
134
136
141 {
142 .base_addr = (uintptr_t)USB,
143 .rcc_mask = RCC_APB1ENR1_USBEN | RCC_APB1ENR1_CRSEN,
144 .irqn = USB_LP_IRQn,
145 .apb = APB1,
146 .dm = GPIO_PIN(PORT_A, 11),
147 .dp = GPIO_PIN(PORT_A, 12),
148 .af = GPIO_AF10,
149 .disconn = GPIO_UNDEF,
150 },
151};
152
156#define USBDEV_ISR isr_usb_lp
157
161#define USBDEV_NUMOF ARRAY_SIZE(stm32_usbdev_fs_config)
162
191static const adc_conf_t adc_config[] = {
192 {GPIO_PIN(PORT_C, 0), 0, 1}, /*< ADC1_IN1 */
193 {GPIO_PIN(PORT_C, 1), 0, 2}, /*< ADC1_IN2 */
194 {GPIO_PIN(PORT_A, 1), 0, 6}, /*< ADC1_IN6 */
195 {GPIO_PIN(PORT_A, 0), 0, 5}, /*< ADC1_IN5 */
196 {GPIO_PIN(PORT_C, 3), 0, 4}, /*< ADC1_IN4 */
197 {GPIO_PIN(PORT_C, 2), 0, 3}, /*< ADC1_IN3 */
198 {GPIO_UNDEF, 0, 18}, /* VBAT */
199};
200
201#define VBAT_ADC ADC_LINE(6)
202#define ADC_NUMOF ARRAY_SIZE(adc_config)
204
205#ifdef __cplusplus
206}
207#endif
208
@ 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 stm32_usbdev_fs_config_t stm32_usbdev_fs_config[]
USB device FS configuration.
Common configuration for STM32 I2C.
Common configuration for STM32 Timer peripheral based on TIM2.
@ GPIO_AF1
use alternate function 1
Definition cpu_gpio.h:102
@ GPIO_AF5
use alternate function 5
Definition cpu_gpio.h:106
@ GPIO_AF8
use alternate function 8
Definition cpu_gpio.h:110
@ GPIO_AF10
use alternate function 10
Definition cpu_gpio.h:112
@ 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
PWM device configuration.
SPI device configuration.
Definition periph_cpu.h:333
stm32 USB device FS configuration
Definition cpu_usbdev.h:44
UART device configuration.
Definition periph_cpu.h:214