PAN1080 Peripheral API
Modules | Data Structures | Macros | Typedefs | Functions
Fmc Interface

Fmc Interface. More...

Collaboration diagram for Fmc Interface:

Modules

 Fmc erase command
 Fmc erase command definition.
 
 Fmc status reg w/r command
 Fmc status register write and read command definition.
 
 Fmc status reg operation command
 Fmc status register operation command definition.
 
 Fmc read command
 Fmc read command definition.
 
 Fmc burst read command
 Fmc burst read command definition.
 
 Fmc work type select
 Fmc work type select definition.
 

Data Structures

struct  _flash_ids
 Structure with flash id. More...
 

Macros

#define CMD_TRIG   (0x01)
 
#define CMD_WRITE_ENABLE   (0x06)
 
#define QUAD_ENABLE_Pos   (9)
 
#define QUAD_ENABLE_Msk   (0x1ul << QUAD_ENABLE_Pos)
 
#define Write_Enable_Latch_Pos   (1)
 
#define Write_Enable_Latch_Msk   (0x1ul << Write_Enable_Latch_Pos)
 
#define Write_In_Process_Pos   (0)
 
#define Write_In_Process_Msk   (0x1ul << Write_In_Process_Pos)
 
#define Long_Time_Op_Pos   (17)
 
#define PAGE_SIZE   (256)
 
#define SECTOR_SIZE   (4096)
 

Typedefs

typedef struct _flash_ids FLASH_IDS_T
 Structure with flash id. More...
 

Functions

__STATIC_FORCEINLINE void FMC_EnterDeepPowerDownMode (FLCTL_T *fmc)
 Enter flash deep power down mode. More...
 
__STATIC_FORCEINLINE void FMC_ExitDeepPowerDownMode (FLCTL_T *fmc)
 Exit flash deep power down mode. More...
 
void FMC_GetFlashUniqueId (FLCTL_T *fmc)
 This function is used to get flash unique id,. More...
 
void FMC_GetFlashJedecId (FLCTL_T *fmc)
 This function is used to get flash jedec id,. More...
 
uint32_t FMC_GetFlashCodeAreaSize (FLCTL_T *fmc)
 Get Size of Flash in Bytes. More...
 
int FMC_EraseSector (FLCTL_T *fmc, unsigned long adr)
 Erase a 4KB Sector in Flash Memory. More...
 
int FMC_EraseBlock32k (FLCTL_T *fmc, unsigned long addr)
 Erase a 32KB Block in Flash Memory. More...
 
int FMC_EraseBlock64k (FLCTL_T *fmc, unsigned long addr)
 Erase a 64KB Block in Flash Memory. More...
 
int FMC_EraseChip (FLCTL_T *fmc)
 Erase the whole flash memory. More...
 
int FMC_EraseCodeArea (FLCTL_T *fmc, uint32_t addr, uint32_t len)
 Erase specific data in flash code area. More...
 
void InitIcache (FLCTL_T *fmc, uint32_t mode)
 This function is used to init Icache,. More...
 
int32_t FMC_GetCrc32Sum (FLCTL_T *fmc, uint32_t addr, uint32_t count, uint32_t *chksum)
 Calculate and read the CRC32 checksum of a specified flash area. More...
 
int BlankCheck (FLCTL_T *fmc, unsigned long adr, unsigned long sz)
 Blank check checks if memory is blank. More...
 
unsigned long Verify (FLCTL_T *fmc, unsigned long adr, unsigned long sz, unsigned char *buf)
 Verify in flash memory. More...
 
int ProgramPage (FLCTL_T *fmc, unsigned long adr, unsigned long sz, unsigned char *buf)
 Program page in flash memory. More...
 
unsigned char FMC_ReadStatusReg (FLCTL_T *fmc, unsigned char cmd)
 This function is used to read status, The Read Status Register can be read at any time. More...
 
unsigned char FMC_WriteEnable (FLCTL_T *fmc)
 This function is used to enable write function,. More...
 
void FMC_WriteStatusReg (FLCTL_T *fmc, unsigned char ops, unsigned int buf)
 This function is used to write status, The Read Status Register can be read at any time. More...
 
unsigned char FMC_ReadByte (FLCTL_T *fmc, unsigned int Addr, unsigned char cmd)
 This function is used to read flash,. More...
 
