Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 luisan00
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser General
5 * Public License v2.1. See the file LICENSE in the top level directory for more
6 * details.
7 */
8
17#ifndef PERIPH_CONF_H
18#define PERIPH_CONF_H
19
20/* This board provides a LSE, marked as X3 on the board */
21#ifndef CONFIG_BOARD_HAS_LSE
22#define CONFIG_BOARD_HAS_LSE 1
23#endif
24
25/* This board provides a HSE, marked as X2 on the board */
26#ifndef CONFIG_BOARD_HAS_HSE
27#define CONFIG_BOARD_HAS_HSE 1
28#endif
29
30/* The HSE provides a 8MHz clock */
31#ifndef CONFIG_CLOCK_HSE
32#define CONFIG_CLOCK_HSE MHZ(8)
33#endif
34
35#include "periph_cpu.h"
36#include "clk_conf.h"
37#include "cfg_rtt_default.h"
38#include "cfg_timer_tim2.h"
39#include "cfg_usb_otg_fs.h"
40
41#ifdef __cplusplus
42extern "C"
43{
44#endif
45
50static const dma_conf_t dma_config[] = {
51 {.stream = 14}, /* DMA2 Stream 6 - SPI TX */
52 {.stream = 13}, /* DMA2 Stream 5 - SPI RX */
53};
54#define DMA_0_ISR isr_dma2_stream6
55#define DMA_1_ISR isr_dma2_stream5
56#define DMA_NUMOF ARRAY_SIZE(dma_config)
65static const uart_conf_t uart_config[] = {
66 {
67 .dev = USART3,
68 .rcc_mask = RCC_APB1ENR_USART3EN,
69 .rx_pin = GPIO_PIN(PORT_B, 11),
70 .tx_pin = GPIO_PIN(PORT_B, 10),
71 .rx_af = GPIO_AF7,
72 .tx_af = GPIO_AF7,
73 .bus = APB1,
74 .irqn = USART3_IRQn,
75#ifdef MODULE_PERIPH_DMA
76 .dma = DMA_STREAM_UNDEF,
77 .dma_chan = UINT8_MAX
78#endif
79 },
80 {
81 .dev = USART6,
82 .rcc_mask = RCC_APB2ENR_USART6EN,
83 .rx_pin = GPIO_PIN(PORT_C, 7),
84 .tx_pin = GPIO_PIN(PORT_C, 6),
85 .rx_af = GPIO_AF8,
86 .tx_af = GPIO_AF8,
87 .bus = APB2,
88 .irqn = USART6_IRQn,
89#ifdef MODULE_PERIPH_DMA
90 .dma = DMA_STREAM_UNDEF,
91 .dma_chan = UINT8_MAX
92#endif
93 },
94};
95#define UART_0_ISR (isr_usart3)
96#define UART_1_ISR (isr_usart6)
97#define UART_NUMOF ARRAY_SIZE(uart_config)
112static const i2c_conf_t i2c_config[] = {
113 {
114 .dev = I2C1,
115 .speed = I2C_SPEED_NORMAL,
116 .scl_pin = GPIO_PIN(PORT_B, 8),
117 .sda_pin = GPIO_PIN(PORT_B, 9),
118 .scl_af = GPIO_AF4,
119 .sda_af = GPIO_AF4,
120 .bus = APB1,
121 .rcc_mask = RCC_APB1ENR_I2C1EN,
122 .clk = CLOCK_APB1,
123 .irqn = I2C1_EV_IRQn,
124 },
125 {
126 .dev = I2C2,
127 .speed = I2C_SPEED_NORMAL,
128 .scl_pin = GPIO_PIN(PORT_H, 4),
129 .sda_pin = GPIO_PIN(PORT_H, 5),
130 .scl_af = GPIO_AF4,
131 .sda_af = GPIO_AF4,
132 .bus = APB1,
133 .rcc_mask = RCC_APB1ENR_I2C2EN,
134 .clk = CLOCK_APB1,
135 .irqn = I2C2_EV_IRQn,
136 },
137};
138#define I2C_0_ISR isr_i2c1_ev
139#define I2C_1_ISR isr_i2c2_ev
140#define I2C_NUMOF ARRAY_SIZE(i2c_config)
147static const spi_conf_t spi_config[] = {
148 {
149 .dev = SPI2,
150 .mosi_pin = GPIO_PIN(PORT_B, 15),
151 .miso_pin = GPIO_PIN(PORT_B, 14),
152 .sclk_pin = GPIO_PIN(PORT_D, 3),
153 .cs_pin = GPIO_PIN(PORT_H, 6),
154 .mosi_af = GPIO_AF5,
155 .miso_af = GPIO_AF5,
156 .sclk_af = GPIO_AF5,
157 .cs_af = GPIO_AF5,
158 .rccmask = RCC_APB1ENR_I2C2EN,
159 .apbbus = APB1,
160#ifdef MODULE_PERIPH_DMA
161 .tx_dma = 0,
162 .tx_dma_chan = 6,
163 .rx_dma = 1,
164 .rx_dma_chan = 6,
165#endif
166 },
167};
168#define SPI_NUMOF ARRAY_SIZE(spi_config)
175static const pwm_conf_t pwm_config[] = {
176 {
177 .dev = TIM3,
178 .rcc_mask = RCC_APB1ENR_TIM3EN,
179 .chan = {
180 {.pin = GPIO_PIN(PORT_A, 6), .cc_chan = 0}, /* D6 */
181 {.pin = GPIO_PIN(PORT_B, 5), .cc_chan = 1}, /* CN12-P9 */
182 {.pin = GPIO_UNDEF, .cc_chan = 0}, /* unused */
183 {.pin = GPIO_UNDEF, .cc_chan = 0}, /* unused */
184 },
185 .af = GPIO_AF2,
186 .bus = APB1,
187 },
188 {
189 .dev = TIM5,
190 .rcc_mask = RCC_APB1ENR_TIM5EN,
191 .chan = {
192 {.pin = GPIO_PIN(PORT_A, 1), .cc_chan = 1}, /* D5 */
193 {.pin = GPIO_PIN(PORT_A, 2), .cc_chan = 2}, /* D3 */
194 {.pin = GPIO_UNDEF, .cc_chan = 0}, /* unused */
195 {.pin = GPIO_UNDEF, .cc_chan = 0}, /* unused */
196 },
197 .af = GPIO_AF2,
198 .bus = APB1,
199 },
200 {
201 .dev = TIM12,
202 .rcc_mask = RCC_APB1ENR_TIM12EN,
203 .chan = {
204 {.pin = GPIO_PIN(PORT_H, 6), .cc_chan = 0}, /* D10 */
205 {.pin = GPIO_PIN(PORT_B, 15), .cc_chan = 1}, /* D11 */
206 {.pin = GPIO_UNDEF, .cc_chan = 0}, /* unused */
207 {.pin = GPIO_UNDEF, .cc_chan = 0}, /* unused */
208 },
209 .af = GPIO_AF9,
210 .bus = APB1,
211 },
212 {
213 .dev = TIM14,
214 .rcc_mask = RCC_APB1ENR_TIM14EN,
215 .chan = {
216 {.pin = GPIO_PIN(PORT_A, 7), .cc_chan = 0}, /* D9 */
217 {.pin = GPIO_UNDEF, .cc_chan = 0}, /* unused */
218 {.pin = GPIO_UNDEF, .cc_chan = 0}, /* unused */
219 {.pin = GPIO_UNDEF, .cc_chan = 0}, /* unused */
220 },
221 .af = GPIO_AF9,
222 .bus = APB1,
223 },
224};
225#define PWM_NUMOF ARRAY_SIZE(pwm_config)
235static const adc_conf_t adc_config[] = {
236 {GPIO_PIN(PORT_B, 1), 2, 9},
237 {GPIO_PIN(PORT_C, 2), 2, 12},
238 {GPIO_PIN(PORT_C, 3), 2, 13},
239 {GPIO_PIN(PORT_C, 4), 2, 14},
240 {GPIO_PIN(PORT_C, 5), 2, 15},
241 {GPIO_PIN(PORT_A, 4), 2, 4},
242 {GPIO_UNDEF, 0, 18}, /* VBAT */
243};
244
245#define VBAT_ADC ADC_LINE(6)
246#define ADC_NUMOF ARRAY_SIZE(adc_config)
253static const dac_conf_t dac_config[] = {
254 {GPIO_PIN(PORT_A, 4), .chan = 0},
255 {GPIO_PIN(PORT_A, 5), .chan = 1},
256};
263#define DAC_NUMOF ARRAY_SIZE(dac_config)
273static const fmc_conf_t fmc_config = {
274 .bus = AHB3,
275 .rcc_mask = RCC_AHB3ENR_FMCEN,
276#if MODULE_PERIPH_FMC_SDRAM
277 .ba0_pin = { .pin = GPIO_PIN(PORT_G, 4), .af = GPIO_AF12, }, /* A14 signal */
278 .ba1_pin = { .pin = GPIO_PIN(PORT_G, 5), .af = GPIO_AF12, }, /* A15 signal */
279 .sdclk_pin = { .pin = GPIO_PIN(PORT_G, 8), .af = GPIO_AF12, }, /* SDCLK signal */
280 .sdnwe_pin = { .pin = GPIO_PIN(PORT_C, 0), .af = GPIO_AF12, }, /* SDNWE signal */
281 .sdnras_pin = { .pin = GPIO_PIN(PORT_F, 11), .af = GPIO_AF12, }, /* SDNRAS signal */
282 .sdncas_pin = { .pin = GPIO_PIN(PORT_G, 15), .af = GPIO_AF12, }, /* SDNCAS signal */
283 .sdcke0_pin = { .pin = GPIO_PIN(PORT_H, 2), .af = GPIO_AF12, }, /* SDCKE0 signal */
284 .sdne0_pin = { .pin = GPIO_PIN(PORT_H, 3), .af = GPIO_AF12, }, /* SDNE0 signal */
285 .addr = {
286 { .pin = GPIO_PIN(PORT_F, 0), .af = GPIO_AF12, }, /* A0 signal */
287 { .pin = GPIO_PIN(PORT_F, 1), .af = GPIO_AF12, }, /* A1 signal */
288 { .pin = GPIO_PIN(PORT_F, 2), .af = GPIO_AF12, }, /* A2 signal */
289 { .pin = GPIO_PIN(PORT_F, 3), .af = GPIO_AF12, }, /* A3 signal */
290 { .pin = GPIO_PIN(PORT_F, 4), .af = GPIO_AF12, }, /* A4 signal */
291 { .pin = GPIO_PIN(PORT_F, 5), .af = GPIO_AF12, }, /* A5 signal */
292 { .pin = GPIO_PIN(PORT_F, 12), .af = GPIO_AF12, }, /* A6 signal */
293 { .pin = GPIO_PIN(PORT_F, 13), .af = GPIO_AF12, }, /* A7 signal */
294 { .pin = GPIO_PIN(PORT_F, 14), .af = GPIO_AF12, }, /* A8 signal */
295 { .pin = GPIO_PIN(PORT_F, 15), .af = GPIO_AF12, }, /* A9 signal */
296 { .pin = GPIO_PIN(PORT_G, 0), .af = GPIO_AF12, }, /* A10 signal */
297 { .pin = GPIO_PIN(PORT_G, 1), .af = GPIO_AF12, }, /* A11 signal */
298 },
299#endif
300 .data = {
301 { .pin = GPIO_PIN(PORT_D, 14), .af = GPIO_AF12, }, /* D0 signal */
302 { .pin = GPIO_PIN(PORT_D, 15), .af = GPIO_AF12, }, /* D1 signal */
303 { .pin = GPIO_PIN(PORT_D, 0), .af = GPIO_AF12, }, /* D2 signal */
304 { .pin = GPIO_PIN(PORT_D, 1), .af = GPIO_AF12, }, /* D3 signal */
305 { .pin = GPIO_PIN(PORT_E, 7), .af = GPIO_AF12, }, /* D4 signal */
306 { .pin = GPIO_PIN(PORT_E, 8), .af = GPIO_AF12, }, /* D5 signal */
307 { .pin = GPIO_PIN(PORT_E, 9), .af = GPIO_AF12, }, /* D6 signal */
308 { .pin = GPIO_PIN(PORT_E, 10), .af = GPIO_AF12, }, /* D7 signal */
309#if MODULE_PERIPH_FMC_32BIT
310 { .pin = GPIO_PIN(PORT_E, 11), .af = GPIO_AF12, }, /* D8 signal */
311 { .pin = GPIO_PIN(PORT_E, 12), .af = GPIO_AF12, }, /* D9 signal */
312 { .pin = GPIO_PIN(PORT_E, 13), .af = GPIO_AF12, }, /* D10 signal */
313 { .pin = GPIO_PIN(PORT_E, 14), .af = GPIO_AF12, }, /* D11 signal */
314 { .pin = GPIO_PIN(PORT_E, 15), .af = GPIO_AF12, }, /* D12 signal */
315 { .pin = GPIO_PIN(PORT_D, 8), .af = GPIO_AF12, }, /* D13 signal */
316 { .pin = GPIO_PIN(PORT_D, 9), .af = GPIO_AF12, }, /* D14 signal */
317 { .pin = GPIO_PIN(PORT_D, 10), .af = GPIO_AF12, }, /* D15 signal */
318 { .pin = GPIO_PIN(PORT_H, 8), .af = GPIO_AF12, }, /* D16 signal */
319 { .pin = GPIO_PIN(PORT_H, 9), .af = GPIO_AF12, }, /* D17 signal */
320 { .pin = GPIO_PIN(PORT_H, 10), .af = GPIO_AF12, }, /* D18 signal */
321 { .pin = GPIO_PIN(PORT_H, 11), .af = GPIO_AF12, }, /* D19 signal */
322 { .pin = GPIO_PIN(PORT_H, 12), .af = GPIO_AF12, }, /* D20 signal */
323 { .pin = GPIO_PIN(PORT_H, 13), .af = GPIO_AF12, }, /* D21 signal */
324 { .pin = GPIO_PIN(PORT_H, 14), .af = GPIO_AF12, }, /* D22 signal */
325 { .pin = GPIO_PIN(PORT_H, 15), .af = GPIO_AF12, }, /* D23 signal */
326 { .pin = GPIO_PIN(PORT_I, 0), .af = GPIO_AF12, }, /* D24 signal */
327 { .pin = GPIO_PIN(PORT_I, 1), .af = GPIO_AF12, }, /* D25 signal */
328 { .pin = GPIO_PIN(PORT_I, 2), .af = GPIO_AF12, }, /* D26 signal */
329 { .pin = GPIO_PIN(PORT_I, 3), .af = GPIO_AF12, }, /* D27 signal */
330 { .pin = GPIO_PIN(PORT_I, 6), .af = GPIO_AF12, }, /* D28 signal */
331 { .pin = GPIO_PIN(PORT_I, 7), .af = GPIO_AF12, }, /* D29 signal */
332 { .pin = GPIO_PIN(PORT_I, 9), .af = GPIO_AF12, }, /* D30 signal */
333 { .pin = GPIO_PIN(PORT_I, 10), .af = GPIO_AF12, }, /* D31 signal */
334#endif
335 },
336 .nbl0_pin = { .pin = GPIO_PIN(PORT_E, 0), .af = GPIO_AF12, }, /* FMC_NBL0 signal (DQM0) */
337 .nbl1_pin = { .pin = GPIO_PIN(PORT_E, 1), .af = GPIO_AF12, }, /* FMC_NBL1 signal (DQM1) */
338 .nbl2_pin = { .pin = GPIO_PIN(PORT_I, 4), .af = GPIO_AF12, }, /* FMC_NBL2 signal (DQM2) */
339 .nbl3_pin = { .pin = GPIO_PIN(PORT_I, 5), .af = GPIO_AF12, }, /* FMC_NBL3 signal (DQM3) */
340};
341
350 /* bank 5 is used for SDRAM */
351 {
352 .bank = FMC_BANK_5,
353 .mem_type = FMC_SDRAM,
354 .data_width = FMC_BUS_WIDTH_32BIT,
355 .address = 0xc0000000, /* Bank 6 is mapped to 0xc0000000 */
356 .size = MiB(16), /* Size in MByte, 4M x 32 Bit */
357 .sdram = {
358 .clk_period = 2, /* SDCLK = 2 x HCLK */
359 .row_bits = 12, /* A11..A0 used for row address */
360 .col_bits = 8, /* A7..A0 used for column address */
361 .cas_latency = 2, /* CAS latency is 2 clock cycles */
362 .read_delay = 0, /* No read delay after CAS */
363 .burst_read = true, /* Burst read mode enabled */
364 .burst_write = false, /* Burst write mode disabled */
365 .burst_len = FMC_BURST_LENGTH_1, /* Burst length is 1 */
366 .burst_interleaved = false, /* Burst mode interleaved */
367 .write_protect = false, /* No write protection */
368 .four_banks = true, /* SDRAM has four internal banks */
369 .timing = { /* SDRAM Timing parameters */
370 .row_to_col_delay = 2, /* Row to column delay (2 clock cycles) */
371 .row_precharge = 2, /* Row precharge delay (2 clock cycles) */
372 .recovery_delay = 2, /* Recovery delay is (2 clock cycles) */
373 .row_cylce = 7, /* Row cycle delay is (7 clock cycles) */
374 .self_refresh = 4, /* Self refresh time is (4 clock cycles) */
375 .exit_self_refresh = 7, /* Exit self-refresh delay (7 clock cycles) */
376 .load_mode_register = 2, /* Load Mode Register to Activate delay */
377 .refresh_period = 16, /* Refresh period in ms */
378 },
379 },
380 },
381};
382
386#define FMC_BANK_NUMOF ARRAY_SIZE(fmc_bank_config)
389#ifdef __cplusplus
390}
391#endif
392
393#endif /* PERIPH_CONF_H */
@ PORT_B
port B
Definition periph_cpu.h:48
@ PORT_G
port G
Definition periph_cpu.h:53
@ PORT_C
port C
Definition periph_cpu.h:49
@ PORT_F
port F
Definition periph_cpu.h:52
@ 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
@ PORT_H
port H
Definition periph_cpu.h:52
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:278
static const fmc_bank_conf_t fmc_bank_config[]
FMC Bank configuration.
static const fmc_conf_t fmc_config
FMC controller configuration.
static const dac_conf_t dac_config[]
DAC configuration.
Common configuration for STM32 Timer peripheral based on TIM2.
Common configuration for STM32 OTG FS peripheral.
@ 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_AF8
use alternate function 8
Definition cpu_gpio.h:111
@ GPIO_AF9
use alternate function 9
Definition cpu_gpio.h:112
@ GPIO_AF12
use alternate function 12
Definition cpu_gpio.h:115
@ 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
@ FMC_SDRAM
SDRAM Controller used.
Definition cpu_fmc.h:345
@ FMC_BUS_WIDTH_32BIT
32 bit data bus width
Definition cpu_fmc.h:354
ADC device configuration.
Definition periph_cpu.h:379
DAC line configuration data.
Definition periph_cpu.h:301
uint8_t chan
DAC device used for this line.
Definition periph_cpu.h:303
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
Bank configuration structure.
Definition cpu_fmc.h:360
fmc_bank_t bank
Bank1 .
Definition cpu_fmc.h:361
FMC peripheral configuration.
Definition cpu_fmc.h:278
uint8_t bus
AHB/APB bus.
Definition cpu_fmc.h:279
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
UART device configuration.
Definition periph_cpu.h:218
USART_t * dev
pointer to the used UART device
Definition periph_cpu.h:219
#define MiB(x)
A macro to return the bytes in x MiB.
Definition units.h:34