Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QSPI Flash S25FL1XX Series

Low-level driver for the S25FL1XX Series QSPI Flash controller.

This driver provides access to the main features of the S25FL1XX Series QSPI Flash.

Macros

#define PAGE_SIZE   256
 

Functions

static uint8_t s25fl1xx_check_protected_addr (uint8_t status1, uint32_t addr)
 Check weather the address of addr is protected. More...
 
void s25fl1xx_continous_read_mode_reset (struct qspid_t *qspid)
 Issue 'CContinuous Read Mode' command, the device can return to normal SPI command mode, in which all commands can be accepts. More...
 
uint8_t s25fl1xx_data_protect (struct qspid_t *qspid, bool dir, enum block_size protect_size)
 Protect the contents of the serial flash device. More...
 
uint8_t s25fl1xx_data_unprotect (struct qspid_t *qspid)
 Unprotected the contents of the serial flash device. More...
 
static void s25fl1xx_disable_write (struct qspid_t *qspid)
 Disable write option to serial flash memory. More...
 
void s25fl1xx_enable_wrap (struct qspid_t *qspid, uint8_t byte_align)
 Enables critical writes operation on a serial flash device, such as sector protection, status register, etc. More...
 
static void s25fl1xx_enable_write (struct qspid_t *qspid)
 Enable write option to serial flash memory. More...
 
void s25fl1xx_enter_continous_read_mode (struct qspid_t *qspid)
 Reads data from the specified address on the serial flash. More...
 
uint8_t s25fl1xx_erase_64k_block (struct qspid_t *qspid, uint32_t address)
 Erases the specified 64KB block of the serial firmware dataflash. More...
 
uint8_t s25fl1xx_erase_chip (struct qspid_t *qspid)
 Erases all the content of the memory chip. More...
 
uint8_t s25fl1xx_erase_sector (struct qspid_t *qspid, uint32_t address)
 Erases the specified block of the serial firmware dataflash. More...
 
static void s25fl1xx_exec_command (struct qspid_t *qspid, uint8_t instr, uint32_t *tx_data, uint32_t *rx_data, enum qspi_access read_write, uint32_t size)
 Send command to the serial flash. More...
 
enum status_code s25fl1xx_initialize (Qspi *qspi, struct qspi_config_t *mode_config, uint32_t use_default_config)
 Initialize QSPI serial memory mode. More...
 
static void s25fl1xx_memory_access (struct qspid_t *qspid, uint8_t instr, uint32_t addr, uint32_t *tx_data, uint32_t *rx_data, enum qspi_access read_write, uint32_t size, uint8_t secure)
 Read/write data from serial flash memory. More...
 
uint8_t s25fl1xx_protect (struct qspid_t *qspid)
 Unprotected the contents of the serial flash device. More...
 
uint8_t s25fl1xx_read (struct qspid_t *qspid, uint32_t *data, uint32_t size, uint32_t address)
 Reads data from the specified address on the serial flash. More...
 
uint8_t s25fl1xx_read_dual (struct qspid_t *qspid, uint32_t *data, uint32_t size, uint32_t address)
 Reads data from the specified address on the serial flash. More...
 
uint8_t s25fl1xx_read_dual_io (struct qspid_t *qspid, uint32_t *data, uint32_t size, uint32_t address, uint8_t cont_mode, uint8_t secure)
 Reads data from the specified address on the serial flash. More...
 
uint32_t s25fl1xx_read_jedec_id (struct qspid_t *qspid)
 Reads and returns the serial flash device ID. More...
 
uint8_t s25fl1xx_read_quad (struct qspid_t *qspid, uint32_t *data, uint32_t size, uint32_t address)
 Reads data from the specified address on the serial flash. More...
 
uint8_t s25fl1xx_read_quad_io (struct qspid_t *qspid, uint32_t *data, uint32_t size, uint32_t address, uint8_t cont_mode, uint8_t secure)
 Reads data from the specified address on the serial flash. More...
 
static uint32_t s25fl1xx_read_status (struct qspid_t *qspid)
 Reads and returns the status register of the serial flash. More...
 
static uint8_t s25fl1xx_read_status1 (struct qspid_t *qspid)
 Reads and returns the status register of the serial flash. More...
 
static uint8_t s25fl1xx_read_status2 (struct qspid_t *qspid)
 Reads and returns the status register of the serial flash. More...
 
static uint8_t s25fl1xx_read_status3 (struct qspid_t *qspid)
 Reads and returns the status register of the serial flash. More...
 
