Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014 Freie Universität Berlin
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
20#ifndef PERIPH_CONF_H
21#define PERIPH_CONF_H
22
23/* This board provides an HSE */
24#ifndef CONFIG_BOARD_HAS_HSE
25#define CONFIG_BOARD_HAS_HSE 1
26#endif
27
28#include "periph_cpu.h"
29#include "clk_conf.h"
30#include "cfg_usb_otg_fs.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
40static const dma_conf_t dma_config[] = {
41 { .stream = 11 }, /* DMA2 Stream 3 - SPI1_TX */
42 { .stream = 10 }, /* DMA2 Stream 2 - SPI1_RX */
43 { .stream = 4 }, /* DMA1 Stream 4 - SPI2_TX */
44 { .stream = 3 }, /* DMA1 Stream 3 - SPI2_RX */
45};
46
47#define DMA_0_ISR isr_dma2_stream3
48#define DMA_1_ISR isr_dma2_stream2
49#define DMA_2_ISR isr_dma1_stream4
50#define DMA_3_ISR isr_dma1_stream3
51
52#define DMA_NUMOF ARRAY_SIZE(dma_config)
59static const timer_conf_t timer_config[] = {
60 {
61 .dev = TIM2,
62 .max = 0xffffffff,
63 .rcc_mask = RCC_APB1ENR_TIM2EN,
64 .bus = APB1,
65 .irqn = TIM2_IRQn
66 },
67 {
68 .dev = TIM5,
69 .max = 0xffffffff,
70 .rcc_mask = RCC_APB1ENR_TIM5EN,
71 .bus = APB1,
72 .irqn = TIM5_IRQn
73 }
74};
75
76#define TIMER_0_ISR isr_tim2
77#define TIMER_1_ISR isr_tim5
78
79#define TIMER_NUMOF ARRAY_SIZE(timer_config)
86static const uart_conf_t uart_config[] = {
87 {
88 .dev = USART2,
89 .rcc_mask = RCC_APB1ENR_USART2EN,
90 .rx_pin = GPIO_PIN(PORT_A, 3),
91 .tx_pin = GPIO_PIN(PORT_A, 2),
92 .rx_af = GPIO_AF7,
93 .tx_af = GPIO_AF7,
94 .bus = APB1,
95 .irqn = USART2_IRQn,
96#ifdef MODULE_PERIPH_DMA
97 .dma = DMA_STREAM_UNDEF,
98 .dma_chan = UINT8_MAX,
99#endif
100 },
101 {
102 .dev = USART3,
103 .rcc_mask = RCC_APB1ENR_USART3EN,
104 .rx_pin = GPIO_PIN(PORT_D, 9),
105 .tx_pin = GPIO_PIN(PORT_D, 8),
106 .rx_af = GPIO_AF7,
107 .tx_af = GPIO_AF7,
108 .bus = APB1,
109 .irqn = USART3_IRQn,
110#ifdef MODULE_PERIPH_DMA
111 .dma = DMA_STREAM_UNDEF,
112 .dma_chan = UINT8_MAX,
113#endif
114 }
115};
116
117#define UART_0_ISR (isr_usart2)
118#define UART_1_ISR (isr_usart3)
119
120#define UART_NUMOF ARRAY_SIZE(uart_config)
130static const adc_conf_t adc_config[] = {
131 {GPIO_PIN(PORT_A, 1), 0, 1},
132 {GPIO_PIN(PORT_A, 4), 0, 4},
133 {GPIO_PIN(PORT_C, 1), 1, 11},
134 {GPIO_PIN(PORT_C, 2), 1, 12},
135 {GPIO_UNDEF, 0, 18}, /* VBAT */
136};
137
138#define VBAT_ADC ADC_LINE(4)
139#define ADC_NUMOF ARRAY_SIZE(adc_config)
146static const dac_conf_t dac_config[] = {
147 { .pin = GPIO_PIN(PORT_A, 4), .chan = 0 },
148 { .pin = GPIO_PIN(PORT_A, 5), .chan = 1 }
149};
150
151#define DAC_NUMOF ARRAY_SIZE(dac_config)
158static const pwm_conf_t pwm_config[] = {
159 {
160 .dev = TIM1,
161 .rcc_mask = RCC_APB2ENR_TIM1EN,
162 .chan = { { .pin = GPIO_PIN(PORT_E, 9), .cc_chan = 0 },
163 { .pin = GPIO_PIN(PORT_E, 11), .cc_chan = 1 },
164 { .pin = GPIO_PIN(PORT_E, 11), .cc_chan = 2 },
165 { .pin = GPIO_PIN(PORT_E, 14), .cc_chan = 3 } },
166 .af = GPIO_AF1,
167 .bus = APB2
168 },
169 {
170 .dev = TIM3,
171 .rcc_mask = RCC_APB1ENR_TIM3EN,
172 .chan = { { .pin = GPIO_PIN(PORT_B, 4), .cc_chan = 0 },
173 { .pin = GPIO_PIN(PORT_B, 5), .cc_chan = 1 },
174 { .pin = GPIO_PIN(PORT_B, 0), .cc_chan = 2 },
175 { .pin = GPIO_PIN(PORT_B, 1), .cc_chan = 3 } },
176 .af = GPIO_AF2,
177 .bus = APB1
178 }
179};
180
181#define PWM_NUMOF ARRAY_SIZE(pwm_config)
188static const spi_conf_t spi_config[] = {
189 {
190 .dev = SPI1,
191 .mosi_pin = GPIO_PIN(PORT_A, 7),
192 .miso_pin = GPIO_PIN(PORT_A, 6),
193 .sclk_pin = GPIO_PIN(PORT_A, 5),
194 .cs_pin = GPIO_PIN(PORT_A, 4),
195 .mosi_af = GPIO_AF5,
196 .miso_af = GPIO_AF5,
197 .sclk_af = GPIO_AF5,
198 .cs_af = GPIO_AF5,
199 .rccmask = RCC_APB2ENR_SPI1EN,
200 .apbbus = APB2,
201#ifdef MODULE_PERIPH_DMA
202 .tx_dma = 0,
203 .tx_dma_chan = 3,
204 .rx_dma = 1,
205 .rx_dma_chan = 3,
206#endif
207 },
208 {
209 .dev = SPI2,
210 .mosi_pin = GPIO_PIN(PORT_B, 15),
211 .miso_pin = GPIO_PIN(PORT_B, 14),
212 .sclk_pin = GPIO_PIN(PORT_B, 13),
213 .cs_pin = GPIO_PIN(PORT_B, 12),
214 .mosi_af = GPIO_AF5,
215 .miso_af = GPIO_AF5,
216 .sclk_af = GPIO_AF5,
217 .cs_af = GPIO_AF5,
218 .rccmask = RCC_APB1ENR_SPI2EN,
219 .apbbus = APB1,
220#ifdef MODULE_PERIPH_DMA
221 .tx_dma = 2,
222 .tx_dma_chan = 0,
223 .rx_dma = 3,
224 .rx_dma_chan = 0,
225#endif
226 },
227};
228
229#define SPI_NUMOF ARRAY_SIZE(spi_config)
236static const i2c_conf_t i2c_config[] = {
237 {
238 .dev = I2C1,
239 .speed = I2C_SPEED_NORMAL,
240 .scl_pin = GPIO_PIN(PORT_B, 6),
241 .sda_pin = GPIO_PIN(PORT_B, 9),
242 .scl_af = GPIO_AF4,
243 .sda_af = GPIO_AF4,
244 .bus = APB1,
245 .rcc_mask = RCC_APB1ENR_I2C1EN,
246 .clk = CLOCK_APB1,
247 .irqn = I2C1_EV_IRQn
248 }
249};
250
251#define I2C_0_ISR isr_i2c1_ev
252
253#define I2C_NUMOF ARRAY_SIZE(i2c_config)
256#ifdef __cplusplus
257}
258#endif
259
260#endif /* PERIPH_CONF_H */
@ PORT_B
port B
Definition periph_cpu.h:48
@ PORT_C
port C
Definition periph_cpu.h:49
@ PORT_E
port E
Definition periph_cpu.h:51
@ PORT_A
port A
Definition periph_cpu.h:47
@ PORT_D
port D
Definition periph_cpu.h:50
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:46
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:278
Common configuration for STM32 OTG FS peripheral.
@ GPIO_AF1
use alternate function 1
Definition cpu_gpio.h:103
@ GPIO_AF2
use alternate function 2
Definition cpu_gpio.h:104
@ GPIO_AF5
use alternate function 5
Definition cpu_gpio.h:107
@ GPIO_AF4
use alternate function 4
Definition cpu_gpio.h:106
@ GPIO_AF7
use alternate function 7
Definition cpu_gpio.h:109
@ APB1
Advanced Peripheral Bus 1
Definition periph_cpu.h:79
@ APB2
Advanced Peripheral Bus 2
Definition periph_cpu.h:80
ADC device configuration.
Definition periph_cpu.h:379
DAC line configuration data.
Definition periph_cpu.h:301
gpio_t pin
pin connected to the line
Definition periph_cpu.h:302
DMA configuration.
Definition cpu_dma.h:32
int stream
DMA stream on stm32f2/4/7, channel on others STM32F2/4/7:
Definition cpu_dma.h:55
I2C configuration structure.
Definition periph_cpu.h:299
TWI_t * dev
Pointer to hardware module registers.
Definition periph_cpu.h:300
PWM device configuration.
mini_timer_t * dev
Timer used.
SPI device configuration.
Definition periph_cpu.h:337
SPI_t * dev
pointer to the used SPI device
Definition periph_cpu.h:338
Timer device configuration.
Definition periph_cpu.h:264
TC0_t * dev
Pointer to the used as Timer device.
Definition periph_cpu.h:265
UART device configuration.
Definition periph_cpu.h:218
USART_t * dev
pointer to the used UART device
Definition periph_cpu.h:219