This module contains APIs to program and use the QSPI LLD module. The APIs can be used by other drivers to get access to QSPI and also by application to initiate data transfer operation.
Files | |
file | qspi_lld.h |
QSPI LLD Driver API/interface file. | |
Data Structures | |
struct | QSPILLD_Transaction |
QSPI Driver Transaction. More... | |
struct | QSPILLD_WriteCmdParams |
QSPI Transaction Info. More... | |
struct | QSPILLD_InitObject |
QSPI driver initialization object. More... | |
struct | QSPILLD_Object |
QSPI driver object. More... | |
Functions | |
int32_t | QSPI_lld_init (QSPILLD_Handle hQspi) |
This function initializes the QSPI module. More... | |
int32_t | QSPI_lld_initDma (QSPILLD_Handle hQspi) |
This function initializes the QSPI module in DMA Mode. More... | |
int32_t | QSPI_lld_deInit (QSPILLD_Handle hQspi) |
This function de-initializes the QSPI module. More... | |
int32_t | QSPI_lld_deInitDma (QSPILLD_Handle hQspi) |
This function de-initializes the QSPI module in DMA Mode. More... | |
int32_t | QSPI_lld_readCmd (QSPILLD_Handle hQspi, QSPILLD_WriteCmdParams *writeMsg) |
Function to send specific commands and receive related data from flash in configuration mode. More... | |
int32_t | QSPI_lld_readCmdIntr (QSPILLD_Handle hQspi, const QSPILLD_WriteCmdParams *msg) |
Function to send specific commands and receive related data from flash in interrupt mode. More... | |
int32_t | QSPI_lld_writeCmd (QSPILLD_Handle hQspi, QSPILLD_WriteCmdParams *writeMsg) |
Function to send specific commands and write data into flash in configuration mode. More... | |
int32_t | QSPI_lld_writeCmdIntr (QSPILLD_Handle hQspi, const QSPILLD_WriteCmdParams *msg) |
Function to send specific commands and write data into flash in interrupt mode. More... | |
int32_t | QSPI_lld_read (QSPILLD_Handle hQspi, uint32_t count, void *rxBuf, uint32_t addrOffset, uint32_t timeout) |
Function to perform reads from the flash in memory map mode. More... | |
int32_t | QSPI_lld_readDma (QSPILLD_Handle hQspi, uint32_t count, void *rxBuf, uint32_t addrOffset, uint32_t timeout) |
Function to perform read from the flash in DMA mode. More... | |
int32_t | QSPI_lld_setWriteCmd (QSPILLD_Handle hQspi, uint8_t command) |
Function to set write command to be used. More... | |
int32_t | QSPI_lld_setReadCmd (QSPILLD_Handle hQspi, uint8_t command) |
Function to set read command to be used. More... | |
int32_t | QSPI_lld_setAddressByteCount (QSPILLD_Handle hQspi, uint32_t count) |
Function to set number of address bytes to be used. More... | |
int32_t | QSPI_lld_setDummyBitCount (QSPILLD_Handle hQspi, uint32_t count) |
Function to set number of dummy bits to be used. More... | |
int32_t | QSPI_lld_setMemAddrSpace (QSPILLD_Handle hQspi, uint32_t memMappedPortSwitch) |
This function is used to switch between memory mapped and configuration mode. More... | |
int32_t | QSPI_lld_setRxLines (QSPILLD_Handle hQspi, uint32_t rxLines) |
Set QSPI Rx lines in the QSPI object. More... | |
int32_t | QSPI_lld_setPreScaler (QSPILLD_Handle hQspi, uint32_t clkDividerVal) |
Set the QSPI clock register divider value. More... | |
int32_t | QSPI_lld_getInputClk (QSPILLD_Handle hQspi, uint32_t *inputClk) |
This function returns the input clock at which QSPI was programmed. More... | |
uint32_t | QSPI_lld_getRxLines (QSPILLD_Handle hQspi) |
Get QSPI Rx lines in the QSPI object. More... | |
void | QSPI_lld_isr (void *args) |
QSPI ISR for Read and Write Functionality. More... | |
void | QSPI_lld_readCompleteCallback (void *args) |
QSPI Read complete callback for DMA mode. More... | |
Typedefs | |
typedef void * | QSPI_DmaHandle |
The handle for DMA instance used with QSPI. More... | |
typedef void * | QSPI_DmaChConfig |
A handle that holds DMA configuration parameters for QSPI. More... | |
typedef uint32_t(* | QSPI_Clock_getTicks) (void) |
The definition of a get System Tick function used by the QSPI driver to keep track of time. More... | |
typedef uint32_t(* | QSPI_Clock_usecToTicks) (uint64_t usecs) |
The definition of a micro seconds to ticks function used by the QSPI driver to get ticks from microseconds. More... | |
typedef void(* | QSPI_lld_InterruptCallback) (void *args) |
The definition of a interrupt completion callback function used by the QSPI driver. More... | |
typedef void(* | QSPI_lld_dma_readCompleteCallback) (void *args) |
The definition of a dma read completion callback function used by the QSPI driver. More... | |
Macros | |
#define | QSPI_NOT_IN_USE(x) (void) 0 |
NOT_IN_USE macro to highlight unused parameters. More... | |
#define | QSPI_MAX_WORD_LENGTH (128U) |
Maximum QSPI Word length. More... | |
Chip Selects | |
Chip selects | |
#define | QSPI_CS0 (0U) |
#define | QSPI_CS1 (1U) |
#define | QSPI_CS2 (2U) |
#define | QSPI_CS3 (3U) |
#define | QSPI_LLD_CMD_INVALID_ADDR (0xFFFFFFFFU) |
Macros for invalid commands. More... | |
Transfer Lines Number | |
Number of lines used for QSPI read transaction | |
#define | QSPI_RX_LINES_SINGLE (0U) |
#define | QSPI_RX_LINES_DUAL (1U) |
#define | QSPI_RX_LINES_QUAD (2U) |
Frame Format | |
Definitions for various SPI data frame formats POL0 = QSPICLK is held low during the INACTIVE state POL1 = QSPICLK is held high during the INACTIVE state PHA0 = Data launch is on the falling edge of QSPICLK PHA1 = Data launch is on the rising edge of QSPICLK | |
#define | QSPI_FF_POL0_PHA0 |
#define | QSPI_FF_POL0_PHA1 |
#define | QSPI_FF_POL1_PHA0 |
#define | QSPI_FF_POL1_PHA1 |
Chip select polarity | |
Polarity of Chip Select | |
#define | QSPI_CS_POL_ACTIVE_LOW (CSL_QSPI_SPI_DC_REG_CSP0_ACTIVE_LOW) |
#define | QSPI_CS_POL_ACTIVE_HIGH (CSL_QSPI_SPI_DC_REG_CSP0_ACTIVE_HIGH) |
Data Delay | |
Value of delay in data output after CS goes active. | |
#define | QSPI_DATA_DELAY_0 (CSL_QSPI_SPI_DC_REG_DD0_CS_TO_DATA_DELAY_0) |
#define | QSPI_DATA_DELAY_1 (CSL_QSPI_SPI_DC_REG_DD0_CS_TO_DATA_DELAY_1) |
#define | QSPI_DATA_DELAY_2 (CSL_QSPI_SPI_DC_REG_DD0_CS_TO_DATA_DELAY_2) |
#define | QSPI_DATA_DELAY_3 (CSL_QSPI_SPI_DC_REG_DD0_CS_TO_DATA_DELAY_3) |
Operation Mode | |
Operation Mode for read and write. | |
#define | QSPI_MEM_MAP_PORT_SEL_CFG_PORT (CSL_QSPI_SPI_SWITCH_REG_MMPT_S_SEL_CFG_PORT) |
QSPI Operation mode- Configuration or memory mapped mode. More... | |
#define | QSPI_MEM_MAP_PORT_SEL_MEM_MAP_PORT (CSL_QSPI_SPI_SWITCH_REG_MMPT_S_SEL_MM_PORT) |
Return status | |
#define | QSPI_SYSTEM_SUCCESS ((int32_t )0) |
Return status when the API execution was successful. More... | |
#define | QSPI_SYSTEM_FAILURE ((int32_t)-1) |
Return status when the API execution was not successful due to a failure. More... | |
#define | QSPI_TIMEOUT ((int32_t)-2) |
Return status when the API execution was not successful due to a time out. More... | |
#define | QSPI_LLD_INVALID_PARAM ((int32_t)-3) |
Return status when the API execution failed due invalid parameters. More... | |
#define | QSPI_BUSY ((int32_t)-4) |
Return status when the API execution failed due to driver busy. More... | |
#define | QSPI_INVALID_STATE ((int32_t)-5) |
Return status when the API execution failed due to invalid LLD state. More... | |
LLD (Low Level Driver) states | |
#define | QSPI_STATE_RESET (0U) |
LLD is in Reset State prior to driver init and post driver deinit. More... | |
#define | QSPI_STATE_READY (1U) |
LLD accepts runtime APIs only Ready State, otherwise return error. More... | |
#define | QSPI_STATE_BUSY (2U) |
LLD is busy performing operation with peripherals, return error when APIs are invoked. More... | |
#define | QSPI_STATE_ERROR (3U) |
LLD ran into error, returns error for all APIs other than deinit in this state. More... | |
LLD (Low Level Driver) Transaction states | |
#define | QSPI_STATE_IDLE (0U) |
Transaction is in idle state. More... | |
#define | QSPI_STATE_ADDRESS_WRITE (1U) |
This transaction state indicates address to be transferred. More... | |
#define | QSPI_STATE_DATA_WRITE (2U) |
This transaction state indicates write functionality. More... | |
#define | QSPI_STATE_DATA_READ (3U) |
This transaction state indicates read functionality. More... | |
QSPI Driver Initialization Structure | |
Status codes that are set by the QSPI driver | |
typedef struct QSPILLD_Transaction * | QSPILLD_TransactionHandle |
typedef struct QSPILLD_InitObject * | QSPILLD_InitHandle |
typedef struct QSPILLD_Object * | QSPILLD_Handle |
#define QSPI_CS0 (0U) |
#define QSPI_CS1 (1U) |
#define QSPI_CS2 (2U) |
#define QSPI_CS3 (3U) |
#define QSPI_NOT_IN_USE | ( | x | ) | (void) 0 |
NOT_IN_USE macro to highlight unused parameters.
#define QSPI_LLD_CMD_INVALID_ADDR (0xFFFFFFFFU) |
Macros for invalid commands.
#define QSPI_RX_LINES_SINGLE (0U) |
#define QSPI_RX_LINES_DUAL (1U) |
#define QSPI_RX_LINES_QUAD (2U) |
#define QSPI_FF_POL0_PHA0 |
#define QSPI_FF_POL0_PHA1 |
#define QSPI_FF_POL1_PHA0 |
#define QSPI_FF_POL1_PHA1 |
#define QSPI_CS_POL_ACTIVE_LOW (CSL_QSPI_SPI_DC_REG_CSP0_ACTIVE_LOW) |
#define QSPI_CS_POL_ACTIVE_HIGH (CSL_QSPI_SPI_DC_REG_CSP0_ACTIVE_HIGH) |
#define QSPI_DATA_DELAY_0 (CSL_QSPI_SPI_DC_REG_DD0_CS_TO_DATA_DELAY_0) |
#define QSPI_DATA_DELAY_1 (CSL_QSPI_SPI_DC_REG_DD0_CS_TO_DATA_DELAY_1) |
#define QSPI_DATA_DELAY_2 (CSL_QSPI_SPI_DC_REG_DD0_CS_TO_DATA_DELAY_2) |
#define QSPI_DATA_DELAY_3 (CSL_QSPI_SPI_DC_REG_DD0_CS_TO_DATA_DELAY_3) |
#define QSPI_MEM_MAP_PORT_SEL_CFG_PORT (CSL_QSPI_SPI_SWITCH_REG_MMPT_S_SEL_CFG_PORT) |
QSPI Operation mode- Configuration or memory mapped mode.
#define QSPI_MEM_MAP_PORT_SEL_MEM_MAP_PORT (CSL_QSPI_SPI_SWITCH_REG_MMPT_S_SEL_MM_PORT) |
#define QSPI_MAX_WORD_LENGTH (128U) |
Maximum QSPI Word length.
#define QSPI_SYSTEM_SUCCESS ((int32_t )0) |
Return status when the API execution was successful.
#define QSPI_SYSTEM_FAILURE ((int32_t)-1) |
Return status when the API execution was not successful due to a failure.
#define QSPI_TIMEOUT ((int32_t)-2) |
Return status when the API execution was not successful due to a time out.
#define QSPI_LLD_INVALID_PARAM ((int32_t)-3) |
Return status when the API execution failed due invalid parameters.
#define QSPI_BUSY ((int32_t)-4) |
Return status when the API execution failed due to driver busy.
#define QSPI_INVALID_STATE ((int32_t)-5) |
Return status when the API execution failed due to invalid LLD state.
#define QSPI_STATE_RESET (0U) |
LLD is in Reset State prior to driver init and post driver deinit.
#define QSPI_STATE_READY (1U) |
LLD accepts runtime APIs only Ready State, otherwise return error.
#define QSPI_STATE_BUSY (2U) |
LLD is busy performing operation with peripherals, return error when APIs are invoked.
#define QSPI_STATE_ERROR (3U) |
LLD ran into error, returns error for all APIs other than deinit in this state.
#define QSPI_STATE_IDLE (0U) |
Transaction is in idle state.
#define QSPI_STATE_ADDRESS_WRITE (1U) |
This transaction state indicates address to be transferred.
#define QSPI_STATE_DATA_WRITE (2U) |
This transaction state indicates write functionality.
#define QSPI_STATE_DATA_READ (3U) |
This transaction state indicates read functionality.
typedef void* QSPI_DmaHandle |
The handle for DMA instance used with QSPI.
typedef void* QSPI_DmaChConfig |
A handle that holds DMA configuration parameters for QSPI.
typedef uint32_t(* QSPI_Clock_getTicks) (void) |
The definition of a get System Tick function used by the QSPI driver to keep track of time.
typedef uint32_t(* QSPI_Clock_usecToTicks) (uint64_t usecs) |
The definition of a micro seconds to ticks function used by the QSPI driver to get ticks from microseconds.
usecs | Micro Seconds |
typedef void(* QSPI_lld_InterruptCallback) (void *args) |
The definition of a interrupt completion callback function used by the QSPI driver.
args | Void Pointer |
typedef void(* QSPI_lld_dma_readCompleteCallback) (void *args) |
The definition of a dma read completion callback function used by the QSPI driver.
args | Void Pointer |
typedef struct QSPILLD_Transaction* QSPILLD_TransactionHandle |
typedef struct QSPILLD_InitObject * QSPILLD_InitHandle |
typedef struct QSPILLD_Object * QSPILLD_Handle |
int32_t QSPI_lld_init | ( | QSPILLD_Handle | hQspi | ) |
This function initializes the QSPI module.
hQspi | QSPILLD_Handle of QSPI instance. |
int32_t QSPI_lld_initDma | ( | QSPILLD_Handle | hQspi | ) |
This function initializes the QSPI module in DMA Mode.
hQspi | QSPILLD_Handle of QSPI instance. |
int32_t QSPI_lld_deInit | ( | QSPILLD_Handle | hQspi | ) |
This function de-initializes the QSPI module.
hQspi | QSPILLD_Handle of QSPI instance. |
int32_t QSPI_lld_deInitDma | ( | QSPILLD_Handle | hQspi | ) |
This function de-initializes the QSPI module in DMA Mode.
hQspi | QSPILLD_Handle of QSPI instance. |
int32_t QSPI_lld_readCmd | ( | QSPILLD_Handle | hQspi, |
QSPILLD_WriteCmdParams * | writeMsg | ||
) |
Function to send specific commands and receive related data from flash in configuration mode.
hQspi | QSPILLD_Handle of QSPI instance. |
writeMsg | Pointer to a structure QSPILLD_WriteCmdParams contains read command OPCODE, flash memory address, buffer to store the response from flash and buffer length |
int32_t QSPI_lld_readCmdIntr | ( | QSPILLD_Handle | hQspi, |
const QSPILLD_WriteCmdParams * | msg | ||
) |
Function to send specific commands and receive related data from flash in interrupt mode.
hQspi | QSPILLD_Handle of QSPI instance. |
msg | Pointer to a structure QSPILLD_WriteCmdParams contains read command OPCODE, flash memory address, buffer to store the response from flash and buffer length |
int32_t QSPI_lld_writeCmd | ( | QSPILLD_Handle | hQspi, |
QSPILLD_WriteCmdParams * | writeMsg | ||
) |
Function to send specific commands and write data into flash in configuration mode.
hQspi | QSPILLD_Handle of QSPI instance. |
writeMsg | Pointer to a structure QSPILLD_WriteCmdParams contains write command OPCODE, flash memory address, buffer to write into flash and buffer length |
int32_t QSPI_lld_writeCmdIntr | ( | QSPILLD_Handle | hQspi, |
const QSPILLD_WriteCmdParams * | msg | ||
) |
Function to send specific commands and write data into flash in interrupt mode.
hQspi | QSPILLD_Handle of QSPI instance. |
msg | Pointer to a structure QSPILLD_WriteCmdParams contains write command OPCODE, flash memory address, buffer to write into flash and buffer length |
int32_t QSPI_lld_read | ( | QSPILLD_Handle | hQspi, |
uint32_t | count, | ||
void * | rxBuf, | ||
uint32_t | addrOffset, | ||
uint32_t | timeout | ||
) |
Function to perform reads from the flash in memory map mode.
hQspi | QSPILLD_Handle of QSPI instance. |
count | Number of bytes to be read from flash. |
rxBuf | Pointer to Receive buffer |
addrOffset | Address offset |
timeout | Timeout for |
int32_t QSPI_lld_readDma | ( | QSPILLD_Handle | hQspi, |
uint32_t | count, | ||
void * | rxBuf, | ||
uint32_t | addrOffset, | ||
uint32_t | timeout | ||
) |
Function to perform read from the flash in DMA mode.
hQspi | QSPILLD_Handle of QSPI instance. |
count | Number of bytes to be read from flash. |
rxBuf | Pointer to receive buffer |
addrOffset | Address offset |
timeout | timeout parameter |
int32_t QSPI_lld_setWriteCmd | ( | QSPILLD_Handle | hQspi, |
uint8_t | command | ||
) |
Function to set write command to be used.
hQspi | QSPILLD_Handle of QSPI instance. |
command | Write command for a particular flash |
int32_t QSPI_lld_setReadCmd | ( | QSPILLD_Handle | hQspi, |
uint8_t | command | ||
) |
Function to set read command to be used.
hQspi | QSPILLD_Handle of QSPI instance. |
command | Read command for a particular flash |
int32_t QSPI_lld_setAddressByteCount | ( | QSPILLD_Handle | hQspi, |
uint32_t | count | ||
) |
Function to set number of address bytes to be used.
hQspi | QSPILLD_Handle of QSPI instance. |
count | Number of Address Bytes. This function should always be called before accessing a memory location that doesn't fit in the current address byte range. |
int32_t QSPI_lld_setDummyBitCount | ( | QSPILLD_Handle | hQspi, |
uint32_t | count | ||
) |
Function to set number of dummy bits to be used.
hQspi | QSPILLD_Handle of QSPI instance. |
count | Number of Dummy Bits. This should be either less than 8 or a multiple of 8, because Bit count field in setup register works only if Byte count is 0. |
int32_t QSPI_lld_setMemAddrSpace | ( | QSPILLD_Handle | hQspi, |
uint32_t | memMappedPortSwitch | ||
) |
This function is used to switch between memory mapped and configuration mode.
hQspi | QSPILLD_Handle of QSPI instance. |
memMappedPortSwitch | Flag for switching mode. |
int32_t QSPI_lld_setRxLines | ( | QSPILLD_Handle | hQspi, |
uint32_t | rxLines | ||
) |
Set QSPI Rx lines in the QSPI object.
This function sets the QSPI RX lines in QSPI object so that it can be used in a subsequent read
hQspi | QSPILLD_Handle of QSPI instance. |
rxLines | QSPI_TransferLines value |
int32_t QSPI_lld_setPreScaler | ( | QSPILLD_Handle | hQspi, |
uint32_t | clkDividerVal | ||
) |
Set the QSPI clock register divider value.
This function sets the QSPI clock control register with serial data clock divider ratio (DCLK_DIV) according to the input clock provided and the output clock required. DCLK_DIV = ((input clock) / (output clock)) - 1. This function also enables the clock for QSPI module. This can only be done if QSPI module is not busy.
hQspi | QSPILLD_Handle of QSPI instance. |
clkDividerVal | Clock divider value to be set. |
int32_t QSPI_lld_getInputClk | ( | QSPILLD_Handle | hQspi, |
uint32_t * | inputClk | ||
) |
This function returns the input clock at which QSPI was programmed.
hQspi | QSPILLD_Handle of QSPI instance. |
inputClk | Pointer where input clock frequency will be stored. |
uint32_t QSPI_lld_getRxLines | ( | QSPILLD_Handle | hQspi | ) |
Get QSPI Rx lines in the QSPI object.
This function returns the QSPI RX lines in QSPI object
hQspi | QSPILLD_Handle of QSPI instance. |
void QSPI_lld_isr | ( | void * | args | ) |
QSPI ISR for Read and Write Functionality.
args | QSPILLD_Handle of QSPI instance. |
void QSPI_lld_readCompleteCallback | ( | void * | args | ) |
QSPI Read complete callback for DMA mode.
args | QSPILLD_Handle of QSPI instance. |