void FMC_WriteByte (FLCTL_T *fmc, unsigned int addr, unsigned char data)
 This function is used to write one byte to flash memory. More...
 
void FMC_WriteHalfWord (FLCTL_T *fmc, unsigned int addr, unsigned short data)
 This function is used to write halfword to flash memory. More...
 
unsigned int FMC_ReadWord (FLCTL_T *fmc, unsigned int Addr, unsigned char cmd)
 This function is used to read flash. More...
 
unsigned char * FMC_ReadPage (FLCTL_T *fmc, unsigned int Addr, unsigned char cmd)
 This function is used to read a page size (256 bytes) of data from flash. More...
 
int FMC_ReadStream (FLCTL_T *fmc, unsigned int Addr, unsigned char cmd, unsigned char *buf, unsigned int len)
 This function is used to read data stream from flash. More...
 
int FMC_WriteStream (FLCTL_T *fmc, unsigned int Addr, unsigned char *buf, unsigned int len)
 This function is used to write data stream to flash. More...
 
int FMC_ReadInfoArea (FLCTL_T *fmc, unsigned int Addr, unsigned char cmd, unsigned char *buf, unsigned int len)
 This function is used to read data from the flash 4KB INFO area. More...
 
int FMC_WriteInfoArea (FLCTL_T *fmc, unsigned int Addr, unsigned char *buf, unsigned int len)
 This function is used to write data to the flash 4KB INFO area. More...
 
int FMC_EraseInfoArea (FLCTL_T *fmc)
 This function is used to erase the flash 4KB INFO area. More...
 
void FMC_SetFlashMode (FLCTL_T *fmc, uint32_t mode, bool enhance)
 This function is used to set flash work mode. More...
 
void FMC_ExitEnhanceMode (FLCTL_T *fmc)
 This function is used to exit flash enhanced read mode. More...
 
void FMC_EnterEnhanceMode (FLCTL_T *fmc, uint32_t mode)
 This function is used to enter flash enhanced read mode. More...
 
void FMC_EnableAutoDp (FLCTL_T *fmc)
 This function is used to enable auto enter deep power down function. More...
 
void FMC_DisableAutoDp (FLCTL_T *fmc)
 This function is used to disable auto enter deep power down function. More...
 
void FMC_SetRdpWaitCount (FLCTL_T *fmc, uint32_t cnt)
 This function is used to set wait count for release from Deep Power-down mode. More...
 

Detailed Description

Fmc Interface.

Macro Definition Documentation

◆ CMD_TRIG

#define CMD_TRIG   (0x01)

Command to triger start operate

◆ CMD_WRITE_ENABLE

#define CMD_WRITE_ENABLE   (0x06)

Command to write enable operate

◆ Long_Time_Op_Pos

#define Long_Time_Op_Pos   (17)

Flash mode reg long time operate bit position

◆ PAGE_SIZE

#define PAGE_SIZE   (256)

Flash one page size

◆ QUAD_ENABLE_Msk

#define QUAD_ENABLE_Msk   (0x1ul << QUAD_ENABLE_Pos)

Flash status reg quad enable value

◆ QUAD_ENABLE_Pos

#define QUAD_ENABLE_Pos   (9)

Flash status reg quad enable bit position

◆ SECTOR_SIZE

#define SECTOR_SIZE   (4096)

Flash one sector size

◆ Write_Enable_Latch_Msk

#define Write_Enable_Latch_Msk   (0x1ul << Write_Enable_Latch_Pos)

Flash write enable value

◆ Write_Enable_Latch_Pos

#define Write_Enable_Latch_Pos   (1)

Flash write enable bit position

◆ Write_In_Process_Msk

#define Write_In_Process_Msk   (0x1ul << Write_In_Process_Pos)

Flash status reg WIP bit value,this bit indicates whether the memory is busy

◆ Write_In_Process_Pos

#define Write_In_Process_Pos   (0)

Flash status reg WIP bit position

Typedef Documentation

◆ FLASH_IDS_T

typedef struct _flash_ids FLASH_IDS_T

Structure with flash id.

Parameters
manufacturer_idSpecifies the flash manufacturer id
memory_type_idSpecifies the flash memory type id
memory_density_idSpecifies the flash memory density id
uidSpecifies the flash unique id

Function Documentation

◆ BlankCheck()

int BlankCheck ( FLCTL_T *  fmc,
unsigned long  adr,
unsigned long  sz 
)

