flash.h File Reference

Go to the source code of this file.

Enumerations

enum  {
  FLASH_WRITE_STATUS_CMD = 0x01, FLASH_WRITE_CMD = 0x02, FLASH_READ_CMD = 0x03, FLASH_WRITE_DISABLE_CMD = 0x04,
  FLASH_READ_STATUS_CMD = 0x05, FLASH_WRITE_ENABLE_CMD = 0x06, FLASH_SECT_ERASE_CMD = 0x20, FLASH_GD_PUYA_READ_UID_CMD = 0x4B,
  FLASH_32KBLK_ERASE_CMD = 0x52, FLASH_XTX_READ_UID_CMD = 0x5A, FLASH_CHIP_ERASE_CMD = 0x60, FLASH_PAGE_ERASE_CMD = 0x81,
  FLASH_64KBLK_ERASE_CMD = 0xD8, FLASH_POWER_DOWN = 0xB9, FLASH_POWER_DOWN_RELEASE = 0xAB, FLASH_GET_JEDEC_ID = 0x9F
}
 flash command definition More...
 
enum  Flash_TypeDef { FLASH_TYPE_GD = 0, FLASH_TYPE_XTX, FLASH_TYPE_PUYA }
 flash type definition More...
 

Functions

_attribute_ram_code_ void flash_erase_page (unsigned int addr)
 This function serves to erase a page(256 bytes). More...
 
_attribute_ram_code_ void flash_erase_sector (unsigned long addr)
 This function serves to erase a sector. More...
 
void flash_erase_32kblock (unsigned int addr)
 This function serves to erase a block(32k). More...
 
void flash_erase_64kblock (unsigned int addr)
 This function serves to erase a block(64k). More...
 
void flash_erase_chip (void)
 This function serves to erase a page(256 bytes). More...
 
_attribute_ram_code_ void flash_write_page (unsigned long addr, unsigned long len, unsigned char *buf)
 This function writes the buffer's content to a page. More...
 
_attribute_ram_code_ void flash_read_page (unsigned long addr, unsigned long len, unsigned char *buf)
 This function reads the content from a page to the buf. More...
 
unsigned char flash_write_status (unsigned char data)
 This function write the status of flash. More...
 
unsigned char flash_read_status (void)
 This function reads the status of flash. More...
 
void flash_deep_powerdown (void)
 Deep Power Down mode to put the device in the lowest consumption mode it can be used as an extra software protection mechanism,while the device is not in active use,since in the mode, all write,Program and Erase commands are ignored,except the Release from Deep Power-Down and Read Device ID(RDI) command.This release the device from this mode. More...
 
void flash_release_deep_powerdown (void)
 The Release from Power-Down or High Performance Mode/Device ID command is a Multi-purpose command.it can be used to release the device from the power-Down State or High Performance Mode or obtain the devices electronic identification (ID)number.Release from Power-Down will take the time duration of tRES1 before the device will resume normal operation and other command are accepted.The CS# pin must remain high during the tRES1(8us) time duration. More...
 
void flash_read_mid (unsigned char *buf)
 
void flash_read_uid (unsigned char idcmd, unsigned char *buf)
 This function serves to read UID of flash. More...
 
int flash_read_mid_uid_with_check (unsigned int *flash_mid, unsigned char *flash_uid)
 This function serves to read flash mid and uid,and check the correctness of mid and uid. More...
 
void flash_lock (Flash_TypeDef type, unsigned short data)
 This function serves to protect data for flash. More...
 
void flash_unlock (Flash_TypeDef type)
 This function serves to protect data for flash. More...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

flash command definition

Enumerator
FLASH_WRITE_STATUS_CMD 
FLASH_WRITE_CMD 
FLASH_READ_CMD 
FLASH_WRITE_DISABLE_CMD 
FLASH_READ_STATUS_CMD 
FLASH_WRITE_ENABLE_CMD 
FLASH_SECT_ERASE_CMD 
FLASH_GD_PUYA_READ_UID_CMD 
FLASH_32KBLK_ERASE_CMD 
FLASH_XTX_READ_UID_CMD 
FLASH_CHIP_ERASE_CMD 
FLASH_PAGE_ERASE_CMD 
FLASH_64KBLK_ERASE_CMD 
FLASH_POWER_DOWN 
FLASH_POWER_DOWN_RELEASE 
FLASH_GET_JEDEC_ID 