void s25fl1xx_set_quad_mode (struct qspid_t *qspid, uint8_t mode)
 Enables critical writes operation on a serial flash device, such as sector protection, status register, etc. More...
 
void s25fl1xx_set_read_latency_control (struct qspid_t *qspid, uint8_t latency)
 Enables critical writes operation on a serial flash device, such as sector protection, status register, etc. More...
 
void s25fl1xx_soft_reset (struct qspid_t *qspid)
 s25fl1d software reset. More...
 
uint8_t s25fl1xx_unprotect (struct qspid_t *qspid)
 Unprotected the control bits of the serial flash device. More...
 
static void s25fl1xx_wait_memory_access_end (struct qspid_t *qspid)
 Wait for transfer to finish calling the SPI driver ISR. More...
 
uint8_t s25fl1xx_write (struct qspid_t *qspid, uint32_t *pdata, uint32_t size, uint32_t address, uint8_t secure)
 Writes data at the specified address on the serial firmware dataflash. More...
 
static void s25fl1xx_write_status (struct qspid_t *qspid, uint8_t *status)
 Writes the given value in the status register of the serial flash device. More...
 
static void s25fl1xx_write_volatile_status (struct qspid_t *qspid, uint8_t *status)
 Writes the given value in the status register of the serial flash device. More...
 

Variables

struct qspi_inst_frame_tdev
 
struct qspi_inst_frame_tmem
 

#define PAGE_SIZE   256

Referenced by s25fl1xx_write().

static uint8_t s25fl1xx_check_protected_addr ( uint8_t  status1,
uint32_t  addr 
)
static

Check weather the address of addr is protected.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
addrAddress to be checked.
Returns
If 0 returned, addr is unprotected, else protected.

References S25FL1XX_BLOCK_PROTECT_Msk, S25FL1XX_SEC_PROTECT_Msk, and S25FL1XX_TOP_BTM_PROTECT_Msk.

Referenced by s25fl1xx_erase_sector().

void s25fl1xx_continous_read_mode_reset ( struct qspid_t qspid)

Issue 'CContinuous Read Mode' command, the device can return to normal SPI command mode, in which all commands can be accepts.

Parameters
qspidPointer to an S25FL1 qspid_t struct.

References QSPI_CMD_ACCESS, S25FL1XX_CONT_MODE_RESET, and s25fl1xx_exec_command().

uint8_t s25fl1xx_data_protect ( struct qspid_t qspid,
bool  dir,
enum block_size  protect_size 
)

Protect the contents of the serial flash device.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
dirData protect direction.
sizeData size to be protect.
Returns
0 if the device has been unprotected; otherwise returns S25FL1D_ERROR_PROTECTED.

References S25FL1XX_ERROR_PROTECTED, s25fl1xx_read_status(), s25fl1xx_read_status1(), s25fl1xx_read_status2(), s25fl1xx_read_status3(), S25FL1XX_SIZE_32K, S25FL1XX_SIZE_64K, s25fl1xx_write_status(), and status.

uint8_t s25fl1xx_data_unprotect ( struct qspid_t qspid)

Unprotected the contents of the serial flash device.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
Returns
0 if the device has been unprotected; otherwise returns S25FL1D_ERROR_PROTECTED.

References S25FL1XX_CHIP_PROTECT_Msk, S25FL1XX_ERROR_PROTECTED, s25fl1xx_read_status(), s25fl1xx_read_status1(), s25fl1xx_read_status2(), s25fl1xx_read_status3(), s25fl1xx_write_status(), and status.

static void s25fl1xx_disable_write ( struct qspid_t qspid)
static

Disable write option to serial flash memory.

Parameters
qspidPointer to an S25FL1 qspid_t struct.

References QSPI_CMD_ACCESS, s25fl1xx_exec_command(), s25fl1xx_read_status1(), S25FL1XX_STATUS_WEL, S25FL1XX_WRITE_DISABLE, and status.

Referenced by s25fl1xx_write(), s25fl1xx_write_status(), and s25fl1xx_write_volatile_status().

void s25fl1xx_enable_wrap ( struct qspid_t qspid,
uint8_t  byte_align 
)

Enables critical writes operation on a serial flash device, such as sector protection, status register, etc.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
byte_alignBurst wrap length to be set.

References qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_dummy_cycles, qspi_inst_frame_t::_qspiinst_frame::bm, qspi_inst_frame_t::inst_frame, QSPI_WRITE_ACCESS, s25fl1xx_exec_command(), s25fl1xx_read_status1(), s25fl1xx_read_status2(), s25fl1xx_read_status3(), S25FL1XX_WRAP_ENABLE, s25fl1xx_write_volatile_status(), and status.

static void s25fl1xx_enable_write ( struct qspid_t qspid)
static
uint8_t s25fl1xx_erase_64k_block ( struct qspid_t qspid,
uint32_t  address 
)

Erases the specified 64KB block of the serial firmware dataflash.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
addressAddress of the block to erase.
Returns
0 if successful; otherwise returns ERROR_PROTECTED if the device is protected or ERROR_BUSY if it is busy executing a command.

References qspi_inst_frame_t::addr, qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_addr_en, qspi_inst_frame_t::_qspiinst_frame::bm, qspi_inst_frame_t::inst_frame, QSPI_CMD_ACCESS, S25FL1XX_BLOCK_ERASE_64K, s25fl1xx_enable_write(), S25FL1XX_ERROR_BUSY, S25FL1XX_ERROR_PROTECTED, s25fl1xx_exec_command(), s25fl1xx_read_status(), S25FL1XX_STATUS_RDYBSY, S25FL1XX_STATUS_RDYBSY_READY, S25FL1XX_STATUS_SWP, S25FL1XX_STATUS_SWP_PROTNONE, s25fl1xx_wait_memory_access_end(), and status.

uint8_t s25fl1xx_erase_chip ( struct qspid_t qspid)

Erases all the content of the memory chip.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
Returns
0 if the device has been unprotected; otherwise returns ERROR_PROTECTED.

References delay_ms, QSPI_CMD_ACCESS, S25FL1XX_CHIP_ERASE_2, S25FL1XX_CHIP_PROTECT_Msk, s25fl1xx_enable_write(), s25fl1xx_exec_command(), s25fl1xx_read_status1(), S25FL1XX_STATUS_RDYBSY, and status.

uint8_t s25fl1xx_erase_sector ( struct qspid_t qspid,
uint32_t  address 
)

Erases the specified block of the serial firmware dataflash.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
addressAddress of the block to erase.
Returns
0 if successful; otherwise returns ERROR_PROTECTED if the device is protected or ERROR_BUSY if it is busy executing a command.

References qspi_inst_frame_t::addr, qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_addr_en, qspi_inst_frame_t::_qspiinst_frame::bm, qspi_inst_frame_t::inst_frame, QSPI_CMD_ACCESS, S25FL1XX_BLOCK_ERASE_4K, S25FL1XX_BLOCK_PROTECT_Msk, s25fl1xx_check_protected_addr(), s25fl1xx_enable_write(), S25FL1XX_ERROR_BUSY, S25FL1XX_ERROR_PROTECTED, s25fl1xx_exec_command(), s25fl1xx_read_status1(), S25FL1XX_STATUS_RDYBSY, S25FL1XX_STATUS_RDYBSY_READY, s25fl1xx_wait_memory_access_end(), and status.

enum status_code s25fl1xx_initialize ( Qspi *  qspi,
struct qspi_config_t mode_config,
uint32_t  use_default_config 
)

Initialize QSPI serial memory mode.

Parameters
qspiPointer to an S25FL1 qspid_t struct.
mode_configConfigure settings to config qspid.
use_default_configConfig QSPI use default configures.
Returns
status S23FL1XX initialize result.

References qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_width, qspi_inst_frame_t::_qspiinst_frame::bm, qspi_inst_frame_t::inst_frame, qspi_get_config_default(), qspi_initialize(), status, and STATUS_OK.

static void s25fl1xx_memory_access ( struct qspid_t qspid,
uint8_t  instr,
uint32_t  addr,
uint32_t *  tx_data,
uint32_t *  rx_data,
enum qspi_access  read_write,
uint32_t  size,
uint8_t  secure 
)
static
uint8_t s25fl1xx_protect ( struct qspid_t qspid)

Unprotected the contents of the serial flash device.

Parameters
qspidPointer to an S25FL1 driver instance.
Returns
0 if the device has been protected; otherwise returns S25FL1D_ERROR_PROTECTED.

References S25FL1XX_ERROR_PROTECTED, s25fl1xx_read_status(), s25fl1xx_read_status1(), s25fl1xx_read_status2(), s25fl1xx_read_status3(), S25FL1XX_STATUS_SPRL, S25FL1XX_STATUS_SPRL_LOCKED, S25FL1XX_STATUS_SWP, s25fl1xx_write_status(), and status.

