Loading...
Searching...
No Matches
cpu_fmc.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 Gunar Schorcht
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
55#ifndef PERIPH_CPU_FMC_H
56#define PERIPH_CPU_FMC_H
57
58#include <stdint.h>
59
60#include "cpu.h"
61#include "periph/cpu_gpio.h"
62
63#ifdef __cplusplus
64extern "C" {
65#endif
66
74#ifndef FMC_BANK_CONFIG
75#define FMC_BANK_CONFIG(n) (&fmc_bank_config[n])
76#endif
77
86#if MODULE_PERIPH_FMC_32BIT || DOXYGEN
87#define FMC_DATA_PIN_NUMOF (32)
88#elif MODULE_PERIPH_FMC_16BIT
89#define FMC_DATA_PIN_NUMOF (16)
90#else
91#define FMC_DATA_PIN_NUMOF (8)
92#endif
93
104#if MODULE_PERIPH_FMC_NOR_SRAM || DOXYGEN
105#define FMC_ADDR_PIN_NUMOF (26)
106#elif MODULE_PERIPH_FMC_SDRAM
107#define FMC_ADDR_PIN_NUMOF (13)
108#else
109#define FMC_ADDR_PIN_NUMOF (0)
110#endif
111
112#if DOXYGEN
123#define FMC_RAM_ADDR 0x60000000
124
137#define FMC_RAM_LEN 1024K
138#endif
139
153
171
197typedef enum {
198 FMC_BURST_LENGTH_1 = 0, /* Burst length is 1 */
199 FMC_BURST_LENGTH_2 = 1, /* Burst length is 2 */
200 FMC_BURST_LENGTH_4 = 2, /* Burst length is 4 */
201 FMC_BURST_LENGTH_8 = 3, /* Burst length is 8 */
202 FMC_BURST_LENGTH_16 = 4, /* Burst length is 16 */
203 FMC_BURST_LENGTH_32 = 5, /* Burst length is 32 */
204 FMC_BURST_LENGTH_64 = 6, /* Burst length is 64 */
205 FMC_BURST_LENGTH_FULL = 7, /* Burst length is full page */
207
234
261typedef struct {
262 gpio_t pin;
264} fmc_gpio_t;
265
278typedef struct {
279 uint8_t bus;
280 uint32_t rcc_mask;
282#if FMC_ADDR_PIN_NUMOF || DOXYGEN
284#endif
285 /* signals used by all kind of memories */
291#if MODULE_PERIPH_FMC_NOR_SRAM
292 /* NORs, PSRAMs, and SRAMs use CLK, NOE, NWE, NE, and NADV signals **/
293 fmc_gpio_t clk_pin;
294 fmc_gpio_t noe_pin;
295 fmc_gpio_t nwe_pin;
296 fmc_gpio_t ne1_pin;
297 fmc_gpio_t ne2_pin;
298 fmc_gpio_t ne3_pin;
299 fmc_gpio_t ne4_pin;
300 fmc_gpio_t nadv_pin;
301#endif /* MODULE_PERIPH_FMC_NORSRAM */
302#if MODULE_PERIPH_FMC_SDRAM
303 /* SDRAMs use BAx, CLK, RAS, CAS, WE, ... signals **/
304 fmc_gpio_t ba0_pin;
305 fmc_gpio_t ba1_pin;
306 fmc_gpio_t sdclk_pin;
307 fmc_gpio_t sdnwe_pin;
308 fmc_gpio_t sdnras_pin;
309 fmc_gpio_t sdncas_pin;
310 fmc_gpio_t sdcke0_pin;
311 fmc_gpio_t sdcke1_pin;
312 fmc_gpio_t sdne0_pin;
313 fmc_gpio_t sdne1_pin;
314#endif /* MODULE_PERIPH_FMC_SDRAM */
315} fmc_conf_t;
316
320typedef enum {
322#if defined(FMC_Bank2_3_R_BASE)
323 FMC_BANK_2 = 2,
324#endif
325#if defined(FMC_Bank2_3_R_BASE) || defined(FMC_Bank3_R_BASE)
326 FMC_BANK_3 = 3,
327#endif
328#if defined(FMC_Bank4_R_BASE)
329 FMC_BANK_4 = 4,
330#endif
331#if defined(FMC_Bank5_6_R_BASE)
332 FMC_BANK_5 = 5,
333 FMC_BANK_6 = 6,
334#endif
335} fmc_bank_t;
336
347
356
360typedef struct {
364 uint32_t address;
365 uint32_t size;
366 union {
367 fmc_nor_sram_bank_conf_t nor_sram; /* Configuration in case of NOR/PSRAM/SRAM */
368 fmc_sdram_bank_conf_t sdram; /* Configuration in case of SDRAM */
369 };
371
372typedef uint8_t fmc_bank_id_t;
375#ifdef __cplusplus
376}
377#endif
378
379#endif /* PERIPH_CPU_FMC_H */
GPIO CPU definitions for the STM32 family.
gpio_af_t
Override alternative GPIO mode options.
Definition periph_cpu.h:166
#define FMC_DATA_PIN_NUMOF
Number of data pins used.
Definition cpu_fmc.h:87
#define FMC_ADDR_PIN_NUMOF
Number of address pins used.
Definition cpu_fmc.h:105
fmc_mem_type_t
Memory types supported by the FMC controller.
Definition cpu_fmc.h:340
fmc_access_mode_t
Memory access modes for NOR/PSRAM/SRAM in extended mode.
Definition cpu_fmc.h:147
uint8_t fmc_bank_id_t
FMC bank identifier.
Definition cpu_fmc.h:372
fmc_bus_width_t
Memory data bus widths.
Definition cpu_fmc.h:351
fmc_bust_length_t
SDRAM Burst Length as an exponent of a power of two.
Definition cpu_fmc.h:197
fmc_bank_t
Memory banks.
Definition cpu_fmc.h:320
@ FMC_SDRAM
SDRAM Controller used.
Definition cpu_fmc.h:345
@ FMC_NOR
NOR Flash.
Definition cpu_fmc.h:343
@ FMC_SRAM
SRAM.
Definition cpu_fmc.h:341
@ FMC_PSRAM
PSRAM.
Definition cpu_fmc.h:342
@ FMC_NAND
NAND Flash.
Definition cpu_fmc.h:344
@ FMC_MODE_A
Access mode A.
Definition cpu_fmc.h:148
@ FMC_MODE_B
Access mode B.
Definition cpu_fmc.h:149
@ FMC_MODE_C
Access mode C.
Definition cpu_fmc.h:150
@ FMC_MODE_D
Access mode D.
Definition cpu_fmc.h:151
@ FMC_BUS_WIDTH_16BIT
16 bit data bus width
Definition cpu_fmc.h:353
@ FMC_BUS_WIDTH_32BIT
32 bit data bus width
Definition cpu_fmc.h:354
@ FMC_BUS_WIDTH_8BIT
8 bit data bus width
Definition cpu_fmc.h:352
@ FMC_BANK_1
Bank 1 is always available and used for NOR, PSRAM, SRAM.
Definition cpu_fmc.h:321
Bank configuration structure.
Definition cpu_fmc.h:360
fmc_bus_width_t data_width
Data bus width.
Definition cpu_fmc.h:363
uint32_t address
Address of the memory bank.
Definition cpu_fmc.h:364
uint32_t size
Size in bytes of the memory bank.
Definition cpu_fmc.h:365
fmc_mem_type_t mem_type
Type of memory.
Definition cpu_fmc.h:362
fmc_bank_t bank
Bank1 .
Definition cpu_fmc.h:361
FMC peripheral configuration.
Definition cpu_fmc.h:278
fmc_gpio_t nwait_pin
NWAIT pin.
Definition cpu_fmc.h:290
uint8_t bus
AHB/APB bus.
Definition cpu_fmc.h:279
fmc_gpio_t nbl0_pin
NBL0 pin.
Definition cpu_fmc.h:286
fmc_gpio_t nbl1_pin
NBL1 pin.
Definition cpu_fmc.h:287
fmc_gpio_t nbl2_pin
NBL2 pin.
Definition cpu_fmc.h:288
uint32_t rcc_mask
Bit in clock enable register.
Definition cpu_fmc.h:280
fmc_gpio_t nbl3_pin
NBL3 pin.
Definition cpu_fmc.h:289
FMC GPIO configuration type.
Definition cpu_fmc.h:261
gpio_t pin
GPIO pin.
Definition cpu_fmc.h:262
gpio_af_t af
Alternate function.
Definition cpu_fmc.h:263
Bank configuration structure for NOR/PSRAM/SRAM.
Definition cpu_fmc.h:175
bool ext_mode
Extended mode used (separate read and write timings)
Definition cpu_fmc.h:181
fmc_nor_sram_timing_t w_timing
Write timings (only used if fmc_nor_sram_bank_conf_t::ext_mode is true)
Definition cpu_fmc.h:185
bool wait_enable
Wait signal used for synchronous access.
Definition cpu_fmc.h:179
bool mux_enable
Multiplexed address/data signals used (only valid for PSRAMs and NORs.
Definition cpu_fmc.h:177
uint8_t sub_bank
Bank1 has 4 subbanks 1..4.
Definition cpu_fmc.h:176
fmc_nor_sram_timing_t r_timing
Read timings (also used for write if fmc_nor_sram_bank_conf_t::ext_mode is false)
Definition cpu_fmc.h:183
Timing configuration for NOR/PSRAM/SRAM.
Definition cpu_fmc.h:160
uint8_t bus_turnaround
Bus turnaround phase duration [0..15], default 15.
Definition cpu_fmc.h:169
uint8_t clk_div
Clock divide ratio, FMC_CLK = HCLK / (DIV + 1)
Definition cpu_fmc.h:163
uint8_t data_setup
Data setup time [0..15], default 15.
Definition cpu_fmc.h:166
uint8_t addr_hold
Address hold time [0..15], default 15.
Definition cpu_fmc.h:165
fmc_access_mode_t mode
Access Mode used (only used if fmc_nor_sram_bank_conf_t::ext_mode is true)
Definition cpu_fmc.h:161
uint8_t addr_setup
Address setup time [0..15], default 15.
Definition cpu_fmc.h:164
uint8_t data_latency
Data latency for synchronous access [0..15], default 15 (only used in read timing)
Definition cpu_fmc.h:167
Bank configuration structure for SDRAM.
Definition cpu_fmc.h:238
uint8_t cas_latency
CAS latency in SDCLK clock cycles [1..3].
Definition cpu_fmc.h:242
bool burst_write
Burst write mode enabled.
Definition cpu_fmc.h:247
uint8_t col_bits
Number column address bits [8..11].
Definition cpu_fmc.h:241
bool burst_read
Burst read mode enabled.
Definition cpu_fmc.h:246
uint8_t row_bits
Number row address bits [11..13].
Definition cpu_fmc.h:240
fmc_bust_length_t burst_len
Burst length as an exponent of a power of two.
Definition cpu_fmc.h:249
fmc_sdram_timing_t timing
SDRAM Timing configuration.
Definition cpu_fmc.h:250
bool write_protect
Write protection enabled.
Definition cpu_fmc.h:245
uint8_t read_delay
Delay for reading data after CAS latency in HCLKs [0..2].
Definition cpu_fmc.h:243
bool burst_interleaved
Burst mode interleaved, otherwise sequential.
Definition cpu_fmc.h:248
bool four_banks
SDRAM has four internal banks.
Definition cpu_fmc.h:244
uint8_t clk_period
CLK period [0,2,3] (0 - disabled, n * HCLK cycles)
Definition cpu_fmc.h:239
Timing configuration for SDRAM.
Definition cpu_fmc.h:211
uint8_t refresh_period
Refresh period in milliseconds.
Definition cpu_fmc.h:232
uint8_t row_precharge
Row precharge delay in SDCLK clock cycles [1..15], delay between Precharge and another command.
Definition cpu_fmc.h:215
uint8_t row_cylce
Row cycle delay in SDCLK clock cycles [1..15], delay between Refresh and Activate command.
Definition cpu_fmc.h:221
uint8_t row_to_col_delay
Row to column delay in SDCLK clock cycles [1..16], delay between Activate and Read/Write command.
Definition cpu_fmc.h:212
uint8_t load_mode_register
Load Mode Register to Activate delay in SDCLK clock cycles [1..15], delay between Load Mode Register ...
Definition cpu_fmc.h:229
uint8_t self_refresh
Self refresh time in SDCLK clock cycles [1..15].
Definition cpu_fmc.h:224
uint8_t exit_self_refresh
Exit self-refresh delay in SDCLK clock cycles [1..15], delay between Self-Refresh and Activate comman...
Definition cpu_fmc.h:226
uint8_t recovery_delay
Recovery delay in SDCLK clock cycles [1..15], delay between Write and Precharge command.
Definition cpu_fmc.h:218