Blank check checks if memory is blank.

Parameters
fmcWhere fmc is a flash peripheral.
adrBlock start address
szBlock Size (in bytes)
Return values
0Success
1Fail

◆ FMC_DisableAutoDp()

void FMC_DisableAutoDp ( FLCTL_T *  fmc)

This function is used to disable auto enter deep power down function.

Parameters
fmcWhere fmc is a flash peripheral.
Returns
None

◆ FMC_EnableAutoDp()

void FMC_EnableAutoDp ( FLCTL_T *  fmc)

This function is used to enable auto enter deep power down function.

Parameters
fmcWhere fmc is a flash peripheral.
Returns
None

◆ FMC_EnterDeepPowerDownMode()

__STATIC_FORCEINLINE void FMC_EnterDeepPowerDownMode ( FLCTL_T *  fmc)

Enter flash deep power down mode.

Parameters
fmcWhere fmc is the base address of fmc peripheral
Returns
None
Note
This function should be put in RAM in case of use Make sure Flash is out of enhance mode before use this API

◆ FMC_EnterEnhanceMode()

void FMC_EnterEnhanceMode ( FLCTL_T *  fmc,
uint32_t  mode 
)

This function is used to enter flash enhanced read mode.

Parameters
fmcWhere fmc is a flash peripheral.
modeWhere mode is line mode select. Fmc work type select
Note
Some Flash does not support 2-line enhance mode
Returns
None

◆ FMC_EraseBlock32k()

int FMC_EraseBlock32k ( FLCTL_T *  fmc,
unsigned long  addr 
)

Erase a 32KB Block in Flash Memory.

This function is used to erase a 32KB flash block in flash code area.

Note
The 1st 28KB flash block is not allowed to be erased as the Info Area resides in this physical 32KB flash block.
The 32KB flash block start address is 0x7000, 0xF000, 0x17000, 0x1F000, 0x27000, 0x2F000, ...
Parameters
fmcwhere fmc is a flash peripheral.
adrwhere addr is a erase start address.
Return values
0Success.
-1Fail.

◆ FMC_EraseBlock64k()

int FMC_EraseBlock64k ( FLCTL_T *  fmc,
unsigned long  addr 
)

Erase a 64KB Block in Flash Memory.

This function is used to erase a 64KB flash block in flash code area.

Note
The 1st 60KB flash block is not allowed to be erased as the Info Area resides in this physical 64KB flash block.
The 64KB flash block start address is 0xF000, 0x1F000, 0x2F000, 0x3F000, 0x4F000, 0x5F000, ...
Parameters
fmcwhere fmc is a flash peripheral.
adrwhere addr is a erase start address.
Return values
0Success.
-1Fail.

◆ FMC_EraseChip()

int FMC_EraseChip ( FLCTL_T *  fmc)

Erase the whole flash memory.

This function is used to erase all data in flash, include Code Area and Info Area.

Note
This API should only be used when you really know what you are doing.
Parameters
fmcwhere fmc is a flash peripheral.
Return values
0Success.
-1Fail.

◆ FMC_EraseCodeArea()

int FMC_EraseCodeArea ( FLCTL_T *  fmc,
uint32_t  addr,
uint32_t  len 
)

Erase specific data in flash code area.

This function is used to erase specific data in flash Code Area.

Note
This API is the most recommended function used to erase data in flash code area.
Parameters
fmcwhere fmc is a flash peripheral.
addrstart address to erase, should be 4KB aligned.
lenlength to erase in bytes.
Return values
0Success.
-1Fail.

◆ FMC_EraseInfoArea()

int FMC_EraseInfoArea ( FLCTL_T *  fmc)

This function is used to erase the flash 4KB INFO area.

Parameters
fmcwhere fmc is a flash peripheral
Return values
0erase success
-1erase fail

◆ FMC_EraseSector()

int FMC_EraseSector ( FLCTL_T *  fmc,
unsigned long  adr 
)

Erase a 4KB Sector in Flash Memory.

This function is used to erase a 4KB flash sector in flash code area.

Parameters
fmcwhere fmc is a flash peripheral.
adrwhere addr is a erase start address.
Return values
0Success.
-1Fail.

◆ FMC_ExitDeepPowerDownMode()

__STATIC_FORCEINLINE void FMC_ExitDeepPowerDownMode ( FLCTL_T *  fmc)

