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... | |
anonymous enum |
flash command definition
enum Flash_TypeDef |
_attribute_ram_code_ void flash_erase_page | ( | unsigned int | addr | ) |
This function serves to erase a page(256 bytes).
[in] | addr | - the start address of the page needs to erase. |
_attribute_ram_code_ void flash_erase_sector | ( | unsigned long | addr | ) |
This function serves to erase a sector.
[in] | addr | the start address of the sector needs to erase. |
void flash_erase_32kblock | ( | unsigned int | addr | ) |
This function serves to erase a block(32k).
[in] | addr | the start address of the block needs to erase. |
void flash_erase_64kblock | ( | unsigned int | addr | ) |
This function serves to erase a block(64k).
[in] | addr | the start address of the block needs to erase. |
void flash_erase_chip | ( | void | ) |
This function serves to erase a page(256 bytes).
[in] | addr | - the start address of the page needs to erase. |
_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.
[in] | addr | the start address of the page |
[in] | len | the length(in byte) of content needs to write into the page |
[in] | buf | the start address of the content needs to write into |
_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.
[in] | addr | the start address of the page |
[in] | len | the length(in byte) of content needs to read out from the page |
[out] | buf | the start address of the buffer |
unsigned char flash_write_status | ( | unsigned char | data | ) |
This function write the status of flash.
[in] | the | value of status |
unsigned char flash_read_status | ( | void | ) |
This function reads the status of flash.
[in] | none |
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.
[in] | none |
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.
[in] | none |
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.
[in] | idcmd | - different flash vendor have different read-uid command GD/PUYA:0x4B; XTX: 0x5A |
[in] | buf | - store UID of flash |
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.
[out] | flash_mid | - Flash Manufacturer ID |
[out] | flash_uid | - Flash Unique ID |
void flash_lock | ( | Flash_TypeDef | type, |
unsigned short | data | ||
) |
This function serves to protect data for flash.
[in] | type | - flash type include GD,Puya and XTX |
[in] | data | - refer to Driver API Doc. |
void flash_unlock | ( | Flash_TypeDef | type | ) |
This function serves to protect data for flash.
[in] | type | - flash type include GD,Puya and XTX |