periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Inria
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 
19 #ifndef PERIPH_CONF_H
20 #define PERIPH_CONF_H
21 
22 /* This board provides an LSE */
23 #ifndef CONFIG_BOARD_HAS_LSE
24 #define CONFIG_BOARD_HAS_LSE 1
25 #endif
26 
27 /* This board provides an HSE */
28 #ifndef CONFIG_BOARD_HAS_HSE
29 #define CONFIG_BOARD_HAS_HSE 1
30 #endif
31 
32 #include "periph_cpu.h"
33 #include "clk_conf.h"
34 #include "cfg_timer_tim5.h"
35 #include "cfg_usb_otg_hs_phy_fs.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
45 static const dma_conf_t dma_config[] = {
46  { .stream = 14 }, /* DMA2 Stream 6 - SPI5_TX */
47  { .stream = 13 }, /* DMA2 Stream 5 - SPI5_RX */
48 };
49 
50 #define DMA_0_ISR isr_dma2_stream6
51 #define DMA_1_ISR isr_dma2_stream5
52 
53 #define DMA_NUMOF ARRAY_SIZE(dma_config)
60 static const uart_conf_t uart_config[] = {
61  {
62  .dev = USART1,
63  .rcc_mask = RCC_APB2ENR_USART1EN,
64  .rx_pin = GPIO_PIN(PORT_A, 10),
65  .tx_pin = GPIO_PIN(PORT_A, 9),
66  .rx_af = GPIO_AF7,
67  .tx_af = GPIO_AF7,
68  .bus = APB2,
69  .irqn = USART1_IRQn,
70 #ifdef MODULE_PERIPH_DMA
71  .dma = DMA_STREAM_UNDEF,
72  .dma_chan = UINT8_MAX,
73 #endif
74  }
75 };
76 
77 #define UART_0_ISR (isr_usart1)
78 
79 #define UART_NUMOF ARRAY_SIZE(uart_config)
86 static const spi_conf_t spi_config[] = {
87  {
88  .dev = SPI5,
89  .mosi_pin = GPIO_PIN(PORT_F, 9),
90  .miso_pin = GPIO_PIN(PORT_F, 8),
91  .sclk_pin = GPIO_PIN(PORT_F, 7),
92  .cs_pin = GPIO_UNDEF,
93  .mosi_af = GPIO_AF5,
94  .miso_af = GPIO_AF5,
95  .sclk_af = GPIO_AF5,
96  .cs_af = GPIO_AF5,
97  .rccmask = RCC_APB2ENR_SPI5EN,
98  .apbbus = APB2,
99 #ifdef MODULE_PERIPH_DMA
100  .tx_dma = 0,
101  .tx_dma_chan = 7,
102  .rx_dma = 1,
103  .rx_dma_chan = 7,
104 #endif
105  }
106 };
107 
108 #define SPI_NUMOF ARRAY_SIZE(spi_config)
115 static const i2c_conf_t i2c_config[] = {
116  {
117  .dev = I2C3,
118  .speed = I2C_SPEED_NORMAL,
119  .scl_pin = GPIO_PIN(PORT_A, 8),
120  .sda_pin = GPIO_PIN(PORT_C, 9),
121  .scl_af = GPIO_AF4,
122  .sda_af = GPIO_AF4,
123  .bus = APB1,
124  .rcc_mask = RCC_APB1ENR_I2C3EN,
125  .clk = CLOCK_APB1,
126  .irqn = I2C3_EV_IRQn,
127  }
128 };
129 
130 #define I2C_0_ISR isr_i2c3_ev
131 
132 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
142 static const fmc_conf_t fmc_config = {
143  .bus = AHB3,
144  .rcc_mask = RCC_AHB3ENR_FMCEN,
145 #if MODULE_PERIPH_FMC_SDRAM
146  .ba0_pin = { .pin = GPIO_PIN(PORT_G, 4), .af = GPIO_AF12, }, /* FMC_BA0 signal */
147  .ba1_pin = { .pin = GPIO_PIN(PORT_G, 5), .af = GPIO_AF12, }, /* FMC_BA1 signal */
148  .sdclk_pin = { .pin = GPIO_PIN(PORT_G, 8), .af = GPIO_AF12, }, /* FMC_SDCLK signal */
149  .sdnwe_pin = { .pin = GPIO_PIN(PORT_C, 0), .af = GPIO_AF12, }, /* FMC_SDNWE signal */
150  .sdnras_pin = { .pin = GPIO_PIN(PORT_F, 11), .af = GPIO_AF12, }, /* FMC_SDNRAS signal */
151  .sdncas_pin = { .pin = GPIO_PIN(PORT_G, 15), .af = GPIO_AF12, }, /* FMC_SDNCAS signal */
152  .sdcke1_pin = { .pin = GPIO_PIN(PORT_B, 5), .af = GPIO_AF12, }, /* FMC_SDCKE1 signal */
153  .sdne1_pin = { .pin = GPIO_PIN(PORT_B, 6), .af = GPIO_AF12, }, /* FMC_SDNE1 signal */
154  .addr = {
155  { .pin = GPIO_PIN(PORT_F, 0), .af = GPIO_AF12, }, /* FMC_A0 signal */
156  { .pin = GPIO_PIN(PORT_F, 1), .af = GPIO_AF12, }, /* FMC_A1 signal */
157  { .pin = GPIO_PIN(PORT_F, 2), .af = GPIO_AF12, }, /* FMC_A2 signal */
158  { .pin = GPIO_PIN(PORT_F, 3), .af = GPIO_AF12, }, /* FMC_A3 signal */
159  { .pin = GPIO_PIN(PORT_F, 4), .af = GPIO_AF12, }, /* FMC_A4 signal */
160  { .pin = GPIO_PIN(PORT_F, 5), .af = GPIO_AF12, }, /* FMC_A5 signal */
161  { .pin = GPIO_PIN(PORT_F, 12), .af = GPIO_AF12, }, /* FMC_A6 signal */
162  { .pin = GPIO_PIN(PORT_F, 13), .af = GPIO_AF12, }, /* FMC_A7 signal */
163  { .pin = GPIO_PIN(PORT_F, 14), .af = GPIO_AF12, }, /* FMC_A8 signal */
164  { .pin = GPIO_PIN(PORT_F, 15), .af = GPIO_AF12, }, /* FMC_A9 signal */
165  { .pin = GPIO_PIN(PORT_G, 0), .af = GPIO_AF12, }, /* FMC_A10 signal */
166  { .pin = GPIO_PIN(PORT_G, 1), .af = GPIO_AF12, }, /* FMC_A11 signal */
167  },
168 #endif
169  .data = {
170  { .pin = GPIO_PIN(PORT_D, 14), .af = GPIO_AF12, }, /* FMC_D0 signal */
171  { .pin = GPIO_PIN(PORT_D, 15), .af = GPIO_AF12, }, /* FMC_D1 signal */
172  { .pin = GPIO_PIN(PORT_D, 0), .af = GPIO_AF12, }, /* FMC_D2 signal */
173  { .pin = GPIO_PIN(PORT_D, 1), .af = GPIO_AF12, }, /* FMC_D3 signal */
174  { .pin = GPIO_PIN(PORT_E, 7), .af = GPIO_AF12, }, /* FMC_D4 signal */
175  { .pin = GPIO_PIN(PORT_E, 8), .af = GPIO_AF12, }, /* FMC_D5 signal */
176  { .pin = GPIO_PIN(PORT_E, 9), .af = GPIO_AF12, }, /* FMC_D6 signal */
177  { .pin = GPIO_PIN(PORT_E, 10), .af = GPIO_AF12, }, /* FMC_D7 signal */
178 #if MODULE_PERIPH_FMC_16BIT
179  { .pin = GPIO_PIN(PORT_E, 11), .af = GPIO_AF12, }, /* FMC_D8 signal */
180  { .pin = GPIO_PIN(PORT_E, 12), .af = GPIO_AF12, }, /* FMC_D9 signal */
181  { .pin = GPIO_PIN(PORT_E, 13), .af = GPIO_AF12, }, /* FMC_D10 signal */
182  { .pin = GPIO_PIN(PORT_E, 14), .af = GPIO_AF12, }, /* FMC_D11 signal */
183  { .pin = GPIO_PIN(PORT_E, 15), .af = GPIO_AF12, }, /* FMC_D12 signal */
184  { .pin = GPIO_PIN(PORT_D, 8), .af = GPIO_AF12, }, /* FMC_D13 signal */
185  { .pin = GPIO_PIN(PORT_D, 9), .af = GPIO_AF12, }, /* FMC_D14 signal */
186  { .pin = GPIO_PIN(PORT_D, 10), .af = GPIO_AF12, }, /* FMC_D15 signal */
187 #endif
188  },
189  .nbl0_pin = { .pin = GPIO_PIN(PORT_E, 0), .af = GPIO_AF12, }, /* FMC_NBL0 signal (LB) */
190  .nbl1_pin = { .pin = GPIO_PIN(PORT_E, 1), .af = GPIO_AF12, }, /* FMC_NBL1 signal (UB) */
191 };
192 
201  /* bank 6 is used for SDRAM */
202  {
203  .bank = FMC_BANK_6,
204  .mem_type = FMC_SDRAM,
205  .data_width = FMC_BUS_WIDTH_16BIT,
206  .address = 0xd0000000, /* Bank 6 is mapped to 0xd0000000 */
207  .size = MiB(8), /* Size in Mbyte, 4M x 16 bit */
208  .sdram = {
209  .clk_period = 2, /* SDCLK = 2 x HCLK */
210  .row_bits = 12, /* A11..A0 used for row address */
211  .col_bits = 8, /* A8..A0 used for column address */
212  .cas_latency = 3, /* CAS latency is 3 clock cycles */
213  .read_delay = 0, /* No read delay after CAS */
214  .burst_read = false, /* Burst read mode disabled */
215  .burst_write = false, /* Burst write mode disabled */
216  .burst_len = FMC_BURST_LENGTH_1, /* Burst length is 1 if enabled */
217  .burst_interleaved = false, /* Burst mode interleaved */
218  .write_protect = false, /* No write protection */
219  .four_banks = true, /* SDRAM has four internal banks */
220  .timing = { /* SDRAM Timing parameters */
221  .row_to_col_delay = 2, /* Row to column delay (2 clock cycles) */
222  .row_precharge = 2, /* Row precharge delay (2 clock cycles) */
223  .recovery_delay = 2, /* Recovery delay is (2 clock cycles) */
224  .row_cylce = 7, /* Row cycle delay is (7 clock cycles) */
225  .self_refresh = 4, /* Self refresh time is (4 clock cycles) */
226  .exit_self_refresh = 7, /* Exit self-refresh delay (7 clock cycles) */
227  .load_mode_register = 2, /* Load Mode Register to Activate delay */
228  .refresh_period = 64, /* Refresh period in ms */
229  },
230  },
231  },
232 };
233 
237 #define FMC_BANK_NUMOF ARRAY_SIZE(fmc_bank_config)
240 #ifdef __cplusplus
241 }
242 #endif
243 
244 #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
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
static const uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:39
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:97
static const i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:69
static const fmc_bank_conf_t fmc_bank_config[]
FMC Bank configuration.
Definition: periph_conf.h:200
static const fmc_conf_t fmc_config
FMC controller configuration.
Definition: periph_conf.h:142
Common configuration for STM32 Timer peripheral based on TIM5.
Common configuration for STM32 OTG HS peripheral with on-chip FS PHY.
@ GPIO_AF5
use alternate function 5
Definition: cpu_gpio.h:107
@ GPIO_AF4
use alternate function 4
Definition: cpu_gpio.h:106
@ 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_16BIT
16 bit data bus width
Definition: cpu_fmc.h:353
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:278
#define CLOCK_APB1
Half AHB clock.
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
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