Quad Serial Peripheral Interface (QSPI) peripheral driver. More...
Modules | |
QSPI peripheral driver configuration | |
Data Structures | |
struct | nrfx_qspi_config_t |
QSPI driver instance configuration structure. More... | |
struct | nrfx_qspi_evt_ext_erase_t |
QSPI driver erase event data. More... | |
struct | nrfx_qspi_evt_ext_xfer_t |
QSPI driver transfer event data. More... | |
struct | nrfx_qspi_evt_ext_t |
QSPI driver extended event structure. More... | |
Macros | |
#define | NRFX_QSPI_DEFAULT_CONFIG(_pin_sck, _pin_csn, _pin_io0, _pin_io1, _pin_io2, _pin_io3) |
QSPI instance default configuration. More... | |
#define | NRFX_QSPI_DEFAULT_CINSTR(opc, len) |
QSPI custom instruction helper with the default configuration. More... | |
Typedefs | |
typedef void(* | nrfx_qspi_handler_t) (nrfx_qspi_evt_t event, void *p_context) |
QSPI driver event handler type. | |
Enumerations | |
enum | nrfx_qspi_evt_t { NRFX_QSPI_EVENT_DONE } |
QSPI master driver event types, passed to the handler routine provided during initialization. More... | |
enum | nrfx_qspi_evt_ext_type_t { NRFX_QSPI_EVENT_NONE , NRFX_QSPI_EVENT_WRITE_DONE , NRFX_QSPI_EVENT_READ_DONE , NRFX_QSPI_EVENT_ERASE_DONE } |
QSPI master driver extended event types, obtained using nrfx_qspi_event_extended_get() function. More... | |
Functions | |
nrfx_err_t | nrfx_qspi_init (nrfx_qspi_config_t const *p_config, nrfx_qspi_handler_t handler, void *p_context) |
Function for initializing the QSPI driver instance. More... | |
void | nrfx_qspi_uninit (void) |
Function for uninitializing the QSPI driver instance. | |
nrfx_err_t | nrfx_qspi_read (void *p_rx_buffer, size_t rx_buffer_length, uint32_t src_address) |
Function for reading data from the QSPI memory. More... | |
nrfx_err_t | nrfx_qspi_write (void const *p_tx_buffer, size_t tx_buffer_length, uint32_t dst_address) |
Function for writing data to QSPI memory. More... | |
nrfx_err_t | nrfx_qspi_erase (nrf_qspi_erase_len_t length, uint32_t start_address) |
Function for starting erasing of one memory block - 4KB, 64KB, or the whole chip. More... | |
nrfx_err_t | nrfx_qspi_chip_erase (void) |
Function for starting an erase operation of the whole chip. More... | |
nrfx_qspi_evt_ext_t const * | nrfx_qspi_event_extended_get (void) |
Function for getting the extended event associated with finished operation. More... | |
bool | nrfx_qspi_xfer_buffered_check (void) |
Function for checking whether any write or read data transfer is buffered. More... | |
nrfx_err_t | nrfx_qspi_mem_busy_check (void) |
Function for getting the current driver status and status byte of memory device with testing WIP (write in progress) bit. More... | |
nrfx_err_t | nrfx_qspi_cinstr_xfer (nrf_qspi_cinstr_conf_t const *p_config, void const *p_tx_buffer, void *p_rx_buffer) |
Function for sending operation code, sending data, and receiving data from the memory device. More... | |
nrfx_err_t | nrfx_qspi_cinstr_quick_send (uint8_t opcode, nrf_qspi_cinstr_len_t length, void const *p_tx_buffer) |
Function for sending operation code and data to the memory device with simpler configuration. More... | |
nrfx_err_t | nrfx_qspi_lfm_start (nrf_qspi_cinstr_conf_t const *p_config) |
Function for starting the custom instruction long frame mode. More... | |
nrfx_err_t | nrfx_qspi_lfm_xfer (void const *p_tx_buffer, void *p_rx_buffer, size_t transfer_length, bool finalize) |
Function for sending and receiving data in the custom instruction long frame mode. More... | |
Quad Serial Peripheral Interface (QSPI) peripheral driver.
#define NRFX_QSPI_DEFAULT_CINSTR | ( | opc, | |
len | |||
) |
QSPI custom instruction helper with the default configuration.
#define NRFX_QSPI_DEFAULT_CONFIG | ( | _pin_sck, | |
_pin_csn, | |||
_pin_io0, | |||
_pin_io1, | |||
_pin_io2, | |||
_pin_io3 | |||
) |
QSPI instance default configuration.
This configuration sets up QSPI with the following options:
[in] | _pin_sck | Pin for clock signal. |
[in] | _pin_csn | Pin for chip select signal. |
[in] | _pin_io0 | Pin 0 for I/O data. |
[in] | _pin_io1 | Pin 1 for I/O data. |
[in] | _pin_io2 | Pin 2 for I/O data. |
[in] | _pin_io3 | Pin 3 for I/O data. |
QSPI master driver extended event types, obtained using nrfx_qspi_event_extended_get() function.
Enumerator | |
---|---|
NRFX_QSPI_EVENT_NONE | No event occurence. |
NRFX_QSPI_EVENT_WRITE_DONE | Write done. |
NRFX_QSPI_EVENT_READ_DONE | Read done. |
NRFX_QSPI_EVENT_ERASE_DONE | Erase done. |
enum nrfx_qspi_evt_t |
nrfx_err_t nrfx_qspi_chip_erase | ( | void | ) |
Function for starting an erase operation of the whole chip.
NRFX_SUCCESS | The operation was successful (blocking mode) or operation was commissioned (handler mode). |
NRFX_ERROR_BUSY | The driver currently handles another operation. |
nrfx_err_t nrfx_qspi_cinstr_quick_send | ( | uint8_t | opcode, |
nrf_qspi_cinstr_len_t | length, | ||
void const * | p_tx_buffer | ||
) |
Function for sending operation code and data to the memory device with simpler configuration.
Use this function to transfer configuration data to memory and to receive data from memory. This function is a synchronous function and should be used only if necessary.
[in] | opcode | Operation code. Sending first. |
[in] | length | Length of the data to send and opcode. See nrf_qspi_cinstr_len_t. |
[in] | p_tx_buffer | Pointer to input data array. |
NRFX_SUCCESS | The operation was successful. |
NRFX_ERROR_BUSY | The driver currently handles another operation. |
nrfx_err_t nrfx_qspi_cinstr_xfer | ( | nrf_qspi_cinstr_conf_t const * | p_config, |
void const * | p_tx_buffer, | ||
void * | p_rx_buffer | ||
) |
Function for sending operation code, sending data, and receiving data from the memory device.
Use this function to transfer configuration data to memory and to receive data from memory. Pointers can be addresses from flash memory. This function is a synchronous function and should be used only if necessary.
io2_level
and io3_level
fields that cause the IO2 and IO3 lines to be kept low during the custom instruction transfer. Such configuration may not be suitable in certain circumstances and memory devices can interpret such levels of those lines as active WP# and HOLD#/RESET# signals, respectively. Hence, it is safer to use a configuration that will keep the lines high during the transfer.[in] | p_config | Pointer to the structure with opcode and transfer configuration. |
[in] | p_tx_buffer | Pointer to the array with data to send. Can be NULL if only opcode is transmitted. |
[out] | p_rx_buffer | Pointer to the array for data to receive. Can be NULL if there is nothing to receive. |
NRFX_SUCCESS | The operation was successful. |
NRFX_ERROR_TIMEOUT | The external memory is busy or there are connection issues. |
NRFX_ERROR_BUSY | The driver currently handles other operation. |
nrfx_err_t nrfx_qspi_erase | ( | nrf_qspi_erase_len_t | length, |
uint32_t | start_address | ||
) |
Function for starting erasing of one memory block - 4KB, 64KB, or the whole chip.
Write, read, and erase operations check memory device busy state before starting the operation. If the memory is busy, the resulting action depends on the mode in which the erase operation is used:
[in] | length | Size of data to erase. See nrf_qspi_erase_len_t. |
[in] | start_address | Memory address to start erasing. If chip erase is performed, address field is ommited. |
NRFX_SUCCESS | The operation was successful (blocking mode) or operation was commissioned (handler mode). |
NRFX_ERROR_INVALID_ADDR | The provided start address is not aligned to a 32-bit word. |
NRFX_ERROR_BUSY | The driver currently handles another operation. |
nrfx_qspi_evt_ext_t const * nrfx_qspi_event_extended_get | ( | void | ) |
Function for getting the extended event associated with finished operation.
nrfx_err_t nrfx_qspi_init | ( | nrfx_qspi_config_t const * | p_config, |
nrfx_qspi_handler_t | handler, | ||
void * | p_context | ||
) |
Function for initializing the QSPI driver instance.
This function configures the peripheral and its interrupts, and activates it. During the activation process, the internal clocks are started and the QSPI peripheral tries to read the status byte to read the busy bit. Reading the status byte is done in a simple poll and wait mechanism. If the busy bit is 1, this indicates issues with the external memory device. As a result, nrfx_qspi_init returns NRFX_ERROR_TIMEOUT.
In case of issues:
[in] | p_config | Pointer to the structure with the initial configuration. |
[in] | handler | Event handler provided by the user. If NULL, transfers will be performed in blocking mode. |
[in] | p_context | Pointer to context. Use in the interrupt handler. |
NRFX_SUCCESS | Initialization was successful. |
NRFX_ERROR_TIMEOUT | The peripheral cannot connect with external memory. |
NRFX_ERROR_INVALID_STATE | The driver was already initialized. |
NRFX_ERROR_INVALID_PARAM | The pin configuration was incorrect. |
nrfx_err_t nrfx_qspi_lfm_start | ( | nrf_qspi_cinstr_conf_t const * | p_config | ) |
Function for starting the custom instruction long frame mode.
The long frame mode is a mechanism that allows for arbitrary byte length custom instructions. Use this function to initiate a custom transaction by sending custom instruction opcode. To send and receive data, use nrfx_qspi_lfm_xfer.
io2_level
and io3_level
fields that cause the IO2 and IO3 lines to be kept low during the custom instruction transfer. Such configuration may not be suitable in certain circumstances and memory devices can interpret such levels of those lines as active WP# and HOLD#/RESET# signals, respectively. Hence, it is safer to use a configuration that will keep the lines high during the transfer.[in] | p_config | Pointer to the structure with custom instruction opcode and transfer configuration. Transfer length must be set to NRF_QSPI_CINSTR_LEN_1B. |
NRFX_SUCCESS | Operation was successful. |
NRFX_ERROR_BUSY | Driver currently handles other operation. |
NRFX_ERROR_TIMEOUT | External memory is busy or there are connection issues. |
nrfx_err_t nrfx_qspi_lfm_xfer | ( | void const * | p_tx_buffer, |
void * | p_rx_buffer, | ||
size_t | transfer_length, | ||
bool | finalize | ||
) |
Function for sending and receiving data in the custom instruction long frame mode.
Both specified buffers must be at least transfer_length
bytes in size.
[in] | p_tx_buffer | Pointer to the array with data to send. Can be NULL if there is nothing to send. |
[out] | p_rx_buffer | Pointer to the array for receiving data. Can be NULL if there is nothing to receive. |
[in] | transfer_length | Number of bytes to send and receive. |
[in] | finalize | True if custom instruction long frame mode is to be finalized after this transfer. |
NRFX_SUCCESS | Operation was successful. |
NRFX_ERROR_TIMEOUT | External memory is busy or there are connection issues. Long frame mode becomes deactivated. |
nrfx_err_t nrfx_qspi_mem_busy_check | ( | void | ) |
Function for getting the current driver status and status byte of memory device with testing WIP (write in progress) bit.
NRFX_SUCCESS | The driver and memory are ready to handle a new operation. |
NRFX_ERROR_BUSY | The driver or memory currently handle another operation. |
nrfx_err_t nrfx_qspi_read | ( | void * | p_rx_buffer, |
size_t | rx_buffer_length, | ||
uint32_t | src_address | ||
) |
Function for reading data from the QSPI memory.
Write, read, and erase operations check memory device busy state before starting the operation. If the memory is busy, the resulting action depends on the mode in which the read operation is used:
[out] | p_rx_buffer | Pointer to the receive buffer. |
[in] | rx_buffer_length | Size of the data to read. |
[in] | src_address | Address in memory to read from. |
NRFX_SUCCESS | The operation was successful (blocking mode) or operation was commissioned (handler mode). |
NRFX_ERROR_BUSY | The driver currently handles another operation. |
NRFX_ERROR_INVALID_ADDR | The provided buffer is not placed in the Data RAM region or its address is not aligned to a 32-bit word. |
nrfx_err_t nrfx_qspi_write | ( | void const * | p_tx_buffer, |
size_t | tx_buffer_length, | ||
uint32_t | dst_address | ||
) |
Function for writing data to QSPI memory.
Write, read, and erase operations check memory device busy state before starting the operation. If the memory is busy, the resulting action depends on the mode in which the write operation is used:
[in] | p_tx_buffer | Pointer to the writing buffer. |
[in] | tx_buffer_length | Size of the data to write. |
[in] | dst_address | Address in memory to write to. |
NRFX_SUCCESS | The operation was successful (blocking mode) or operation was commissioned (handler mode). |
NRFX_ERROR_BUSY | The driver currently handles other operation. |
NRFX_ERROR_INVALID_ADDR | The provided buffer is not placed in the Data RAM region or its address is not aligned to a 32-bit word. |
bool nrfx_qspi_xfer_buffered_check | ( | void | ) |
Function for checking whether any write or read data transfer is buffered.