periph_conf.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2017 Inria
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
19 /* Add specific clock configuration (HSE, LSE) for this board here */
20 #ifndef CONFIG_BOARD_HAS_LSE
21 #define CONFIG_BOARD_HAS_LSE 1
22 #endif
23 
24 #include "periph_cpu.h"
25 #include "clk_conf.h"
26 #include "cfg_rtt_default.h"
27 #include "cfg_i2c1_pb8_pb9.h"
28 #include "cfg_timer_tim2.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
38 static const dma_conf_t dma_config[] = {
39  { .stream = 1 }, /* channel 2 */
40  { .stream = 2 }, /* channel 3 */
41  { .stream = 3 }, /* channel 4 */
42  { .stream = 4 }, /* channel 5 */
43  { .stream = 5 }, /* channel 6 */
44 };
45 
46 #define DMA_SHARED_ISR_0 isr_dma1_channel2_3
47 #define DMA_SHARED_ISR_0_STREAMS { 0, 1 } /* Indexes 0 and 1 of dma_config share the same isr */
48 #define DMA_SHARED_ISR_1 isr_dma1_channel4_5_6_7
49 #define DMA_SHARED_ISR_1_STREAMS { 2, 3, 4 } /* Indexes 2, 3 and 4 of dma_config share the same isr */
50 
51 #define DMA_NUMOF ARRAY_SIZE(dma_config)
58 static const uart_conf_t uart_config[] = {
59  {
60  .dev = USART2,
61  .rcc_mask = RCC_APB1ENR_USART2EN,
62  .rx_pin = GPIO_PIN(PORT_A, 3),
63  .tx_pin = GPIO_PIN(PORT_A, 2),
64  .rx_af = GPIO_AF4,
65  .tx_af = GPIO_AF4,
66  .bus = APB1,
67  .irqn = USART2_IRQn,
68  .type = STM32_USART,
69  .clk_src = 0, /* Use APB clock */
70 #ifdef MODULE_PERIPH_DMA
71  .dma = 2,
72  .dma_chan = 4,
73 #endif
74  },
75  {
76  .dev = USART1,
77  .rcc_mask = RCC_APB2ENR_USART1EN,
78  .rx_pin = GPIO_PIN(PORT_A, 10),
79  .tx_pin = GPIO_PIN(PORT_A, 9),
80  .rx_af = GPIO_AF4,
81  .tx_af = GPIO_AF4,
82  .bus = APB2,
83  .irqn = USART1_IRQn,
84  .type = STM32_USART,
85  .clk_src = 0, /* Use APB clock */
86 #ifdef MODULE_PERIPH_DMA
87  .dma = 0,
88  .dma_chan = 3,
89 #endif
90  },
91 };
92 
93 #define UART_0_ISR (isr_usart2)
94 #define UART_1_ISR (isr_usart1)
95 
96 #define UART_NUMOF ARRAY_SIZE(uart_config)
103 static const spi_conf_t spi_config[] = {
104  {
105  .dev = SPI2,
106  .mosi_pin = GPIO_PIN(PORT_B, 15),
107  .miso_pin = GPIO_PIN(PORT_B, 14),
108  .sclk_pin = GPIO_PIN(PORT_B, 13),
109  .cs_pin = SPI_CS_UNDEF,
110  .mosi_af = GPIO_AF0,
111  .miso_af = GPIO_AF0,
112  .sclk_af = GPIO_AF0,
113  .cs_af = GPIO_AF0,
114  .rccmask = RCC_APB1ENR_SPI2EN,
115  .apbbus = APB1,
116 #ifdef MODULE_PERIPH_DMA
117  .tx_dma = 3,
118  .tx_dma_chan = 2,
119  .rx_dma = 2,
120  .rx_dma_chan = 2,
121 #endif
122  },
123  {
124  .dev = SPI1, /* connected to SX1276 */
125  .mosi_pin = GPIO_PIN(PORT_A, 7),
126  .miso_pin = GPIO_PIN(PORT_A, 6),
127  .sclk_pin = GPIO_PIN(PORT_B, 3),
128  .cs_pin = SPI_CS_UNDEF,
129  .mosi_af = GPIO_AF0,
130  .miso_af = GPIO_AF0,
131  .sclk_af = GPIO_AF0,
132  .cs_af = GPIO_AF0,
133  .rccmask = RCC_APB2ENR_SPI1EN,
134  .apbbus = APB2,
135 #ifdef MODULE_PERIPH_DMA
136  .tx_dma = 1,
137  .tx_dma_chan = 1,
138  .rx_dma = 0,
139  .rx_dma_chan = 1,
140 #endif
141  },
142 };
143 
144 #define SPI_NUMOF ARRAY_SIZE(spi_config)
151 static const adc_conf_t adc_config[] = {
152  { GPIO_PIN(PORT_A, 0), 0 },
153  { GPIO_PIN(PORT_A, 2), 2 },
154  { GPIO_PIN(PORT_A, 3), 3 },
155  { GPIO_PIN(PORT_A, 4), 4 },
156  { GPIO_PIN(PORT_A, 5), 5 }
157 };
158 
159 #define ADC_NUMOF ARRAY_SIZE(adc_config)
162 #ifdef __cplusplus
163 }
164 #endif
165 
@ 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
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 adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:247
Common configuration for STM32 I2C.
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
ADC device configuration.
Definition: periph_cpu.h:377
DMA configuration.
Definition: cpu_dma.h:31
int stream
DMA stream on stm32f2/4/7, channel on others STM32F2/4/7:
Definition: cpu_dma.h:54
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