See Quickstart guide for AT25DFx component..
This is a driver for the AT25DFx SerialFlash memories. It provides functions for initialization, read and write operations.
This driver depends on the following modules:
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the AT25DFx SerialFlash component driver.. | |
Quick Start Guide(s) | |
In this section you can find a list of all Quick Start guides related to the AT25DFx SerialFlash component driver.. | |
Data Structures | |
struct | at25_cmd |
SerialFlash transfers request prepared by the AT25 driver. More... | |
Macros | |
#define | AT25DFX_BLOCK_ERASE_CMD AT25_BLOCK_ERASE_64K |
AT25 block erase command. More... | |
#define | AT25DFX_BLOCK_SIZE (64*1024) |
AT25 block size. More... | |
#define | AT25DFX_DEV_ID 0x0001441F |
AT25 device ID. More... | |
#define | AT25DFX_PAGE_SIZE 256 |
The page size of AT25DF series is always 256. More... | |
#define | AT25DFX_SIZE (512 * 1024) |
AT25 total size. More... | |
Typedefs | |
typedef struct at25_cmd | at25_cmd_t |
SerialFlash transfers request prepared by the AT25 driver. More... | |
Functions | |
static at25_status_t | at25dfx_enable_write (void) |
Enable critical write operation on a SerialFlash device, such as sector protection, status register, etc. More... | |
at25_status_t | at25dfx_erase_block (uint32_t address) |
Erase the specified block of the SerialFlash. More... | |
at25_status_t | at25dfx_erase_chip (void) |
Erase all the content of the memory chip. More... | |
at25_status_t | at25dfx_initialize (void) |
Initialize the SerialFlash. More... | |
at25_status_t | at25dfx_mem_check (void) |
Check if the SerialFlash is valid. More... | |
at25_status_t | at25dfx_protect_chip (uint8_t protect_type) |
Protect the SerialFlash device. More... | |
at25_status_t | at25dfx_protect_sector (uint32_t address, uint8_t protect_type) |
Protect/unprotect the specific sector. More... | |
at25_status_t | at25dfx_read (uint8_t *data, uint16_t size, uint32_t address) |
Read data from the specified address on the SerialFlash. More... | |
static at25_status_t | at25dfx_read_dev_id (uint32_t *dev_id) |
Read and return the SerialFlash device ID. More... | |
at25_status_t | at25dfx_read_sector_protect_status (uint32_t address) |
Read sector protection status. More... | |
at25_status_t | at25dfx_read_status (uint8_t *status) |
Read and return the status register of the SerialFlash. More... | |
static at25_status_t | at25dfx_send_command (at25_cmd_t *at25cmd) |
Start an AT25DFx command transfer. More... | |
void | at25dfx_set_mem_active (uint8_t cs) |
Select the SerialFlash by the corresponding chip select. More... | |
static at25_status_t | at25dfx_wait_ready (void) |
Wait for the SerialFlash device to be ready to accept new commands. More... | |
at25_status_t | at25dfx_write (uint8_t *data, uint16_t size, uint32_t address) |
Write data at the specified address on the serial firmware SerialFlash. More... | |
at25_status_t | at25dfx_write_status (uint8_t status) |
Write the given value in the status register of the SerialFlash device. More... | |
Variables | |
static uint8_t | active_sf_cs = AT25DFX_MEM_ID |
Activated SerialFlash chip select, default to device 1. More... | |
#define AT25DFX_BLOCK_ERASE_CMD AT25_BLOCK_ERASE_64K |
AT25 block erase command.
Referenced by at25dfx_erase_block().
#define AT25DFX_BLOCK_SIZE (64*1024) |
AT25 block size.
#define AT25DFX_DEV_ID 0x0001441F |
AT25 device ID.
Referenced by at25dfx_mem_check().
#define AT25DFX_PAGE_SIZE 256 |
The page size of AT25DF series is always 256.
Referenced by at25dfx_write().
#define AT25DFX_SIZE (512 * 1024) |
AT25 total size.
Referenced by at25dfx_erase_block(), at25dfx_read(), and at25dfx_write().
typedef struct at25_cmd at25_cmd_t |
SerialFlash transfers request prepared by the AT25 driver.
This structure is sent to the at25_send_command function which is application dependent. This function transforms at25_cmd_t request into api command request.
|
static |
Enable critical write operation on a SerialFlash device, such as sector protection, status register, etc.
References at25_cmd::address, AT25_WRITE_ENABLE, at25dfx_send_command(), at25_cmd::cmd, at25_cmd::cmd_size, at25_cmd::data, at25_cmd::data_size, and NULL.
Referenced by at25dfx_erase_block(), at25dfx_erase_chip(), at25dfx_protect_chip(), at25dfx_protect_sector(), and at25dfx_write().
at25_status_t at25dfx_erase_block | ( | uint32_t | address | ) |
Erase the specified block of the SerialFlash.
address | Address of the block to erase. |
References at25_cmd::address, AT25_ERROR, AT25_ERROR_BUSY, AT25_ERROR_PROTECTED, AT25_STATUS_RDYBSY, AT25_STATUS_RDYBSY_READY, AT25_STATUS_SWP, AT25_STATUS_SWP_PROTNONE, AT25_SUCCESS, AT25DFX_BLOCK_ERASE_CMD, at25dfx_enable_write(), at25dfx_read_status(), at25dfx_send_command(), AT25DFX_SIZE, at25dfx_wait_ready(), at25_cmd::cmd, at25_cmd::cmd_size, at25_cmd::data, at25_cmd::data_size, and NULL.
Referenced by main(), and run_test_at25dfx_data_access().
at25_status_t at25dfx_erase_chip | ( | void | ) |
Erase all the content of the memory chip.
References at25_cmd::address, AT25_CHIP_ERASE_2, AT25_ERROR_PROTECTED, AT25_STATUS_SWP, AT25_STATUS_SWP_PROTNONE, AT25_SUCCESS, at25dfx_enable_write(), at25dfx_read_status(), at25dfx_send_command(), at25dfx_wait_ready(), at25_cmd::cmd, at25_cmd::cmd_size, at25_cmd::data, at25_cmd::data_size, and NULL.
at25_status_t at25dfx_initialize | ( | void | ) |
Initialize the SerialFlash.
References AT25_SUCCESS, and at25dfx_spi_init().
Referenced by main(), and run_test_at25dfx_init().
at25_status_t at25dfx_mem_check | ( | void | ) |
Check if the SerialFlash is valid.
It will read the device id from the device and compare the value set in the configuration file.
References AT25_ERROR_NOT_FOUND, AT25_SUCCESS, AT25DFX_DEV_ID, and at25dfx_read_dev_id().
Referenced by main(), and run_test_at25dfx_init().
at25_status_t at25dfx_protect_chip | ( | uint8_t | protect_type | ) |
Protect the SerialFlash device.
protect_type | AT25_TYPE_PROTECT to protect the sector, AT25_TYPE_UNPROTECT to unprotect. |
References AT25_ERROR, AT25_GLOBAL_PROTECT_VALUE, AT25_STATUS_SPRL, AT25_STATUS_SWP, AT25_SUCCESS, AT25_TYPE_PROTECT, at25dfx_enable_write(), at25dfx_read_status(), and at25dfx_write_status().
Referenced by main(), run_test_at25dfx_data_access(), and run_test_at25dfx_protect().
at25_status_t at25dfx_protect_sector | ( | uint32_t | address, |
uint8_t | protect_type | ||
) |
Protect/unprotect the specific sector.
address | Address to be protected. |
protect_type | AT25_TYPE_PROTECT to protect the sector, AT25_TYPE_UNPROTECT to unprotect. |
References at25_cmd::address, AT25_PROTECT_SECTOR, AT25_TYPE_PROTECT, AT25_UNPROTECT_SECTOR, at25dfx_enable_write(), at25dfx_send_command(), at25_cmd::cmd, at25_cmd::cmd_size, at25_cmd::data, at25_cmd::data_size, and NULL.
Referenced by run_test_at25dfx_protect().
at25_status_t at25dfx_read | ( | uint8_t * | data, |
uint16_t | size, | ||
uint32_t | address | ||
) |
Read data from the specified address on the SerialFlash.
data | Data buffer. |
size | Number of bytes to read. |
address | Read address. |
References at25_cmd::address, AT25_ERROR, AT25_READ_ARRAY_LF, at25dfx_send_command(), AT25DFX_SIZE, at25_cmd::cmd, at25_cmd::cmd_size, data, at25_cmd::data, and at25_cmd::data_size.
Referenced by main(), and run_test_at25dfx_data_access().
|
static |
Read and return the SerialFlash device ID.
p_dev_id | Pointer to the data of the device ID. |
References at25_cmd::address, AT25_READ_JEDEC_ID, at25dfx_send_command(), at25_cmd::cmd, at25_cmd::cmd_size, at25_cmd::data, and at25_cmd::data_size.
Referenced by at25dfx_mem_check().
at25_status_t at25dfx_read_sector_protect_status | ( | uint32_t | address | ) |
Read sector protection status.
ul_address | Sector address to be read. |
References at25_cmd::address, AT25_ERROR, AT25_READ_SECTOR_PROT, AT25_SECTOR_PROTECTED, AT25_SECTOR_PROTECTED_VALUE, AT25_SECTOR_UNPROTECTED, AT25_SECTOR_UNPROTECTED_VALUE, at25dfx_send_command(), at25_cmd::cmd, at25_cmd::cmd_size, at25_cmd::data, and at25_cmd::data_size.
Referenced by run_test_at25dfx_protect().
at25_status_t at25dfx_read_status | ( | uint8_t * | status | ) |
Read and return the status register of the SerialFlash.
status | Pointer to an AT25 device status. |
References at25_cmd::address, AT25_READ_STATUS, at25dfx_send_command(), at25_cmd::cmd, at25_cmd::cmd_size, at25_cmd::data, at25_cmd::data_size, and status.
Referenced by at25dfx_erase_block(), at25dfx_erase_chip(), at25dfx_protect_chip(), at25dfx_wait_ready(), at25dfx_write(), and run_test_at25dfx_protect().
|
static |
Start an AT25DFx command transfer.
This is a non blocking function. It will return as soon as the transfer is started.
pat25_cmd_t | Pointer to the command transfer request. |
References at25_cmd::address, AT25_BYTE_PAGE_PROGRAM, AT25_ERROR_SPI, AT25_SUCCESS, AT25_WRITE_STATUS, at25dfx_spi_deselect_device(), at25dfx_spi_read_packet(), at25dfx_spi_select_device(), at25dfx_spi_write_packet(), at25_cmd::cmd, at25_cmd::cmd_size, at25_cmd::data, at25_cmd::data_size, and STATUS_OK.
Referenced by at25dfx_enable_write(), at25dfx_erase_block(), at25dfx_erase_chip(), at25dfx_protect_sector(), at25dfx_read(), at25dfx_read_dev_id(), at25dfx_read_sector_protect_status(), at25dfx_read_status(), at25dfx_write(), and at25dfx_write_status().
void at25dfx_set_mem_active | ( | uint8_t | cs | ) |
Select the SerialFlash by the corresponding chip select.
cs | SerialFlash chip select. |
Referenced by main(), and run_test_at25dfx_init().
|
static |
Wait for the SerialFlash device to be ready to accept new commands.
References AT25_STATUS_RDYBSY, AT25_STATUS_RDYBSY_READY, AT25_SUCCESS, and at25dfx_read_status().
Referenced by at25dfx_erase_block(), at25dfx_erase_chip(), and at25dfx_write().
at25_status_t at25dfx_write | ( | uint8_t * | data, |
uint16_t | size, | ||
uint32_t | address | ||
) |
Write data at the specified address on the serial firmware SerialFlash.
The page(s) to program must have been erased prior to writing. This function handles page boundary crossing automatically.
data | Data buffer. |
size | Number of bytes in buffer. |
address | Write address. |
References at25_cmd::address, AT25_BYTE_PAGE_PROGRAM, AT25_ERROR, AT25_ERROR_WRITE, AT25_STATUS_EPE, AT25_STATUS_EPE_ERROR, AT25_SUCCESS, at25dfx_enable_write(), AT25DFX_PAGE_SIZE, at25dfx_read_status(), at25dfx_send_command(), AT25DFX_SIZE, at25dfx_wait_ready(), at25_cmd::cmd, at25_cmd::cmd_size, data, at25_cmd::data, at25_cmd::data_size, and Min.
Referenced by main(), and run_test_at25dfx_data_access().
at25_status_t at25dfx_write_status | ( | uint8_t | status | ) |
Write the given value in the status register of the SerialFlash device.
status | Status to write. |
References at25_cmd::address, AT25_WRITE_STATUS, at25dfx_send_command(), at25_cmd::cmd, at25_cmd::cmd_size, at25_cmd::data, and at25_cmd::data_size.
Referenced by at25dfx_protect_chip().
|
static |
Activated SerialFlash chip select, default to device 1.