Loading...
Searching...
No Matches
STM32 FMC/FSMC peripheral driver

The periph_fmc module implements a driver for STM32 FMC/FSMC peripherals. More...

Detailed Description

The periph_fmc module implements a driver for STM32 FMC/FSMC peripherals.

It supports

NAND Flashes are not yet supported.

To use the FMC/FSMC, the periph_fmc module has to be enabled. To keep required data structures and resulting code as small as possible, a couple of pseudomodules are defined that have to be used in addition to the periph_fmc module to enable supported features. These are:

Module Feature
periph_fmc_nor_sram enable NOR Flash and PSRAM/SRAM support
periph_fmc_sdram enable SDRAM support
periph_fmc_16bit enable 16-bit support
periph_fmc_32bit enable 32-bit support


The board has then to define

As examples for such configurations, see STM32L496G-DISCO (FMC with Display and SRAM) or STM32F429I-DISC1 (FMC with SDRAM).

To use the RAM connected to the FMC as heap, the board has also to define FMC_RAM_ADDR and FMC_RAM_LEN.

Files

file  cpu_fmc.h
 Specific FMC definitions for the STM32.
 

Data Structures

struct  fmc_nor_sram_timing_t
 Timing configuration for NOR/PSRAM/SRAM. More...
 
struct  fmc_nor_sram_bank_conf_t
 Bank configuration structure for NOR/PSRAM/SRAM. More...
 
struct  fmc_sdram_timing_t
 Timing configuration for SDRAM. More...
 
struct  fmc_sdram_bank_conf_t
 Bank configuration structure for SDRAM. More...
 
struct  fmc_gpio_t
 FMC GPIO configuration type. More...
 
struct  fmc_conf_t
 FMC peripheral configuration. More...
 
struct  fmc_bank_conf_t
 Bank configuration structure. More...
 

Macros

#define FMC_BANK_CONFIG(n)   (&fmc_bank_config[n])
 Gives the configuration of n-th bank.
 
#define FMC_DATA_PIN_NUMOF   (32)
 Number of data pins used.
 
#define FMC_ADDR_PIN_NUMOF   (26)
 Number of address pins used.
 
#define FMC_RAM_ADDR   0x60000000
 Start address of the heap for the FMC RAM.
 
#define FMC_RAM_LEN   1024K
 Length of the heap for the FMC RAM.
 

Type declarations for NOR Flash, PSRAM and SRAM

enum  fmc_access_mode_t { FMC_MODE_A = 0 , FMC_MODE_B = 1 , FMC_MODE_C = 2 , FMC_MODE_D = 3 }
 Memory access modes for NOR/PSRAM/SRAM in extended mode. More...
 

Type declarations for SDRAMs

enum  fmc_bust_length_t {
  FMC_BURST_LENGTH_1 = 0 , FMC_BURST_LENGTH_2 = 1 , FMC_BURST_LENGTH_4 = 2 , FMC_BURST_LENGTH_8 = 3 ,
  FMC_BURST_LENGTH_16 = 4 , FMC_BURST_LENGTH_32 = 5 , FMC_BURST_LENGTH_64 = 6 , FMC_BURST_LENGTH_FULL = 7
}
 SDRAM Burst Length as an exponent of a power of two. More...
 

Type declarations that are common for all memories

enum  fmc_bank_t { FMC_BANK_1 = 1 }
 Memory banks. More...
 
enum  fmc_mem_type_t {
  FMC_SRAM = 0 , FMC_PSRAM = 1 , FMC_NOR = 2 , FMC_NAND = 3 ,
  FMC_SDRAM = 4
}
 Memory types supported by the FMC controller. More...
 
enum  fmc_bus_width_t { FMC_BUS_WIDTH_8BIT = 0 , FMC_BUS_WIDTH_16BIT = 1 , FMC_BUS_WIDTH_32BIT = 2 }
 Memory data bus widths. More...
 
typedef uint8_t fmc_bank_id_t
 FMC bank identifier.
 

Macro Definition Documentation

◆ FMC_ADDR_PIN_NUMOF

