periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 twostairs
3  * 2017 Inria
4  * 2017 OTA keys
5  *
6  * This file is subject to the terms and conditions of the GNU Lesser
7  * General Public License v2.1. See the file LICENSE in the top level
8  * directory for more details.
9  */
10 
11 #pragma once
12 
25 /* Add specific clock configuration (HSE, LSE) for this board here */
26 #ifndef CONFIG_BOARD_HAS_LSE
27 #define CONFIG_BOARD_HAS_LSE 1
28 #endif
29 
30 #include "periph_cpu.h"
31 #include "clk_conf.h"
32 #include "cfg_i2c1_pb6_pb7.h"
33 #include "cfg_timer_tim2.h"
34 #include "cfg_rtt_default.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
44 static const uart_conf_t uart_config[] = {
45  {
46  .dev = USART2,
47  .rcc_mask = RCC_APB1ENR1_USART2EN,
48  .rx_pin = GPIO_PIN(PORT_A, 15),
49  .tx_pin = GPIO_PIN(PORT_A, 2),
50  .rx_af = GPIO_AF3,
51  .tx_af = GPIO_AF7,
52  .bus = APB1,
53  .irqn = USART2_IRQn,
54  .type = STM32_USART,
55  .clk_src = 0, /* Use APB clock */
56  },
57  {
58  .dev = USART1,
59  .rcc_mask = RCC_APB2ENR_USART1EN,
60  .rx_pin = GPIO_PIN(PORT_A, 10),
61  .tx_pin = GPIO_PIN(PORT_A, 9),
62  .rx_af = GPIO_AF7,
63  .tx_af = GPIO_AF7,
64  .bus = APB2,
65  .irqn = USART1_IRQn,
66  .type = STM32_USART,
67  .clk_src = 0, /* Use APB clock */
68  },
69 };
70 
71 #define UART_0_ISR (isr_usart2)
72 #define UART_1_ISR (isr_usart1)
73 
74 #define UART_NUMOF ARRAY_SIZE(uart_config)
81 static const pwm_conf_t pwm_config[] = {
82  {
83  .dev = TIM1,
84  .rcc_mask = RCC_APB2ENR_TIM1EN,
85  .chan = { { .pin = GPIO_PIN(PORT_A, 8) /* D9 */, .cc_chan = 0 },
86  { .pin = GPIO_UNDEF, .cc_chan = 0 },
87  { .pin = GPIO_UNDEF, .cc_chan = 0 },
88  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
89  .af = GPIO_AF1,
90  .bus = APB2
91  }
92 };
93 
94 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
101 static const spi_conf_t spi_config[] = {
102  {
103  .dev = SPI1,
104  .mosi_pin = GPIO_PIN(PORT_B, 5),
105  .miso_pin = GPIO_PIN(PORT_B, 4),
106  .sclk_pin = GPIO_PIN(PORT_B, 3),
107  .cs_pin = SPI_CS_UNDEF,
108  .mosi_af = GPIO_AF5,
109  .miso_af = GPIO_AF5,
110  .sclk_af = GPIO_AF5,
111  .cs_af = GPIO_AF5,
112  .rccmask = RCC_APB2ENR_SPI1EN,
113  .apbbus = APB2
114  }
115 };
116 
117 #define SPI_NUMOF ARRAY_SIZE(spi_config)
120 #ifdef __cplusplus
121 }
122 #endif
123 
@ 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 pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:221
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_AF3
use alternate function 3
Definition: cpu_gpio.h:104
@ GPIO_AF7
use alternate function 7
Definition: cpu_gpio.h:108
@ 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