uint8_t s25fl1xx_read ( struct qspid_t qspid,
uint32_t *  data,
uint32_t  size,
uint32_t  address 
)

Reads data from the specified address on the serial flash.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
dataData buffer.
sizeNumber of bytes to read.
addressRead address.
Returns
0 if successful; otherwise, fail.

References qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_dummy_cycles, qspi_inst_frame_t::_qspiinst_frame::bm, qspi_inst_frame_t::inst_frame, QSPI_READ_ACCESS, s25fl1xx_memory_access(), S25FL1XX_READ_ARRAY, and secure().

uint8_t s25fl1xx_read_dual ( struct qspid_t qspid,
uint32_t *  data,
uint32_t  size,
uint32_t  address 
)

Reads data from the specified address on the serial flash.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
dataData buffer.
sizeNumber of bytes to read.
addressRead address.
Returns
0 if successful; otherwise, fail.

References qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_dummy_cycles, qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_width, qspi_inst_frame_t::_qspiinst_frame::bm, qspi_inst_frame_t::inst_frame, QSPI_READ_ACCESS, s25fl1xx_memory_access(), S25FL1XX_READ_ARRAY_DUAL, and secure().

uint8_t s25fl1xx_read_dual_io ( struct qspid_t qspid,
uint32_t *  data,
uint32_t  size,
uint32_t  address,
uint8_t  cont_mode,
uint8_t  secure 
)
uint32_t s25fl1xx_read_jedec_id ( struct qspid_t qspid)

Reads and returns the serial flash device ID.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
Returns
Jedec id read from chip.

References QSPI_READ_ACCESS, s25fl1xx_exec_command(), and S25FL1XX_READ_JEDEC_ID.

uint8_t s25fl1xx_read_quad ( struct qspid_t qspid,
uint32_t *  data,
uint32_t  size,
uint32_t  address 
)

Reads data from the specified address on the serial flash.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
dataData buffer.
sizeNumber of bytes to read.
addressRead address.
Returns
0 if successful; otherwise, fail.

References qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_dummy_cycles, qspi_inst_frame_t::_qspiinst_frame::_qspiinst_frame_bitmap::b_width, qspi_inst_frame_t::_qspiinst_frame::bm, qspi_inst_frame_t::inst_frame, QSPI_READ_ACCESS, s25fl1xx_memory_access(), S25FL1XX_READ_ARRAY_QUAD, and secure().

uint8_t s25fl1xx_read_quad_io ( struct qspid_t qspid,
uint32_t *  data,
uint32_t  size,
uint32_t  address,
uint8_t  cont_mode,
uint8_t  secure 
)
static uint32_t s25fl1xx_read_status ( struct qspid_t qspid)
static

Reads and returns the status register of the serial flash.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
Returns
QSPI status1/2/3

References s25fl1xx_read_status1(), s25fl1xx_read_status2(), s25fl1xx_read_status3(), and status.

Referenced by s25fl1xx_data_protect(), s25fl1xx_data_unprotect(), s25fl1xx_erase_64k_block(), and s25fl1xx_protect().

static uint8_t s25fl1xx_read_status2 ( struct qspid_t qspid)
static

Reads and returns the status register of the serial flash.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
Returns
QSPI status2

References QSPI_READ_ACCESS, s25fl1xx_exec_command(), S25FL1XX_READ_STATUS_2, and status.

Referenced by s25fl1xx_data_protect(), s25fl1xx_data_unprotect(), s25fl1xx_enable_wrap(), s25fl1xx_protect(), s25fl1xx_read_status(), s25fl1xx_set_quad_mode(), s25fl1xx_set_read_latency_control(), and s25fl1xx_unprotect().

static uint8_t s25fl1xx_read_status3 ( struct qspid_t qspid)
static

Reads and returns the status register of the serial flash.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
Returns
QSPI status3

References QSPI_READ_ACCESS, s25fl1xx_exec_command(), S25FL1XX_READ_STATUS_3, and status.

Referenced by s25fl1xx_data_protect(), s25fl1xx_data_unprotect(), s25fl1xx_enable_wrap(), s25fl1xx_protect(), s25fl1xx_read_status(), s25fl1xx_set_quad_mode(), s25fl1xx_set_read_latency_control(), and s25fl1xx_unprotect().

