Chapter 2. API Reference
Public Members
const struct spi_flash_host_driver_s *driver
Pointer to the implementation function table.
struct spi_flash_host_driver_s
Host driver configuration and context structure.
Public Members
esp_err_t (*dev_config)(spi_flash_host_inst_t *host)
Configure the device-related register before transactions. This saves some time to re-configure those
registers when we send continuously
esp_err_t (*common_command)(spi_flash_host_inst_t *host, spi_flash_trans_t *t)
Send an user-defined spi transaction to the device.
esp_err_t (*read_id)(spi_flash_host_inst_t *host, uint32_t *id)
Read flash ID.
void (*erase_chip)(spi_flash_host_inst_t *host)
Erase whole flash chip.
void (*erase_sector)(spi_flash_host_inst_t *host, uint32_t start_address)
Erase a specific sector by its start address.
void (*erase_block)(spi_flash_host_inst_t *host, uint32_t start_address)
Erase a specific block by its start address.
esp_err_t (*read_status)(spi_flash_host_inst_t *host, uint8_t *out_sr)
Read the status of the flash chip.
esp_err_t (*set_write_protect)(spi_flash_host_inst_t *host, bool wp)
Disable write protection.
void (*program_page)(spi_flash_host_inst_t *host, const void *buffer, uint32_t address, uint32_t
length)
Program a page of the flash. Check max_write_bytes for the maximum allowed writing length.
bool (*supports_direct_write)(spi_flash_host_inst_t *host, const void *p)
Check whether given buffer can be directly used to write
int (*write_data_slicer)(spi_flash_host_inst_t *host, uint32_t address, uint32_t len, uint32_t
*align_addr, uint32_t page_size)
Slicer for write data. The program_page should be called iteratively with the return value of this
function.
Return Length that can be actually written in one program_page call
Parameters
• address: Beginning flash address to write
• len: Length request to write
• align_addr: Output of the aligned address to write to
• page_size: Physical page size of the flash chip
esp_err_t (*read)(spi_flash_host_inst_t *host, void *buffer, uint32_t address, uint32_t read_len)
Read data from the flash. Check max_read_bytes for the maximum allowed reading length.
bool (*supports_direct_read)(spi_flash_host_inst_t *host, const void *p)
Check whether given buffer can be directly used to read
int (*read_data_slicer)(spi_flash_host_inst_t *host, uint32_t address, uint32_t len, uint32_t
*align_addr, uint32_t page_size)
Slicer for read data. The read should be called iteratively with the return value of this function.
Return Length that can be actually read in one read call
Parameters
Espressif Systems 754
Submit Document Feedback
Release v4.4