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