periph_conf.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2017 Freie Universität Berlin
3  * SPDX-FileCopyrightText: 2017 Inria
4  * SPDX-License-Identifier: LGPL-2.1-only
5  */
6 
7 #pragma once
8 
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 #include "periph_cpu.h"
26 #include "clk_conf.h"
27 #include "cfg_rtt_default.h"
28 #include "cfg_timer_tim2.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
38 static const uart_conf_t uart_config[] = {
39  {
40  .dev = USART2,
41  .rcc_mask = RCC_APB1ENR_USART2EN,
42  .rx_pin = GPIO_PIN(PORT_A, 3),
43  .tx_pin = GPIO_PIN(PORT_A, 2),
44  .rx_af = GPIO_AF4,
45  .tx_af = GPIO_AF4,
46  .bus = APB1,
47  .irqn = USART2_IRQn,
48  .type = STM32_USART,
49  .clk_src = 0, /* Use APB clock */
50  },
51  {
52  .dev = USART1,
53  .rcc_mask = RCC_APB2ENR_USART1EN,
54  .rx_pin = GPIO_PIN(PORT_A, 10),
55  .tx_pin = GPIO_PIN(PORT_A, 9),
56  .rx_af = GPIO_AF4,
57  .tx_af = GPIO_AF4,
58  .bus = APB2,
59  .irqn = USART1_IRQn,
60  .type = STM32_USART,
61  .clk_src = 0, /* Use APB clock */
62  }
63 };
64 
65 #define UART_0_ISR (isr_usart2)
66 #define UART_1_ISR (isr_usart1)
67 
68 #define UART_NUMOF ARRAY_SIZE(uart_config)
75 static const pwm_conf_t pwm_config[] = {
76  {
77  .dev = TIM22,
78  .rcc_mask = RCC_APB2ENR_TIM22EN,
79  .chan = { { .pin = GPIO_PIN(PORT_B, 4) /* D5 */, .cc_chan = 0 },
80  { .pin = GPIO_PIN(PORT_B, 5), .cc_chan = 1 },
81  { .pin = GPIO_UNDEF, .cc_chan = 0 },
82  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
83  .af = GPIO_AF4,
84  .bus = APB2
85  }
86 };
87 
88 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
95 static const spi_conf_t spi_config[] = {
96  {
97  .dev = SPI1,
98  .mosi_pin = GPIO_PIN(PORT_A, 7),
99  .miso_pin = GPIO_PIN(PORT_A, 6),
100  .sclk_pin = GPIO_PIN(PORT_A, 5),
101  .cs_pin = SPI_CS_UNDEF,
102  .mosi_af = GPIO_AF0,
103  .miso_af = GPIO_AF0,
104  .sclk_af = GPIO_AF0,
105  .cs_af = GPIO_AF0,
106  .rccmask = RCC_APB2ENR_SPI1EN,
107  .apbbus = APB2
108  }
109 };
110 
111 #define SPI_NUMOF ARRAY_SIZE(spi_config)
114 #ifdef __cplusplus
115 }
116 #endif
117 
@ 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:35
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:93
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:218
Common configuration for STM32 Timer peripheral based on TIM2.
@ GPIO_AF4
use alternate function 4
Definition: cpu_gpio.h:105
@ GPIO_AF0
use alternate function 0
Definition: cpu_gpio.h:101
@ 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
PWM device configuration.
mini_timer_t * dev
Timer used.
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