void s25fl1xx_set_quad_mode ( struct qspid_t qspid,
uint8_t  mode 
)

Enables critical writes operation on a serial flash device, such as sector protection, status register, etc.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
modeMode to be set.

References delay_ms, s25fl1xx_read_status1(), s25fl1xx_read_status2(), s25fl1xx_read_status3(), S25FL1XX_STATUS_QUAD_ENABLE, s25fl1xx_write_status(), and status.

void s25fl1xx_set_read_latency_control ( struct qspid_t qspid,
uint8_t  latency 
)

Enables critical writes operation on a serial flash device, such as sector protection, status register, etc.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
latencyLatency control.

References qspi_buffer_t::data_tx, delay_ms, qspid_t::qspi_buffer, s25fl1xx_read_status1(), s25fl1xx_read_status2(), s25fl1xx_read_status3(), S25FL1XX_STATUS_LATENCY_CTRL, s25fl1xx_write_volatile_status(), and status.

void s25fl1xx_soft_reset ( struct qspid_t qspid)

s25fl1d software reset.

Parameters
qspidPointer to an S25FL1 qspid_t struct.

References QSPI_CMD_ACCESS, s25fl1xx_exec_command(), S25FL1XX_SOFT_RESET, and S25FL1XX_SOFT_RESET_ENABLE.

uint8_t s25fl1xx_unprotect ( struct qspid_t qspid)

Unprotected the control bits of the serial flash device.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
Returns
0 if the device has been unprotected; otherwise returns S25FL1D_ERROR_PROTECTED.
S25FL1 protection status.

References S25FL1XX_ERROR_PROTECTED, s25fl1xx_read_status1(), s25fl1xx_read_status2(), s25fl1xx_read_status3(), S25FL1XX_STATUS_SPRL, S25FL1XX_STATUS_SPRL_LOCKED, S25FL1XX_STATUS_SWP, S25FL1XX_STATUS_SWP_PROTNONE, s25fl1xx_write_status(), and status.

static void s25fl1xx_wait_memory_access_end ( struct qspid_t qspid)
static

Wait for transfer to finish calling the SPI driver ISR.

(interrupts are disabled)

Parameters
qspidPointer to an S25FL1 qspid_t struct.

References s25fl1xx_read_status1(), and S25FL1XX_STATUS_RDYBSY.

Referenced by s25fl1xx_erase_64k_block(), s25fl1xx_erase_sector(), and s25fl1xx_write().

uint8_t s25fl1xx_write ( struct qspid_t qspid,
uint32_t *  pdata,
uint32_t  size,
uint32_t  address,
uint8_t  secure 
)

Writes data at the specified address on the serial firmware dataflash.

The page(s) to program must have been erased prior to writing. This function handles page boundary crossing automatically.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
pDataData buffer.
sizeNumber of bytes in buffer.
addressWrite address.
secureEnable or disable scramble on QSPI.
Returns
0 if successful; otherwise, returns ERROR_PROGRAM is there has been an error during the data programming.

Size / page_zize

If less than page size

Multiple page

References addr, PAGE_SIZE, QSPI_WRITE_ACCESS, S25FL1XX_BYTE_PAGE_PROGRAM, s25fl1xx_disable_write(), s25fl1xx_enable_write(), s25fl1xx_memory_access(), and s25fl1xx_wait_memory_access_end().

static void s25fl1xx_write_status ( struct qspid_t qspid,
uint8_t *  status 
)
static

Writes the given value in the status register of the serial flash device.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
statusStatus to write.

References QSPI_WRITE_ACCESS, s25fl1xx_disable_write(), s25fl1xx_enable_write(), s25fl1xx_exec_command(), and S25FL1XX_WRITE_STATUS.

Referenced by s25fl1xx_data_protect(), s25fl1xx_data_unprotect(), s25fl1xx_protect(), s25fl1xx_set_quad_mode(), and s25fl1xx_unprotect().

static void s25fl1xx_write_volatile_status ( struct qspid_t qspid,
uint8_t *  status 
)
static

Writes the given value in the status register of the serial flash device.

Parameters
qspidPointer to an S25FL1 qspid_t struct.
statusStatus to write.

References QSPI_CMD_ACCESS, QSPI_WRITE_ACCESS, s25fl1xx_disable_write(), s25fl1xx_exec_command(), and S25FL1XX_WRITE_STATUS.

Referenced by s25fl1xx_enable_wrap(), and s25fl1xx_set_read_latency_control().