periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Inria
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 
9 #pragma once
10 
21 /* Add specific clock configuration (HSE, LSE) for this board here */
22 #ifndef CONFIG_BOARD_HAS_LSE
23 #define CONFIG_BOARD_HAS_LSE 1
24 #endif
25 
26 #include "periph_cpu.h"
27 #include "clk_conf.h"
28 #include "cfg_rtt_default.h"
29 #include "cfg_timer_tim2.h"
30 #include "cfg_usb_otg_fs.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
40 static const uart_conf_t uart_config[] = {
41  {
42  .dev = USART2,
43  .rcc_mask = RCC_APB1ENR1_USART2EN,
44  .rx_pin = GPIO_PIN(PORT_D, 6),
45  .tx_pin = GPIO_PIN(PORT_A, 2),
46  .rx_af = GPIO_AF7,
47  .tx_af = GPIO_AF7,
48  .bus = APB1,
49  .irqn = USART2_IRQn,
50 #ifdef MODULE_PERIPH_UART_HW_FC
51  .cts_pin = GPIO_UNDEF,
52  .rts_pin = GPIO_UNDEF,
53  .cts_af = GPIO_AF7,
54  .rts_af = GPIO_AF7,
55 #endif
56  .type = STM32_USART,
57  .clk_src = 0, /* Use APB clock */
58  },
59  { /* Arduino pinout RX/TX pins on D0/D1 */
60  .dev = LPUART1,
61  .rcc_mask = RCC_APB1ENR2_LPUART1EN,
62  .rx_pin = GPIO_PIN(PORT_G, 8),
63  .tx_pin = GPIO_PIN(PORT_G, 7),
64  .rx_af = GPIO_AF8,
65  .tx_af = GPIO_AF8,
66  .bus = APB12,
67  .irqn = LPUART1_IRQn,
68 #ifdef MODULE_PERIPH_UART_HW_FC
69  .cts_pin = GPIO_UNDEF,
70  .rts_pin = GPIO_UNDEF,
71  .cts_af = GPIO_AF7,
72  .rts_af = GPIO_AF7,
73 #endif
74  .type = STM32_LPUART,
75  .clk_src = 0,
76  },
77  { /* STMod+/PMOD connectors */
78  .dev = USART1,
79  .rcc_mask = RCC_APB2ENR_USART1EN,
80  .rx_pin = GPIO_PIN(PORT_G, 10),
81  .tx_pin = GPIO_PIN(PORT_B, 6),
82  .rx_af = GPIO_AF7,
83  .tx_af = GPIO_AF7,
84  .bus = APB2,
85  .irqn = USART1_IRQn,
86 #ifdef MODULE_PERIPH_UART_HW_FC
87  .cts_pin = GPIO_PIN(PORT_G, 11),
88  .rts_pin = GPIO_PIN(PORT_G, 12),
89  .cts_af = GPIO_AF7,
90  .rts_af = GPIO_AF7,
91 #endif
92  .type = STM32_USART,
93  .clk_src = 0, /* Use APB clock */
94  }
95 };
96 
97 #define UART_0_ISR (isr_usart2)
98 #define UART_1_ISR (isr_lpuart1)
99 #define UART_2_ISR (isr_usart1)
100 
101 #define UART_NUMOF ARRAY_SIZE(uart_config)
108 static const i2c_conf_t i2c_config[] = {
109  {
110  .dev = I2C1,
111  .speed = I2C_SPEED_NORMAL,
112  .scl_pin = GPIO_PIN(PORT_B, 8),
113  .sda_pin = GPIO_PIN(PORT_B, 7),
114  .scl_af = GPIO_AF4,
115  .sda_af = GPIO_AF4,
116  .bus = APB1,
117  .rcc_mask = RCC_APB1ENR1_I2C1EN,
118  .rcc_sw_mask = RCC_CCIPR_I2C1SEL_1, /* HSI (16 MHz) */
119  .irqn = I2C1_ER_IRQn
120  },
121 };
122 
123 #define I2C_0_ISR isr_i2c1_er
124 
125 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
132 static const spi_conf_t spi_config[] = {
133  {
134  .dev = SPI1,
135  .mosi_pin = GPIO_PIN(PORT_B, 5),
136  .miso_pin = GPIO_PIN(PORT_B, 4),
137  .sclk_pin = GPIO_PIN(PORT_A, 5),
138  .cs_pin = SPI_CS_UNDEF,
139  .mosi_af = GPIO_AF5,
140  .miso_af = GPIO_AF5,
141  .sclk_af = GPIO_AF5,
142  .cs_af = GPIO_AF5,
143  .rccmask = RCC_APB2ENR_SPI1EN,
144  .apbbus = APB2
145  }
146 };
147 
148 #define SPI_NUMOF ARRAY_SIZE(spi_config)
151 #ifdef __cplusplus
152 }
153 #endif
154 
@ PORT_B
port B
Definition: periph_cpu.h:47
@ PORT_G
port G
Definition: periph_cpu.h:52
@ PORT_A
port A
Definition: periph_cpu.h:46
@ PORT_D
port D
Definition: periph_cpu.h:49
#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 i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:68
Common configuration for STM32 Timer peripheral based on TIM2.
Common configuration for STM32 OTG FS peripheral.
@ 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_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
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:277
I2C configuration structure.
Definition: periph_cpu.h:298
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:299
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