Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021 Inria
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18/* This board provides an LSE */
19#ifndef CONFIG_BOARD_HAS_LSE
20#define CONFIG_BOARD_HAS_LSE 1
21#endif
22
23/* This board provides an HSE */
24#ifndef CONFIG_BOARD_HAS_HSE
25#define CONFIG_BOARD_HAS_HSE 1
26#endif
27
28/* The HSE provides a 25MHz clock */
29#ifndef CONFIG_CLOCK_HSE
30#define CONFIG_CLOCK_HSE MHZ(25)
31#endif
32
33#include <stdint.h>
34
35#include "periph_cpu.h"
36#include "clk_conf.h"
37#include "cfg_rtt_default.h"
38#include "cfg_timer_tim2.h"
39#if defined(MODULE_PERIPH_USBDEV_HS_ULPI)
41#else
42#include "cfg_usb_otg_fs.h"
43#endif
44#include "mii.h"
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
54static const dma_conf_t dma_config[] = {
55 { .stream = 15 }, /* DMA2 Stream 7 - USART1_TX */
56 { .stream = 14 }, /* DMA2 Stream 6 - USART6_TX */
57 { .stream = 6 }, /* DMA1 Stream 6 - USART2_TX */
58 { .stream = 3 }, /* DMA1 Stream 3 - SPI2_RX */
59 { .stream = 4 }, /* DMA1 Stream 4 - SPI2_TX */
60 { .stream = 11 }, /* DMA2 Stream 3 - SPI4_RX Ch5 / SDMMC1 Ch 4 */
61 { .stream = 12 }, /* DMA2 Stream 4 - SPI4_TX */
62 { .stream = 8 }, /* DMA2 Stream 0 - ETH_TX */
63};
64
65#define DMA_0_ISR isr_dma2_stream7
66#define DMA_1_ISR isr_dma2_stream6
67#define DMA_2_ISR isr_dma1_stream6
68
69#define DMA_3_ISR isr_dma2_stream2
70#define DMA_4_ISR isr_dma2_stream5
71#define DMA_5_ISR isr_dma2_stream3
72#define DMA_6_ISR isr_dma2_stream4
73
74#define DMA_7_ISR isr_dma2_stream0
75
76#define DMA_NUMOF ARRAY_SIZE(dma_config)
78
83static const uart_conf_t uart_config[] = {
84 {
85 .dev = USART1,
86 .rcc_mask = RCC_APB2ENR_USART1EN,
87 .rx_pin = GPIO_PIN(PORT_B, 7),
88 .tx_pin = GPIO_PIN(PORT_A, 9),
89 .rx_af = GPIO_AF7,
90 .tx_af = GPIO_AF7,
91 .bus = APB2,
92 .irqn = USART1_IRQn,
93#ifdef MODULE_PERIPH_DMA
94 .dma = 0,
95 .dma_chan = 4
96#endif
97 },
98 { /* Arduino connectors */
99 .dev = USART6,
100 .rcc_mask = RCC_APB2ENR_USART6EN,
101 .rx_pin = GPIO_PIN(PORT_C, 6),
102 .tx_pin = GPIO_PIN(PORT_C, 7),
103 .rx_af = GPIO_AF7,
104 .tx_af = GPIO_AF7,
105 .bus = APB2,
106 .irqn = USART6_IRQn,
107#ifdef MODULE_PERIPH_DMA
108 .dma = 1,
109 .dma_chan = 5
110#endif
111 },
112};
113
114#define UART_0_ISR (isr_usart1)
115#define UART_0_DMA_ISR (isr_dma2_stream7)
116#define UART_6_ISR (isr_usart6)
117#define UART_6_DMA_ISR (isr_dma2_stream6)
118
119#define UART_NUMOF ARRAY_SIZE(uart_config)
121
126static const spi_conf_t spi_config[] = {
127 {
128 .dev = SPI2,
129 .mosi_pin = GPIO_PIN(PORT_B, 15),
130 .miso_pin = GPIO_PIN(PORT_B, 14),
131 .sclk_pin = GPIO_PIN(PORT_I, 1),
132 .cs_pin = SPI_CS_UNDEF,
133 .mosi_af = GPIO_AF5,
134 .miso_af = GPIO_AF5,
135 .sclk_af = GPIO_AF5,
136 .cs_af = GPIO_AF5,
137 .rccmask = RCC_APB1ENR_SPI2EN,
138 .apbbus = APB1,
139#ifdef MODULE_PERIPH_DMA
140 .tx_dma = 4,
141 .tx_dma_chan = 0,
142 .rx_dma = 3,
143 .rx_dma_chan = 0,
144#endif
145 },
146};
147
148#define SPI_NUMOF ARRAY_SIZE(spi_config)
150
155static const i2c_conf_t i2c_config[] = {
156 {
157 .dev = I2C1,
158 .speed = I2C_SPEED_NORMAL,
159 .scl_pin = GPIO_PIN(PORT_B, 8),
160 .sda_pin = GPIO_PIN(PORT_B, 9),
161 .scl_af = GPIO_AF4,
162 .sda_af = GPIO_AF4,
163 .bus = APB1,
164 .rcc_mask = RCC_APB1ENR_I2C1EN,
165 .rcc_sw_mask = RCC_DCKCFGR2_I2C1SEL_1,
166 .irqn = I2C1_ER_IRQn,
167 },
168 {
169 .dev = I2C3,
170 .speed = I2C_SPEED_NORMAL,
171 .scl_pin = GPIO_PIN(PORT_H, 7),
172 .sda_pin = GPIO_PIN(PORT_H, 8),
173 .scl_af = GPIO_AF4,
174 .sda_af = GPIO_AF4,
175 .bus = APB1,
176 .rcc_mask = RCC_APB1ENR_I2C3EN,
177 .rcc_sw_mask = RCC_DCKCFGR2_I2C3SEL_1,
178 .irqn = I2C3_ER_IRQn,
179 },
180};
181
182#define I2C_0_ISR isr_i2c1_er
183#define I2C_1_ISR isr_i2c3_er
184
185#define I2C_NUMOF ARRAY_SIZE(i2c_config)
187
192static const eth_conf_t eth_config = {
193 .mode = RMII,
195 .dma = 7,
196 .dma_chan = 8,
197 .phy_addr = 0x00,
198 .pins = {
199 GPIO_PIN(PORT_G, 13), /* TXD0 */
200 GPIO_PIN(PORT_G, 14), /* TXD1 */
201 GPIO_PIN(PORT_G, 11), /* TX_EN */
202 GPIO_PIN(PORT_C, 4), /* RXD0 */
203 GPIO_PIN(PORT_C, 5), /* RXD1 */
204 GPIO_PIN(PORT_A, 7), /* CRS_DV */
205 GPIO_PIN(PORT_C, 1), /* MDC */
206 GPIO_PIN(PORT_A, 2), /* MDIO */
207 GPIO_PIN(PORT_A, 1), /* REF_CLK */
208 }
209};
210
211#define ETH_DMA_ISR isr_dma2_stream0
213
219static const ltdc_conf_t ltdc_config = {
220 .bus = APB2,
221 .rcc_mask = RCC_APB2ENR_LTDCEN,
222 .clk_pin = { .pin = GPIO_PIN(PORT_I, 14), .af = GPIO_AF14, },
223 .de_pin = { .pin = GPIO_PIN(PORT_K, 7), .af = GPIO_AF14, },
224 .hsync_pin = { .pin = GPIO_PIN(PORT_I, 10), .af = GPIO_AF14, },
225 .vsync_pin = { .pin = GPIO_PIN(PORT_I, 9), .af = GPIO_AF14, },
226 .r_pin = {
227 { .pin = GPIO_PIN(PORT_I, 15), .af = GPIO_AF14, },
228 { .pin = GPIO_PIN(PORT_J, 0), .af = GPIO_AF14, },
229 { .pin = GPIO_PIN(PORT_J, 1), .af = GPIO_AF14, },
230 { .pin = GPIO_PIN(PORT_J, 2), .af = GPIO_AF14, },
231 { .pin = GPIO_PIN(PORT_J, 3), .af = GPIO_AF14, },
232 { .pin = GPIO_PIN(PORT_J, 4), .af = GPIO_AF14, },
233 { .pin = GPIO_PIN(PORT_J, 5), .af = GPIO_AF14, },
234 { .pin = GPIO_PIN(PORT_J, 6), .af = GPIO_AF14, },
235 },
236 .g_pin = {
237 { .pin = GPIO_PIN(PORT_J, 7), .af = GPIO_AF14, },
238 { .pin = GPIO_PIN(PORT_J, 8), .af = GPIO_AF14, },
239 { .pin = GPIO_PIN(PORT_J, 9), .af = GPIO_AF14, },
240 { .pin = GPIO_PIN(PORT_J, 10), .af = GPIO_AF14, },
241 { .pin = GPIO_PIN(PORT_J, 11), .af = GPIO_AF14, },
242 { .pin = GPIO_PIN(PORT_K, 0), .af = GPIO_AF14, },
243 { .pin = GPIO_PIN(PORT_K, 1), .af = GPIO_AF14, },
244 { .pin = GPIO_PIN(PORT_K, 2), .af = GPIO_AF14, },
245 },
246 .b_pin = {
247 { .pin = GPIO_PIN(PORT_E, 4), .af = GPIO_AF14, },
248 { .pin = GPIO_PIN(PORT_J, 13), .af = GPIO_AF14, },
249 { .pin = GPIO_PIN(PORT_J, 14), .af = GPIO_AF14, },
250 { .pin = GPIO_PIN(PORT_J, 15), .af = GPIO_AF14, },
251 { .pin = GPIO_PIN(PORT_G, 12), .af = GPIO_AF9, },
252 { .pin = GPIO_PIN(PORT_K, 4), .af = GPIO_AF14, },
253 { .pin = GPIO_PIN(PORT_K, 5), .af = GPIO_AF14, },
254 { .pin = GPIO_PIN(PORT_K, 6), .af = GPIO_AF14, },
255 },
256 /* values below come from STM32CubeF7 code and differ from the typical
257 * values mentioned in the RK043FN48H datasheet. Both sets of values work
258 * with the display.
259 * See the discussion in
260 * https://community.st.com/s/question/0D50X0000BOvdWP/how-to-set-displays-parameters-
261 */
262 .hsync = 41,
263 .vsync = 10,
264 .hbp = 13,
265 .hfp = 32,
266 .vbp = 2,
267 .vfp = 2,
268};
269
270
271#if defined(MODULE_PERIPH_USBDEV_HS_ULPI) || DOXYGEN
280
284#define DWC2_USB_OTG_HS_ENABLED
285
290 {
291 .periph = USB_OTG_HS_PERIPH_BASE,
292 .type = DWC2_USB_OTG_HS,
294 .rcc_mask = RCC_AHB1ENR_OTGHSEN,
295 .irqn = OTG_HS_IRQn,
296 .ahb = AHB1,
297 .ulpi_af = GPIO_AF10,
298 .ulpi_clk = GPIO_PIN(PORT_A, 5),
299 .ulpi_d0 = GPIO_PIN(PORT_A, 3),
300 .ulpi_d1 = GPIO_PIN(PORT_B, 0),
301 .ulpi_d2 = GPIO_PIN(PORT_B, 1),
302 .ulpi_d3 = GPIO_PIN(PORT_B, 10),
303 .ulpi_d4 = GPIO_PIN(PORT_B, 11),
304 .ulpi_d5 = GPIO_PIN(PORT_B, 12),
305 .ulpi_d6 = GPIO_PIN(PORT_B, 13),
306 .ulpi_d7 = GPIO_PIN(PORT_B, 5),
307 .ulpi_dir = GPIO_PIN(PORT_C, 2),
308 .ulpi_stp = GPIO_PIN(PORT_C, 0),
309 .ulpi_nxt = GPIO_PIN(PORT_H, 4),
310 }
311};
312
316#define USBDEV_NUMOF ARRAY_SIZE(dwc2_usb_otg_fshs_config)
317
319#endif /* defined(MODULE_PERIPH_USBDEV_HS_ULPI) || DOXYGEN */
320
328static const fmc_conf_t fmc_config = {
329 .bus = AHB3,
330 .rcc_mask = RCC_AHB3ENR_FMCEN,
331#if MODULE_PERIPH_FMC_SDRAM
332 .ba0_pin = { .pin = GPIO_PIN(PORT_G, 4), .af = GPIO_AF12, }, /* FMC_BA0 signal */
333 .ba1_pin = { .pin = GPIO_PIN(PORT_G, 5), .af = GPIO_AF12, }, /* FMC_BA1 signal */
334 .sdclk_pin = { .pin = GPIO_PIN(PORT_G, 8), .af = GPIO_AF12, }, /* FMC_SDCLK signal */
335 .sdnwe_pin = { .pin = GPIO_PIN(PORT_H, 5), .af = GPIO_AF12, }, /* FMC_SDNWE signal */
336 .sdnras_pin = { .pin = GPIO_PIN(PORT_F, 11), .af = GPIO_AF12, }, /* FMC_SDNRAS signal */
337 .sdncas_pin = { .pin = GPIO_PIN(PORT_G, 15), .af = GPIO_AF12, }, /* FMC_SDNCAS signal */
338 .sdcke0_pin = { .pin = GPIO_PIN(PORT_C, 3), .af = GPIO_AF12, }, /* FMC_SDCKE0 signal */
339 .sdne0_pin = { .pin = GPIO_PIN(PORT_H, 3), .af = GPIO_AF12, }, /* FMC_SDNE0 signal */
340 .addr = {
341 { .pin = GPIO_PIN(PORT_F, 0), .af = GPIO_AF12, }, /* FMC_A0 signal */
342 { .pin = GPIO_PIN(PORT_F, 1), .af = GPIO_AF12, }, /* FMC_A1 signal */
343 { .pin = GPIO_PIN(PORT_F, 2), .af = GPIO_AF12, }, /* FMC_A2 signal */
344 { .pin = GPIO_PIN(PORT_F, 3), .af = GPIO_AF12, }, /* FMC_A3 signal */
345 { .pin = GPIO_PIN(PORT_F, 4), .af = GPIO_AF12, }, /* FMC_A4 signal */
346 { .pin = GPIO_PIN(PORT_F, 5), .af = GPIO_AF12, }, /* FMC_A5 signal */
347 { .pin = GPIO_PIN(PORT_F, 12), .af = GPIO_AF12, }, /* FMC_A6 signal */
348 { .pin = GPIO_PIN(PORT_F, 13), .af = GPIO_AF12, }, /* FMC_A7 signal */
349 { .pin = GPIO_PIN(PORT_F, 14), .af = GPIO_AF12, }, /* FMC_A8 signal */
350 { .pin = GPIO_PIN(PORT_F, 15), .af = GPIO_AF12, }, /* FMC_A9 signal */
351 { .pin = GPIO_PIN(PORT_G, 0), .af = GPIO_AF12, }, /* FMC_A10 signal */
352 { .pin = GPIO_PIN(PORT_G, 1), .af = GPIO_AF12, }, /* FMC_A11 signal */
353 },
354#endif
355 .data = {
356 { .pin = GPIO_PIN(PORT_D, 14), .af = GPIO_AF12, }, /* FMC_D0 signal */
357 { .pin = GPIO_PIN(PORT_D, 15), .af = GPIO_AF12, }, /* FMC_D1 signal */
358 { .pin = GPIO_PIN(PORT_D, 0), .af = GPIO_AF12, }, /* FMC_D2 signal */
359 { .pin = GPIO_PIN(PORT_D, 1), .af = GPIO_AF12, }, /* FMC_D3 signal */
360 { .pin = GPIO_PIN(PORT_E, 7), .af = GPIO_AF12, }, /* FMC_D4 signal */
361 { .pin = GPIO_PIN(PORT_E, 8), .af = GPIO_AF12, }, /* FMC_D5 signal */
362 { .pin = GPIO_PIN(PORT_E, 9), .af = GPIO_AF12, }, /* FMC_D6 signal */
363 { .pin = GPIO_PIN(PORT_E, 10), .af = GPIO_AF12, }, /* FMC_D7 signal */
364#if MODULE_PERIPH_FMC_16BIT
365 { .pin = GPIO_PIN(PORT_E, 11), .af = GPIO_AF12, }, /* FMC_D8 signal */
366 { .pin = GPIO_PIN(PORT_E, 12), .af = GPIO_AF12, }, /* FMC_D9 signal */
367 { .pin = GPIO_PIN(PORT_E, 13), .af = GPIO_AF12, }, /* FMC_D10 signal */
368 { .pin = GPIO_PIN(PORT_E, 14), .af = GPIO_AF12, }, /* FMC_D11 signal */
369 { .pin = GPIO_PIN(PORT_E, 15), .af = GPIO_AF12, }, /* FMC_D12 signal */
370 { .pin = GPIO_PIN(PORT_D, 8), .af = GPIO_AF12, }, /* FMC_D13 signal */
371 { .pin = GPIO_PIN(PORT_D, 9), .af = GPIO_AF12, }, /* FMC_D14 signal */
372 { .pin = GPIO_PIN(PORT_D, 10), .af = GPIO_AF12, }, /* FMC_D15 signal */
373#endif
374 },
375 .nbl0_pin = { .pin = GPIO_PIN(PORT_E, 0), .af = GPIO_AF12, }, /* FMC_NBL0 signal (LB) */
376 .nbl1_pin = { .pin = GPIO_PIN(PORT_E, 1), .af = GPIO_AF12, }, /* FMC_NBL1 signal (UB) */
377};
378
391 /* bank 5 is used for SDRAM */
392 {
393 .bank = FMC_BANK_5,
394 .mem_type = FMC_SDRAM,
395 .data_width = FMC_BUS_WIDTH_16BIT,
396 .address = 0xc0000000, /* Bank 5 is mapped to 0xc0000000 */
397 .size = MiB(8), /* Size in MByte, 4M x 16 Bit */
398 .sdram = {
399 .clk_period = 2, /* SDCLK = 2 x HCLK */
400 .row_bits = 12, /* A11..A0 used for row address */
401 .col_bits = 8, /* A7..A0 used for column address */
402 .cas_latency = 2, /* CAS latency is 2 clock cycles */
403 .read_delay = 0, /* No read delay after CAS */
404 .burst_read = true, /* Burst read mode enabled */
405 .burst_write = false, /* Burst write mode disabled */
406 .burst_len = FMC_BURST_LENGTH_1, /* Burst length is 1 */
407 .burst_interleaved = false, /* Burst mode interleaved */
408 .write_protect = false, /* No write protection */
409 .four_banks = true, /* SDRAM has four internal banks */
410 .timing = { /* SDRAM Timing parameters */
411 .row_to_col_delay = 2, /* Row to column delay (2 clock cycles) */
412 .row_precharge = 2, /* Row precharge delay (2 clock cycles) */
413 .recovery_delay = 2, /* Recovery delay is (2 clock cycles) */
414 .row_cylce = 7, /* Row cycle delay is (7 clock cycles) */
415 .self_refresh = 4, /* Self refresh time is (4 clock cycles) */
416 .exit_self_refresh = 7, /* Exit self-refresh delay (7 clock cycles) */
417 .load_mode_register = 2, /* Load Mode Register to Activate delay */
418 .refresh_period = 16, /* Refresh period in ms */
419 },
420 },
421 },
422};
423
427#define FMC_BANK_NUMOF ARRAY_SIZE(fmc_bank_config)
429
434
438static const sdmmc_conf_t sdmmc_config[] = {
439 {
440 .dev = SDMMC1,
441 .bus = APB2,
442 .rcc_mask = RCC_APB2ENR_SDMMC1EN,
443 .cd = GPIO_PIN(PORT_C, 13),
444 .cd_active = 0, /* CD pin is LOW active */
445 .cd_mode = GPIO_IN_PU, /* Pull-up R12 not soldered by default */
446 .clk = { GPIO_PIN(PORT_C, 12), GPIO_AF12 },
447 .cmd = { GPIO_PIN(PORT_D, 2), GPIO_AF12 },
448 .dat0 = { GPIO_PIN(PORT_C, 8), GPIO_AF12 },
449 .dat1 = { GPIO_PIN(PORT_C, 9), GPIO_AF12 },
450 .dat2 = { GPIO_PIN(PORT_C, 10), GPIO_AF12 },
451 .dat3 = { GPIO_PIN(PORT_C, 11), GPIO_AF12 },
452#ifdef MODULE_PERIPH_DMA
453 .dma = 5,
454 .dma_chan = 4,
455#endif
456 .irqn = SDMMC1_IRQn
457 },
458};
459
463#define SDMMC_CONFIG_NUMOF 1
464
466
467#ifdef __cplusplus
468}
469#endif
470
@ PORT_B
port B
Definition periph_cpu.h:44
@ PORT_G
port G
Definition periph_cpu.h:49
@ PORT_C
port C
Definition periph_cpu.h:45
@ PORT_F
port F
Definition periph_cpu.h:48
@ PORT_E
port E
Definition periph_cpu.h:47
@ PORT_A
port A
Definition periph_cpu.h:43
@ PORT_D
port D
Definition periph_cpu.h:46
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:42
@ PORT_K
port K
Definition periph_cpu.h:50
@ PORT_H
port H
Definition periph_cpu.h:48
@ PORT_J
port J
Definition periph_cpu.h:49
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:274
static const sdmmc_conf_t sdmmc_config[]
SDMMC devices.
static const fmc_bank_conf_t fmc_bank_config[]
FMC Bank configuration.
static const fmc_conf_t fmc_config
FMC controller configuration.
static const ltdc_conf_t ltdc_config
LTDC static configuration struct.
Common configuration for STM32 Timer peripheral based on TIM2.
Common configuration for STM32 OTG FS peripheral.
@ RMII
Configuration for RMII.
Definition cpu_eth.h:36
@ GPIO_AF5
use alternate function 5
Definition cpu_gpio.h:106
@ GPIO_AF4
use alternate function 4
Definition cpu_gpio.h:105
@ GPIO_AF10
use alternate function 10
Definition cpu_gpio.h:112
@ GPIO_AF9
use alternate function 9
Definition cpu_gpio.h:111
@ GPIO_AF14
use alternate function 14
Definition cpu_gpio.h:116
@ GPIO_AF12
use alternate function 12
Definition cpu_gpio.h:114
@ GPIO_AF7
use alternate function 7
Definition cpu_gpio.h:108
static const dwc2_usb_otg_fshs_config_t dwc2_usb_otg_fshs_config[]
Common USB OTG FS configuration.
#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
@ FMC_SDRAM
SDRAM Controller used.
Definition cpu_fmc.h:344
@ FMC_BUS_WIDTH_16BIT
16 bit data bus width
Definition cpu_fmc.h:352
#define MII_BMCR_FULL_DPLX
Set for full duplex.
Definition mii.h:68
#define MII_BMCR_SPEED_100
Set speed to 100 Mbps.
Definition mii.h:72
Interface definition for MII/RMII h.
DMA configuration.
Definition cpu_dma.h:31
Ethernet Peripheral configuration.
Definition cpu_eth.h:43
Bank configuration structure.
Definition cpu_fmc.h:359
FMC peripheral configuration.
Definition cpu_fmc.h:277
I2C configuration structure.
Definition periph_cpu.h:295
LTDC Peripheral configuration.
Definition cpu_ltdc.h:40
SDMMC slot configuration.
Definition periph_cpu.h:701
SPI device configuration.
Definition periph_cpu.h:333
UART device configuration.
Definition periph_cpu.h:214
#define MiB(x)
A macro to return the bytes in x MiB.
Definition units.h:33
Low level USB FS/HS driver definitions for MCUs with Synopsys DWC2 IP core.
@ DWC2_USB_OTG_PHY_ULPI
ULPI for external HS PHY.
@ DWC2_USB_OTG_HS
High speed peripheral.