Exit flash deep power down mode.

Parameters
fmcWhere fmc is the base address of fmc peripheral
Returns
None
Note
This function should be put in RAM in case of use Flash may need some time (0.1us ~ 30us for different flash vendor) before it reliably wakes up from deep power down mode.

◆ FMC_ExitEnhanceMode()

void FMC_ExitEnhanceMode ( FLCTL_T *  fmc)

This function is used to exit flash enhanced read mode.

Parameters
fmcWhere fmc is a flash peripheral.
Returns
None

◆ FMC_GetCrc32Sum()

int32_t FMC_GetCrc32Sum ( FLCTL_T *  fmc,
uint32_t  addr,
uint32_t  count,
uint32_t *  chksum 
)

Calculate and read the CRC32 checksum of a specified flash area.

Parameters
[in]fmcWhere fmc is a flash peripheral.
[in]addrStart address of the flash area to be executed CRC32 checksum calculation.
[in]countNumber of bytes to be calculated.
[out]chksumIf success, it will contain the result of CRC32 checksum calculation.
Return values
0Success
-1Invalid parameter.

◆ FMC_GetFlashCodeAreaSize()

uint32_t FMC_GetFlashCodeAreaSize ( FLCTL_T *  fmc)

Get Size of Flash in Bytes.

Parameters
fmcFlash memory controller base
Returns
Size in bytes

◆ FMC_GetFlashJedecId()

void FMC_GetFlashJedecId ( FLCTL_T *  fmc)

This function is used to get flash jedec id,.

Parameters
fmcwhere fmc is a flash peripheral.
Returns
Flash jedec id

◆ FMC_GetFlashUniqueId()

void FMC_GetFlashUniqueId ( FLCTL_T *  fmc)

This function is used to get flash unique id,.

Parameters
fmcwhere fmc is a flash peripheral.
Returns
Flash unique id

◆ FMC_ReadByte()

unsigned char FMC_ReadByte ( FLCTL_T *  fmc,
unsigned int  Addr,
unsigned char  cmd 
)

This function is used to read flash,.

Parameters
fmcwhere fmc is a flash peripheral.
Addrwhere Addr is start address to read
cmdwhere cmd can be CMD_FAST_READ or CMD_NORM_READ
Returns
1byte data

◆ FMC_ReadInfoArea()

int FMC_ReadInfoArea ( FLCTL_T *  fmc,
unsigned int  Addr,
unsigned char  cmd,
unsigned char *  buf,
unsigned int  len 
)

This function is used to read data from the flash 4KB INFO area.

Parameters
fmcwhere fmc is a flash peripheral.
Addrwhere Addr is start address to read, can be 0 ~ 4095
cmdwhere cmd can be CMD_FAST_READ or CMD_NORM_READ
bufwhere buf is a buffer to store read data
lenwhere len is data length of bytes to read
Return values
0read success
-1read fail

◆ FMC_ReadPage()

unsigned char * FMC_ReadPage ( FLCTL_T *  fmc,
unsigned int  Addr,
unsigned char  cmd 
)

This function is used to read a page size (256 bytes) of data from flash.

Parameters
fmcwhere fmc is a flash peripheral.
Addrwhere Addr is start address to read
cmdwhere cmd can be CMD_FAST_READ or CMD_NORM_READ
Returns
Internal Buffer address

◆ FMC_ReadStatusReg()

unsigned char FMC_ReadStatusReg ( FLCTL_T *  fmc,
unsigned char  cmd 
)

This function is used to read status, The Read Status Register can be read at any time.

Parameters
fmcwhere fmc is a flash peripheral.
cmdwhere cmd can be CMD_READ_STATUS_L(return register bit[7:0]) CMD_READ_STATUS_H(return register bit[15:8])
Returns
status value

◆ FMC_ReadStream()

int FMC_ReadStream ( FLCTL_T *  fmc,
unsigned int  Addr,
unsigned char  cmd,
unsigned char *  buf,
unsigned int  len 
)

This function is used to read data stream from flash.

Parameters
fmcwhere fmc is a flash peripheral.
Addrwhere Addr is start address to read
cmdwhere cmd can be CMD_FAST_READ or CMD_NORM_READ
bufwhere buf is a buffer to store read data
lenwhere len is data length of bytes to read
Returns
None

◆ FMC_ReadWord()

