Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Lari Lehtomäki
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
20
21/* This board provides an LSE */
22#ifndef CONFIG_BOARD_HAS_LSE
23#define CONFIG_BOARD_HAS_LSE 1
24#endif
25
26/* This board provides an HSE */
27#ifndef CONFIG_BOARD_HAS_HSE
28#define CONFIG_BOARD_HAS_HSE 1
29#endif
30
31#include "periph_cpu.h"
32#include "clk_conf.h"
33#include "cfg_i2c1_pb8_pb9.h"
34#include "cfg_timer_tim5.h"
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
44static const dma_conf_t dma_config[] = {
45 { .stream = 11 }, /* DMA2 Stream 3 - SPI1_TX */
46 { .stream = 10 }, /* DMA2 Stream 2 - SPI1_RX */
47 { .stream = 4 }, /* DMA1 Stream 4 - SPI2_TX */
48 { .stream = 3 }, /* DMA1 Stream 3 - SPI2_RX */
49 { .stream = 5 }, /* DMA1 Stream 5 - SPI3_TX */
50 { .stream = 0 }, /* DMA1 Stream 0 - SPI3_RX */
51};
52
53#define DMA_0_ISR isr_dma2_stream3
54#define DMA_1_ISR isr_dma2_stream2
55#define DMA_2_ISR isr_dma1_stream4
56#define DMA_3_ISR isr_dma1_stream3
57#define DMA_4_ISR isr_dma1_stream5
58#define DMA_5_ISR isr_dma1_stream0
59
60#define DMA_NUMOF ARRAY_SIZE(dma_config)
62
67static const uart_conf_t uart_config[] = {
68 {
69 .dev = USART2,
70 .rcc_mask = RCC_APB1ENR_USART2EN,
71 .rx_pin = GPIO_PIN(PORT_A, 3),
72 .tx_pin = GPIO_PIN(PORT_A, 2),
73 .rx_af = GPIO_AF7,
74 .tx_af = GPIO_AF7,
75 .bus = APB1,
76 .irqn = USART2_IRQn,
77#ifdef MODULE_PERIPH_DMA
78 .dma = DMA_STREAM_UNDEF,
79 .dma_chan = UINT8_MAX,
80#endif
81 },
82 {
83 .dev = USART1,
84 .rcc_mask = RCC_APB2ENR_USART1EN,
85 .rx_pin = GPIO_PIN(PORT_A, 10),
86 .tx_pin = GPIO_PIN(PORT_A, 9),
87 .rx_af = GPIO_AF7,
88 .tx_af = GPIO_AF7,
89 .bus = APB2,
90 .irqn = USART1_IRQn,
91#ifdef MODULE_PERIPH_DMA
92 .dma = DMA_STREAM_UNDEF,
93 .dma_chan = UINT8_MAX,
94#endif
95 },
96 {
97 .dev = USART6,
98 .rcc_mask = RCC_APB2ENR_USART6EN,
99 .rx_pin = GPIO_PIN(PORT_A, 12),
100 .tx_pin = GPIO_PIN(PORT_A, 11),
101 .rx_af = GPIO_AF8,
102 .tx_af = GPIO_AF8,
103 .bus = APB2,
104 .irqn = USART6_IRQn,
105#ifdef MODULE_PERIPH_DMA
106 .dma = DMA_STREAM_UNDEF,
107 .dma_chan = UINT8_MAX,
108#endif
109 }
110};
111
112#define UART_0_ISR (isr_usart2)
113#define UART_1_ISR (isr_usart1)
114#define UART_2_ISR (isr_usart6)
115
116#define UART_NUMOF ARRAY_SIZE(uart_config)
118
123static const pwm_conf_t pwm_config[] = {
124 {
125 .dev = TIM2,
126 .rcc_mask = RCC_APB1ENR_TIM2EN,
127 .chan = { { .pin = GPIO_PIN(PORT_A, 15) , .cc_chan = 0 },
128 { .pin = GPIO_PIN(PORT_B, 3) /* D3 */, .cc_chan = 1 },
129 { .pin = GPIO_PIN(PORT_B, 10) /* D6 */, .cc_chan = 2 },
130 { .pin = GPIO_UNDEF, .cc_chan = 0 } },
131 .af = GPIO_AF1,
132 .bus = APB1
133 },
134};
135
136#define PWM_NUMOF ARRAY_SIZE(pwm_config)
138
143static const qdec_conf_t qdec_config[] = {
144 {
145 .dev = TIM3,
146 .max = 0xffffffff,
147 .rcc_mask = RCC_APB1ENR_TIM3EN,
148 .chan = { { .pin = GPIO_PIN(PORT_A, 6), .cc_chan = 0 },
149 { .pin = GPIO_PIN(PORT_A, 7), .cc_chan = 1 } },
150 .af = GPIO_AF2,
151 .bus = APB1,
152 .irqn = TIM3_IRQn
153 },
154 {
155 .dev = TIM4,
156 .max = 0xffffffff,
157 .rcc_mask = RCC_APB1ENR_TIM4EN,
158 .chan = { { .pin = GPIO_PIN(PORT_B, 6), .cc_chan = 0 },
159 { .pin = GPIO_PIN(PORT_B, 7), .cc_chan = 1 } },
160 .af = GPIO_AF2,
161 .bus = APB1,
162 .irqn = TIM4_IRQn
163 },
164};
165
166#define QDEC_0_ISR isr_tim3
167#define QDEC_1_ISR isr_tim4
168
169#define QDEC_NUMOF ARRAY_SIZE(qdec_config)
171
176static const spi_conf_t spi_config[] = {
177 {
178 .dev = SPI1,
179 .mosi_pin = GPIO_PIN(PORT_A, 7),
180 .miso_pin = GPIO_PIN(PORT_A, 6),
181 .sclk_pin = GPIO_PIN(PORT_A, 5),
182 .cs_pin = GPIO_PIN(PORT_A, 4),
183 .mosi_af = GPIO_AF5,
184 .miso_af = GPIO_AF5,
185 .sclk_af = GPIO_AF5,
186 .cs_af = GPIO_AF5,
187 .rccmask = RCC_APB2ENR_SPI1EN,
188 .apbbus = APB2,
189#ifdef MODULE_PERIPH_DMA
190 .tx_dma = 0,
191 .tx_dma_chan = 3,
192 .rx_dma = 1,
193 .rx_dma_chan = 3,
194#endif
195 },
196 {
197 .dev = SPI2,
198 .mosi_pin = GPIO_PIN(PORT_B, 15),
199 .miso_pin = GPIO_PIN(PORT_B, 14),
200 .sclk_pin = GPIO_PIN(PORT_B, 13),
201 .cs_pin = GPIO_PIN(PORT_B, 12),
202 .mosi_af = GPIO_AF5,
203 .miso_af = GPIO_AF5,
204 .sclk_af = GPIO_AF5,
205 .cs_af = GPIO_AF5,
206 .rccmask = RCC_APB1ENR_SPI2EN,
207 .apbbus = APB1,
208#ifdef MODULE_PERIPH_DMA
209 .tx_dma = 2,
210 .tx_dma_chan = 0,
211 .rx_dma = 3,
212 .rx_dma_chan = 0,
213#endif
214 },
215 {
216 .dev = SPI3,
217 .mosi_pin = GPIO_PIN(PORT_C, 12),
218 .miso_pin = GPIO_PIN(PORT_C, 11),
219 .sclk_pin = GPIO_PIN(PORT_C, 10),
220 .cs_pin = GPIO_UNDEF,
221 .mosi_af = GPIO_AF6,
222 .miso_af = GPIO_AF6,
223 .sclk_af = GPIO_AF6,
224 .cs_af = GPIO_AF6,
225 .rccmask = RCC_APB1ENR_SPI3EN,
226 .apbbus = APB1,
227#ifdef MODULE_PERIPH_DMA
228 .tx_dma = 4,
229 .tx_dma_chan = 0,
230 .rx_dma = 5,
231 .rx_dma_chan = 0,
232#endif
233 }
234};
235
236#define SPI_NUMOF ARRAY_SIZE(spi_config)
238
249static const adc_conf_t adc_config[] = {
250 {GPIO_PIN(PORT_A, 0), 0, 0},
251 {GPIO_PIN(PORT_A, 1), 0, 1},
252 {GPIO_PIN(PORT_A, 4), 0, 4},
253 {GPIO_PIN(PORT_B, 0), 0, 8},
254 {GPIO_PIN(PORT_C, 1), 0, 11},
255 {GPIO_PIN(PORT_C, 0), 0, 10},
256 {GPIO_UNDEF, 0, 18}, /* VBAT */
257};
258
259#define VBAT_ADC ADC_LINE(6)
260#define ADC_NUMOF ARRAY_SIZE(adc_config)
262
263#ifdef __cplusplus
264}
265#endif
266
@ PORT_B
port B
Definition periph_cpu.h:47
@ PORT_C
port C
Definition periph_cpu.h:48
@ 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.
Common configuration for STM32 I2C.
Common configuration for STM32 Timer peripheral based on TIM5.
@ GPIO_AF1
use alternate function 1
Definition cpu_gpio.h:102
@ GPIO_AF2
use alternate function 2
Definition cpu_gpio.h:103
@ GPIO_AF5
use alternate function 5
Definition cpu_gpio.h:106
@ GPIO_AF8
use alternate function 8
Definition cpu_gpio.h:110
@ GPIO_AF6
use alternate function 6
Definition cpu_gpio.h:107
@ GPIO_AF7
use alternate function 7
Definition cpu_gpio.h:108
@ 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
PWM device configuration.
Quadrature decoder configuration struct.
SPI device configuration.
Definition periph_cpu.h:336
UART device configuration.
Definition periph_cpu.h:217