#define FMC_ADDR_PIN_NUMOF   (26)

Number of address pins used.

The number of configured address pins depends on the memory types used. NORs, PSRAMs and SRAMs (module periph_fmc_nor_sram) use up to 26 address signals A0...A25 if address/data multiplexing is not used. SDRAMs (module periph_fmc_sdram) use only up to 13 address signals A0...A12. NANDs (module periph_fmc_sdram) don't need separate address signals. The type of used memories is specified by the corresponding pseudomodules.

Definition at line 105 of file cpu_fmc.h.

◆ FMC_BANK_CONFIG

#define FMC_BANK_CONFIG (   n)    (&fmc_bank_config[n])

Gives the configuration of n-th bank.

This macro gives a pointer to the n-th entry of type fmc_bank_conf_t of the banks configured by the board in the fmc_bank_config array. n is in the range 0 ... FMC_BANK_NUMOF - 1.

Definition at line 75 of file cpu_fmc.h.

◆ FMC_DATA_PIN_NUMOF

#define FMC_DATA_PIN_NUMOF   (32)

Number of data pins used.

The number of configured data pins depends on the memory with the maximum data bus width. The maximum data bus width used has to be specified by the pseudomodules periph_fmc_16bit and periph_fmc_32bit. 8 bit data bus width is the default.

Definition at line 87 of file cpu_fmc.h.

◆ FMC_RAM_ADDR

#define FMC_RAM_ADDR   0x60000000

Start address of the heap for the FMC RAM.

This variable has to be defined in Makefile.include of the board definition to use the a RAM connected to the FMC as heap. It has to correspond to the fmc_bank_conf_t::address in FMC bank configuration.

Note
FMC_RAM_ADDR is not a macro and cannot be used in C code. It is just defined for documentation purpose.

Definition at line 123 of file cpu_fmc.h.

◆ FMC_RAM_LEN

#define FMC_RAM_LEN   1024K

Length of the heap for the FMC RAM.

This variable has to be defined in Makefile.include of the board definition to use the a RAM connected to the FMC as heap. It has to correspond to the fmc_bank_conf_t::size in FMC bank configuration. Since it is used in linker script, it has to be defined in kByte with suffix K, e.g. 1024K.

Note
FMC_RAM_SIZE is not a macro and cannot be used in C code. It is just defined for documentation purpose.

Definition at line 137 of file cpu_fmc.h.

Typedef Documentation

◆ fmc_bank_id_t

typedef uint8_t fmc_bank_id_t

FMC bank identifier.

Definition at line 372 of file cpu_fmc.h.

Enumeration Type Documentation

◆ fmc_access_mode_t

Memory access modes for NOR/PSRAM/SRAM in extended mode.

Enumerator
FMC_MODE_A 

Access mode A.

FMC_MODE_B 

Access mode B.

FMC_MODE_C 

Access mode C.

FMC_MODE_D 

Access mode D.

Definition at line 147 of file cpu_fmc.h.

◆ fmc_bank_t

enum fmc_bank_t

Memory banks.

Enumerator
FMC_BANK_1 

Bank 1 is always available and used for NOR, PSRAM, SRAM.

Definition at line 320 of file cpu_fmc.h.

◆ fmc_bus_width_t

Memory data bus widths.

Enumerator
FMC_BUS_WIDTH_8BIT 

8 bit data bus width

FMC_BUS_WIDTH_16BIT 

16 bit data bus width

FMC_BUS_WIDTH_32BIT 

32 bit data bus width

Definition at line 351 of file cpu_fmc.h.

◆ fmc_bust_length_t

SDRAM Burst Length as an exponent of a power of two.

Definition at line 197 of file cpu_fmc.h.

◆ fmc_mem_type_t

Memory types supported by the FMC controller.

Enumerator
FMC_SRAM 

SRAM.

FMC_PSRAM 

PSRAM.

FMC_NOR 

NOR Flash.

FMC_NAND 

NAND Flash.

FMC_SDRAM 

SDRAM Controller used.

Definition at line 340 of file cpu_fmc.h.