◆ Flash_TypeDef

flash type definition

Enumerator
FLASH_TYPE_GD 
FLASH_TYPE_XTX 
FLASH_TYPE_PUYA 

Function Documentation

◆ flash_erase_page()

_attribute_ram_code_ void flash_erase_page ( unsigned int  addr)

This function serves to erase a page(256 bytes).

Parameters
[in]addr- the start address of the page needs to erase.
Returns
none
Note
only 8359 support

◆ flash_erase_sector()

_attribute_ram_code_ void flash_erase_sector ( unsigned long  addr)

This function serves to erase a sector.

Parameters
[in]addrthe start address of the sector needs to erase.
Returns
none

◆ flash_erase_32kblock()

void flash_erase_32kblock ( unsigned int  addr)

This function serves to erase a block(32k).

Parameters
[in]addrthe start address of the block needs to erase.
Returns
none

◆ flash_erase_64kblock()

void flash_erase_64kblock ( unsigned int  addr)

This function serves to erase a block(64k).

Parameters
[in]addrthe start address of the block needs to erase.
Returns
none

◆ flash_erase_chip()

void flash_erase_chip ( void  )

This function serves to erase a page(256 bytes).

Parameters
[in]addr- the start address of the page needs to erase.
Returns
none

◆ flash_write_page()

_attribute_ram_code_ void flash_write_page ( unsigned long  addr,
unsigned long  len,
unsigned char *  buf 
)

This function writes the buffer's content to a page.

Parameters
[in]addrthe start address of the page
[in]lenthe length(in byte) of content needs to write into the page
[in]bufthe start address of the content needs to write into
Returns
none

◆ flash_read_page()

_attribute_ram_code_ void flash_read_page ( unsigned long  addr,
unsigned long  len,
unsigned char *  buf 
)

This function reads the content from a page to the buf.

Parameters
[in]addrthe start address of the page
[in]lenthe length(in byte) of content needs to read out from the page
[out]bufthe start address of the buffer
Returns
none

◆ flash_write_status()

unsigned char flash_write_status ( unsigned char  data)

This function write the status of flash.

Parameters
[in]thevalue of status
Returns
status

◆ flash_read_status()

unsigned char flash_read_status ( void  )

This function reads the status of flash.

Parameters
[in]none
Returns
none

◆ flash_deep_powerdown()

void flash_deep_powerdown ( void  )

Deep Power Down mode to put the device in the lowest consumption mode it can be used as an extra software protection mechanism,while the device is not in active use,since in the mode, all write,Program and Erase commands are ignored,except the Release from Deep Power-Down and Read Device ID(RDI) command.This release the device from this mode.

Parameters
[in]none
Returns
none.

◆ flash_release_deep_powerdown()

void flash_release_deep_powerdown ( void  )

The Release from Power-Down or High Performance Mode/Device ID command is a Multi-purpose command.it can be used to release the device from the power-Down State or High Performance Mode or obtain the devices electronic identification (ID)number.Release from Power-Down will take the time duration of tRES1 before the device will resume normal operation and other command are accepted.The CS# pin must remain high during the tRES1(8us) time duration.

Parameters
[in]none
Returns
none.

◆ flash_read_mid()

void flash_read_mid ( unsigned char *  buf)

◆ flash_read_uid()

void flash_read_uid ( unsigned char  idcmd,
unsigned char *  buf 
)

This function serves to read UID of flash.

Parameters
[in]idcmd- different flash vendor have different read-uid command GD/PUYA:0x4B; XTX: 0x5A
[in]buf- store UID of flash
Returns
none.

◆ flash_read_mid_uid_with_check()

int flash_read_mid_uid_with_check ( unsigned int *  flash_mid,
unsigned char *  flash_uid 
)

This function serves to read flash mid and uid,and check the correctness of mid and uid.

Parameters
[out]flash_mid- Flash Manufacturer ID
[out]flash_uid- Flash Unique ID
Returns
0:error 1:ok

◆ flash_lock()

void flash_lock ( Flash_TypeDef  type,
unsigned short  data 
)

This function serves to protect data for flash.

Parameters
[in]type- flash type include GD,Puya and XTX
[in]data- refer to Driver API Doc.
Returns
none

◆ flash_unlock()

void flash_unlock ( Flash_TypeDef  type)

This function serves to protect data for flash.

Parameters
[in]type- flash type include GD,Puya and XTX
Returns
none