unsigned int FMC_ReadWord ( FLCTL_T *  fmc,
unsigned int  Addr,
unsigned char  cmd 
)

This function is used to read flash.

Parameters
fmcwhere fmc is a flash peripheral.
Addrwhere Addr is start address to read
cmdwhere cmd can be CMD_FAST_READ or CMD_NOR_READ
Returns
4byte data

◆ FMC_SetFlashMode()

void FMC_SetFlashMode ( FLCTL_T *  fmc,
uint32_t  mode,
bool  enhance 
)

This function is used to set flash work mode.

Parameters
fmcWhere fmc is a flash peripheral.
modeWhere mode is line mode select. Fmc work type select
enhanceWhether enhanced mode is supported
Returns
None

◆ FMC_SetRdpWaitCount()

void FMC_SetRdpWaitCount ( FLCTL_T *  fmc,
uint32_t  cnt 
)

This function is used to set wait count for release from Deep Power-down mode.

Parameters
fmcWhere fmc is a flash peripheral.
cntWhere cnt is a flash clk count value.
Returns
None

◆ FMC_WriteByte()

void FMC_WriteByte ( FLCTL_T *  fmc,
unsigned int  addr,
unsigned char  data 
)

This function is used to write one byte to flash memory.

Parameters
fmcWhere fmc is a flash peripheral.
addrWhere Addr is start address to write
dataWhere data is data need to program
Returns
None

◆ FMC_WriteEnable()

unsigned char FMC_WriteEnable ( FLCTL_T *  fmc)

This function is used to enable write function,.

Parameters
fmcwhere fmc is a flash peripheral.
Returns
Enable or not

◆ FMC_WriteHalfWord()

void FMC_WriteHalfWord ( FLCTL_T *  fmc,
unsigned int  addr,
unsigned short  data 
)

This function is used to write halfword to flash memory.

Parameters
fmcWhere fmc is a flash peripheral.
addrWhere Addr is start address to write
dataWhere data is data need to program
Returns
None

◆ FMC_WriteInfoArea()

int FMC_WriteInfoArea ( FLCTL_T *  fmc,
unsigned int  Addr,
unsigned char *  buf,
unsigned int  len 
)

This function is used to write data to the flash 4KB INFO area.

Parameters
fmcwhere fmc is a flash peripheral
Addrwhere Addr is start address to write, can be 0 ~ 4095
bufwhere buf is a buffer to store data to write
lenwhere len is data length of bytes to write
Return values
0write success
-1write fail

◆ FMC_WriteStatusReg()

void FMC_WriteStatusReg ( FLCTL_T *  fmc,
unsigned char  ops,
unsigned int  buf 
)

This function is used to write status, The Read Status Register can be read at any time.

Parameters
fmcwhere fmc is a flash peripheral.
opswhere ops can be OPS_WR_STU_REG_ALL OPS_WR_STU_REG_NOR
bufwhere buf is write value
Returns
none

◆ FMC_WriteStream()

int FMC_WriteStream ( FLCTL_T *  fmc,
unsigned int  Addr,
unsigned char *  buf,
unsigned int  len 
)

This function is used to write data stream to flash.

Parameters
fmcwhere fmc is a flash peripheral
Addrwhere Addr is start address to write, can be any valid address
bufwhere buf is a buffer to store data to write
lenwhere len is data length of bytes to write
Returns
None

◆ InitIcache()

void InitIcache ( FLCTL_T *  fmc,
uint32_t  mode 
)

This function is used to init Icache,.

Parameters
fmcWhere fmc is a flash peripheral.
modeWhere mode can be FLASH_X1_MODE FLASH_X2_MODE FLASH_X4_MODE
Returns
None

◆ ProgramPage()

int ProgramPage ( FLCTL_T *  fmc,
unsigned long  adr,
unsigned long  sz,
unsigned char *  buf 
)

Program page in flash memory.

Parameters
fmcWhere fmc is a flash peripheral.
adrBlock start address
szPage size
bufPage data
Return values
0Success
1Fail

◆ Verify()

unsigned long Verify ( FLCTL_T *  fmc,
unsigned long  adr,
unsigned long  sz,
unsigned char *  buf 
)

Verify in flash memory.

Parameters
fmcWhere fmc is a flash peripheral.
adrBlock start address
szData lenth need to verify
bufProgramed data
Note
The buf address should be 4-bytes-alingned.
Returns
Final verify address