MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
QSPI: Queued SPI Driver

Read Guidance

This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc., each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc., for your further reference.

Driver Overview

 QSPI Peripheral and Driver Overview
 Content including 1) peripheral features; 2) driver design logic and use method; 3) typical use case.
 
 The Driver Change Log
 The current QueueSpi driver version is 2.1.0.
 

Data Structures

struct  qspi_master_config_t
 QUEUEDSPI master configuration structure with all master configuration fields covered. More...
 
struct  qspi_slave_config_t
 QUEUEDSPI slave configuration structure with all slave configuration fields covered. More...
 
struct  qspi_transfer_t
 QUEUEDSPI master/slave transfer structure. More...
 
struct  qspi_slave_transfer_handle_t
 QUEUEDSPI master transfer handle structure used for transactional API. More...
 

Macros

#define QSPI_DUMMY_DATA   (0x00U)
 User Configuraiton item dummy data filled into Output signal if there is no Tx data. More...
 

Typedefs

typedef void(* qspi_master_transfer_callback_t )(qspi_master_transfer_handle_t *psHandle, status_t eCompletionStatus, void *pUserData)
 Completion callback function pointer type. More...
 
typedef void(* qspi_slave_transfer_callback_t )(qspi_slave_transfer_handle_t *psHandle, status_t eCompletionStatus, void *pUserData)
 Completion callback function pointer type. More...
 

Enumerations

enum  {
  kStatus_QSPI_Busy = MAKE_STATUS(kStatusGroup_QUEUEDSPI, 0),
  kStatus_QSPI_Error = MAKE_STATUS(kStatusGroup_QUEUEDSPI, 1),
  kStatus_QSPI_Idle = MAKE_STATUS(kStatusGroup_QUEUEDSPI, 2),
  kStatus_QSPI_OutOfRange = MAKE_STATUS(kStatusGroup_QUEUEDSPI, 3)
}
 Status return code for the QUEUEDSPI driver. More...
 
enum  _qspi_status_flags {
  kQSPI_TxEmptyFlag = QSPI_SPSCR_SPTE_MASK,
  kQSPI_ModeFaultFlag = QSPI_SPSCR_MODF_MASK,
  kQSPI_RxOverflowFlag = QSPI_SPSCR_OVRF_MASK,
  kQSPI_RxFullFlag = QSPI_SPSCR_SPRF_MASK
}
 QUEUEDSPI peripheral status flags. More...
 
enum  _qspi_interrupt_enable {
  kQSPI_TxInterruptEnable = (QSPI_SPSCR_SPTIE_MASK >> 4U),
  kQSPI_RxInterruptEnable = (QSPI_SPSCR_SPRIE_MASK >> 4U),
  kQSPI_RxOverFlowInterruptEnable = (QSPI_SPSCR_ERRIE_MASK >> 4U)
}
 QUEUEDSPI interrupt source. More...
 
enum  qspi_ss_direction_t {
  kQSPI_SlaveSelectDirectionInput,
  kQSPI_SlaveSelectDIrectionOutput = 1U
}
 options for Slave Select (SSB) signal direction. More...
 
enum  qspi_ss_data_logic_level_t {
  kQSPI_SlaveSelectLogicLow = 0U,
  kQSPI_SlaveSelectLogicHigh = 1U
}
 logical level for Slave Select (SSB) signal data More...
 
enum  qspi_txfifo_watermark_t {
  kQSPI_TxFifoWatermarkEmpty = 0U,
  kQSPI_TxFifoWatermarkOneWord = 1U,
  kQSPI_TxFifoWatermarkTwoWord = 2U,
  kQSPI_TxFifoWatermarkThreeWord
}
 QUEUEDSPI Transmit FIFO watermark settings. More...
 
enum  qspi_rxfifo_watermark_t {
  kQSPI_RxFifoWatermarkOneWord = 0U,
  kQSPI_RxFifoWatermarkTwoWord = 1U,
  kQSPI_RxFifoWatermarkThreeWord = 2U,
  kQSPI_RxFifowatermarkFull = 3U
}
 QUEUEDSPI Receive FIFO watermark settings. More...
 
enum  qspi_data_width_t {
  kQSPI_Data2Bits = 1U,
  kQSPI_Data3Bits = 2U,
  kQSPI_Data4Bits = 3U,
  kQSPI_Data5Bits = 4U,
  kQSPI_Data6Bits = 5U,
  kQSPI_Data7Bits = 6U,
  kQSPI_Data8Bits = 7U,
  kQSPI_Data9Bits = 8U,
  kQSPI_Data10Bits = 9U,
  kQSPI_Data11Bits = 10U,
  kQSPI_Data12Bits = 11U,
  kQSPI_Data13Bits = 12U,
  kQSPI_Data14Bits = 13U,
  kQSPI_Data15Bits = 14U,
  kQSPI_Data16Bits = 15U
}
 Transfer data width in each frame. More...
 
enum  _qspi_dma_enable_flags {
  kQSPI_DmaRx = 1U,
  kQSPI_DmaTx = 2U
}
 QUEUEDSPI DMA configuration for Transmit and Receive. More...
 
enum  qspi_master_slave_mode_t {
  kQSPI_Slave = 0U,
  kQSPI_Master = 1U
}
 QUEUEDSPI master or slave mode configuration. More...
 
enum  qspi_clock_polarity_t {
  kQSPI_ClockPolarityActiveRisingEdge,
  kQSPI_ClockPolarityActiveFallingEdge
}
 QUEUEDSPI clock polarity configuration. More...
 
enum  qspi_clock_phase_t {
  kQSPI_ClockPhaseSlaveSelectHighBetweenWords = 0U,
  kQSPI_ClockPhaseSlaveSelectLowBetweenWords = 1U
}
 QUEUEDSPI clock phase configuration. More...
 
enum  qspi_data_shift_direction_t {
  kQSPI_MsbFirst = 0U,
  kQSPI_LsbFirst = 1U
}
 QUEUEDSPI data shifter direction options for a given CTAR. More...
 
enum  qspi_pcs_polarity_config_t {
  kQSPI_PcsActiveHigh = 0U,
  kQSPI_PcsActiveLow = 1U
}
 QUEUEDSPI Peripheral Chip Select Polarity configuration. More...
 
enum  _qspi_master_transfer_flag {
  kQSPI_MasterPCSContinous,
  kQSPI_MasterActiveAfterTransfer
}
 transaction layer configuration options for each transaction More...
 
enum  _qspi_transfer_state {
  kQSPI_Idle = 0x0U,
  kQSPI_Busy,
  kQSPI_Error
}
 QUEUEDSPI transfer state, used internally for transactional layer. More...
 

Variables

volatile uint16_t g_u8QueuedSpiDummyData []
 Global variable for dummy data value setting. More...
 

Driver version

#define FSL_QSPI_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 QUEUEDSPI driver version. More...
 

Module Initialization/Deinitialization

void QSPI_MasterInit (QSPI_Type *base, const qspi_master_config_t *psConfig)
 Initializes the QUEUEDSPI as Master. More...
 
void QSPI_MasterGetDefaultConfig (qspi_master_config_t *psConfig, uint32_t u32ClockFreqHz)
 Helper function to create ready-to-user maste init structure. More...
 
void QSPI_SlaveInit (QSPI_Type *base, const qspi_slave_config_t *psConfig)
 Initializes the QUEUEDSPI as slave. More...
 
void QSPI_SlaveGetDefaultConfig (qspi_slave_config_t *psConfig)
 Set the qspi_slave_config_t structure to default values. More...
 
void QSPI_Deinit (QSPI_Type *base)
 De-initialize the QUEUEDSPI peripheral for either Master or Slave. More...
 

Interrupt APIs

static void QSPI_EnableInterrupts (QSPI_Type *base, uint8_t u8Interrupts)
 Enable one or multiple interrupts. More...
 
static void QSPI_DisableInterrupts (QSPI_Type *base, uint8_t u8Interrupts)
 Disable one or multiple interrupts. More...
 

DMA Operation APIs

static void QSPI_EnableDMA (QSPI_Type *base, uint8_t u8DmaFlags)
 Enable one or multiple DMA. More...
 
static void QSPI_DisableDMA (QSPI_Type *base, uint8_t u8DmaFlags)
 Enable one or multiple DMA. More...
 
static uint32_t QSPI_GetTxRegisterAddress (QSPI_Type *base)
 Get the QUEUEDSPI transmit data register address for the DMA operation. More...
 
static uint32_t QSPI_GetRxRegisterAddress (QSPI_Type *base)
 Get the QUEUEDSPI receive data register address for the DMA operation. More...
 

Status Get/Clear APIs

static uint16_t QSPI_GetStatusFlags (QSPI_Type *base)
 Get the QUEUEDSPI status flag state. More...
 
static void QSPI_ClearStatusFlags (QSPI_Type *base, uint16_t u16StatusFlags)
 Clear the status flag only for the mode fault. More...
 

QUEUESPI Configuration

static void QSPI_Enable (QSPI_Type *base, bool bEnable)
 Enable or disable the QUEUEDSPI peripheral. More...
 
uint32_t QSPI_MasterSetBaudRate (QSPI_Type *base, uint32_t u32BaudRateBps, uint32_t u32SrcClockHz)
 Set the QUEUEDSPI baud rate in bits-per-second. More...
 
static void QSPI_SetMasterSlaveMode (QSPI_Type *base, qspi_master_slave_mode_t eMode)
 Set the QUEUEDSPI as master or slave. More...
 
static bool QSPI_IsMaster (QSPI_Type *base)
 Return whether the QUEUEDSPI module is in master mode. More...
 
static void QSPI_SetDataShiftOrder (QSPI_Type *base, qspi_data_shift_direction_t eDataShiftOrder)
 Set Data Shift Order as MSB first or LSB first. More...
 
static void QSPI_EnableModeFault (QSPI_Type *base, bool bEnable)
 Enable/Disable mode fault detection. More...
 
static void QSPI_SetClockPolarity (QSPI_Type *base, qspi_clock_polarity_t ePolarity)
 Set clock polarity. More...
 
static void QSPI_SetClockPhase (QSPI_Type *base, qspi_clock_phase_t eClockPhase)
 Set clock phase. More...
 
static void QSPI_EnableWiredORMode (QSPI_Type *base, bool bEnable)
 Enable/Disable Wired OR mode for SPI pins which means open-drain when enabled and push-pull when disabled. More...
 
static void QSPI_SetTransactionDataSize (QSPI_Type *base, qspi_data_width_t eDataWidth)
 Set the transaction data width. More...
 
static void QSPI_MasterSetWaitDelay (QSPI_Type *base, uint16_t u16WaitDelayInPeriClockCount)
 For master mode, set wait delay in clock cycle with delay is set value + 1 peripheral bus clock. More...
 
static void QSPI_EnableStopModeHoldOff (QSPI_Type *base, bool bEnable)
 Enable/Disable hold off entry to stop mode is a word is being transmitted/received for Master Mode. More...
 
uint32_t QSPI_GetInstance (QSPI_Type *base)
 Helper function exported for QSPI DMA driver. More...
 

Slave Select (SS) singal

static qspi_ss_data_logic_level_t QSPI_MasterGetSlaveSelectLogicLevel (QSPI_Type *base)
 For master mode, get the SS_B input logic level while true means drive High and false means drive Low. More...
 
static void QSPI_MasterSetSlaveSelectLogicLevel (QSPI_Type *base, qspi_ss_data_logic_level_t eLogicLevel)
 for master mode, drive Slave Select pin logic high or low More...
 
static void QSPI_MasterEnableSlaveSelectOpenDrainMode (QSPI_Type *base, bool bEnable)
 For master mode, Enable open drain in SSB pad pin. More...
 
static void QSPI_MasterEnableSlaveSelectAutomaticMode (QSPI_Type *base, bool bEnable)
 For master mode, Enable/Disable Slave Select pin automatic mode. More...
 
static void QSPI_SetSlaveSelectDirection (QSPI_Type *base, qspi_ss_direction_t eDirection)
 Set Input/Output mode for SSB signal. More...
 
static void QSPI_MasterEnableSlaveSelectStrobe (QSPI_Type *base, bool bEnable)
 For master, set strobe mode for SSB signal. More...
 
static void QSPI_EnableSlaveSelectOverride (QSPI_Type *base, bool bEnable)
 Enable / Disable SSB signal from Master/Slave configuration or GPIO pin state. More...
 

Transmit/Receive Bus Operation

void QSPI_SetDummyData (QSPI_Type *base, uint8_t u8DummyData)
 Set up the dummy data used when there is not transmit data provided. More...
 
uint8_t QSPI_GetDummyData (QSPI_Type *base)
 Get the dummy data for each peripheral. More...
 
static void QSPI_WriteData (QSPI_Type *base, uint16_t data)
 Write data into the transmit data register without polling the status of shifting. More...
 
static uint16_t QSPI_ReadData (QSPI_Type *base)
 Read data from the receive data register. More...
 

FIFO Operation APIs

static void QSPI_EnableFifo (QSPI_Type *base, bool bEnable)
 Enable or disable the QUEUEDSPI FIFOs. More...
 
static uint16_t QSPI_GetTxFIFOCount (QSPI_Type *base)
 Get TX FIFO level. More...
 
static uint16_t QSPI_GetRxFIFOCount (QSPI_Type *base)
 Get RX FIFO level. More...
 
static void QSPI_SetFifoWatermarks (QSPI_Type *base, uint16_t txWatermark, uint16_t rxWatermark)
 Set the transmit and receive FIFO watermark values. More...
 
static void QSPI_GetFifoWatermarks (QSPI_Type *base, uint8_t *pu8TxWatermark, uint8_t *pu8RxWatermark)
 Get the transmit and receive FIFO watermark values. More...
 
static void QSPI_EmptyRxFifo (QSPI_Type *base)
 Empty the QUEUEDSPI RX FIFO. More...
 

Transactional Helper Apis to extract information from handle

#define QSPI_TRANSFER_GET_BASE(handle)   (handle->base)
 Extract Base Address from handle for master or slave handle. More...
 
#define QSPI_TRANSFER_GET_USER_DATA(handle)   (handle->pUserData)
 Extract user data from handle for master or slave handle. More...
 

Transactional Master

void QSPI_MasterTransferCreateHandle (QSPI_Type *base, qspi_master_transfer_handle_t *psHandle, qspi_master_transfer_callback_t pfCallback, void *pUserData)
 Initialize the QUEUEDSPI master handle. More...
 
status_t QSPI_MasterTransferBlocking (QSPI_Type *base, qspi_transfer_t *psXfer)
 Polling method of QUEUEDSPI master transfer. More...
 
status_t QSPI_MasterTransferNonBlocking (qspi_master_transfer_handle_t *psHandle, qspi_transfer_t *psXfer)
 Interrupt method of QUEUEDSPI master transfer. More...
 
status_t QSPI_MasterTransferGetCount (qspi_master_transfer_handle_t *psHandle, uint16_t *pu16Count)
 Get the master transfer count. More...
 
void QSPI_MasterTransferAbort (qspi_master_transfer_handle_t *psHandle)
 Abort a transfer that uses interrupts for master. More...
 
void QSPI_MasterTransferHandleIRQ (qspi_master_transfer_handle_t *psHandle)
 QUEUEDSPI Master IRQ handler function. More...
 

Transactional Slave

void QSPI_SlaveTransferCreateHandle (QSPI_Type *base, qspi_slave_transfer_handle_t *psHandle, qspi_slave_transfer_callback_t pfCallback, void *pUserData)
 Initialize the QUEUEDSPI slave handle. More...
 
status_t QSPI_SlaveTransferNonBlocking (qspi_slave_transfer_handle_t *psHandle, qspi_transfer_t *psXfer)
 Interrupt driven method of QUEUEDSPI slave transfer with completion will be notified by registered callback. More...
 
status_t QSPI_SlaveTransferGetCount (qspi_slave_transfer_handle_t *psHandle, uint16_t *pu16Count)
 Get the slave transfer count already transmitted/received. More...
 
void QSPI_SlaveTransferAbort (qspi_slave_transfer_handle_t *psHandle)
 Abort a transaction. More...
 
void QSPI_SlaveTransferHandleIRQ (qspi_slave_transfer_handle_t *psHandle)
 QUEUEDSPI slave IRQ handler function. More...
 

Data Structure Documentation

struct qspi_master_config_t

Data Fields

uint32_t u32BaudRateBps
 Baud Rate for QUEUEDSPI. More...
 
qspi_data_width_t eDataWidth: 4
 Data width in SPI transfer.
 
qspi_clock_polarity_t eClkPolarity: 1
 Clock polarity. More...
 
qspi_clock_phase_t eClkPhase: 1
 Clock phase. More...
 
qspi_data_shift_direction_t eShiftDirection: 1
 MSB or LSB data shift direction. More...
 
bool bEnableWiredOrMode: 1
 SPI pin configuration, when enabled the SPI pins are configured as open-drain drivers with the pull-ups disabled. More...
 
bool bEnableModeFault: 1
 Enable/Disable mode fault detect for Slave Select Signal.
 
bool bEnableStrobe: 1
 Enable/Disable strobe between data frames irrespective of clock pahse setting.
 
bool bEnableSlaveSelAutoMode: 1
 Enable/Disable Slave Select Auto mode. More...
 
bool bEnableSlaveSelOpenDrain: 1
 Enable the open-drain mode of SPI Pins, otherwise Push-Pull.
 
uint16_t u16DelayBetweenFrameInCLK
 The delay between frame. More...
 
bool bEnableFIFO: 1
 Enable / Disable FIFO for Transmit/Receive.
 
qspi_txfifo_watermark_t eTxFIFOWatermark: 2
 Watermark config for Transmit FIFO.
 
qspi_txfifo_watermark_t eRxFIFOWatermark: 2
 Watermark config for Receive FIFO.
 
bool bEnableModule: 1
 Enable / Disable module.
 
uint8_t u8Interrupts: 8
 Interrupt enabled ORed from _qspi_interrupt_enable.
 
uint8_t u8DmaEnableFlags: 8
 Configure DMA Enable/Disable for Transmit/Receive.
 

Field Documentation

uint32_t qspi_master_config_t::u32BaudRateBps
qspi_clock_polarity_t qspi_master_config_t::eClkPolarity
qspi_clock_phase_t qspi_master_config_t::eClkPhase
qspi_data_shift_direction_t qspi_master_config_t::eShiftDirection
bool qspi_master_config_t::bEnableWiredOrMode
bool qspi_master_config_t::bEnableSlaveSelAutoMode
uint16_t qspi_master_config_t::u16DelayBetweenFrameInCLK
struct qspi_slave_config_t

Data Fields

qspi_data_width_t eDataWidth: 4
 Data width in SPI transfer.
 
qspi_clock_polarity_t eClkPolarity: 1
 Clock polarity. More...
 
qspi_clock_phase_t eClkPhase: 1
 Clock phase. More...
 
qspi_data_shift_direction_t eShiftDirection: 1
 MSB or LSB data shift direction. More...
 
bool bEnableWiredOrMode: 1
 SPI pin configuration, when enabled the SPI pins are configured as open-drain drivers with the pull-ups disabled. More...
 
bool bEnableModeFault: 1
 Enable/Disable mode fault detect for Slave Select Signal.
 
bool bEnableSlaveSelOverride: 1
 Enable/Disble override Slave Select (SS) singal with Master/Slave Mode config.
 
bool bEnableFIFO: 1
 Enable / Disable FIFO for Transmit/Receive.
 
qspi_txfifo_watermark_t eTxFIFOWatermark: 2
 Watermark config for Transmit FIFO.
 
qspi_txfifo_watermark_t eRxFIFOWatermark: 2
 Watermark config for Receive FIFO.
 
bool bEnableModule: 1
 Enable/Disable Module.
 
uint8_t u8DmaEnableFlags
 Configure DMA Enable/Disable for Transmit/Receive.
 

Field Documentation

qspi_clock_polarity_t qspi_slave_config_t::eClkPolarity
qspi_clock_phase_t qspi_slave_config_t::eClkPhase
qspi_data_shift_direction_t qspi_slave_config_t::eShiftDirection
bool qspi_slave_config_t::bEnableWiredOrMode
struct qspi_transfer_t

Data Fields

void * pTxData
 Transmit buffer. More...
 
void * pRxData
 Receive buffer. More...
 
volatile uint16_t u16DataSize
 Transfer bytes. More...
 
uint8_t u8ConfigFlags
 Transfer configuration flags; set from _qspi_master_transfer_flag. More...
 

Field Documentation

void* qspi_transfer_t::pTxData
void* qspi_transfer_t::pRxData
volatile uint16_t qspi_transfer_t::u16DataSize
uint8_t qspi_transfer_t::u8ConfigFlags

This is not used in slave transfer.

struct _qspi_master_handle

Forward declaration of the _qspi_master_handle typedefs.

Data Fields

QSPI_Type * base
 Base address for the QSPI peripheral.
 
qspi_data_width_t eDataWidth
 The desired number of bits per frame. More...
 
volatile bool bIsPcsActiveAfterTransfer
 Indicates whether the PCS signal is active after the last frame transfer, This is not used in slave transfer. More...
 
uint8_t *volatile pu8TxData
 Send buffer. More...
 
uint8_t *volatile pu8RxData
 Receive buffer. More...
 
volatile uint16_t u16RemainingSendByteCount
 A number of bytes remaining to send. More...
 
volatile uint16_t u16RemainingReceiveByteCount
 A number of bytes remaining to receive. More...
 
uint16_t u16TotalByteCount
 A number of transfer bytes.
 
volatile uint8_t u8State
 QUEUEDSPI transfer state, see _qspi_transfer_state. More...
 
qspi_master_transfer_callback_t pfCallback
 Completion callback. More...
 
void * pUserData
 Callback user data. More...
 
volatile uint16_t u16ErrorCount
 Error count for slave transfer, this is not used in master transfer. More...
 

Field Documentation

qspi_data_width_t qspi_master_transfer_handle_t::eDataWidth
volatile bool qspi_master_transfer_handle_t::bIsPcsActiveAfterTransfer
uint8_t* volatile qspi_master_transfer_handle_t::pu8TxData
uint8_t* volatile qspi_master_transfer_handle_t::pu8RxData
volatile uint16_t qspi_master_transfer_handle_t::u16RemainingSendByteCount
volatile uint16_t qspi_master_transfer_handle_t::u16RemainingReceiveByteCount
volatile uint8_t qspi_master_transfer_handle_t::u8State
qspi_master_transfer_callback_t qspi_master_transfer_handle_t::pfCallback
void* qspi_master_transfer_handle_t::pUserData
volatile uint16_t qspi_master_transfer_handle_t::u16ErrorCount

Macro Definition Documentation

#define FSL_QSPI_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
#define QSPI_DUMMY_DATA   (0x00U)

Dummy data used for Tx if there is no txData.

#define QSPI_TRANSFER_GET_BASE (   handle)    (handle->base)
#define QSPI_TRANSFER_GET_USER_DATA (   handle)    (handle->pUserData)

Typedef Documentation

typedef void(* qspi_master_transfer_callback_t)(qspi_master_transfer_handle_t *psHandle, status_t eCompletionStatus, void *pUserData)
Parameters
baseQUEUEDSPI peripheral address.
psHandlePointer to the handle for the QUEUEDSPI master.
eCompletionStatusSuccess or error code describing whether the transfer completed.
pUserDataArbitrary pointer-dataSized value passed from the application.
typedef void(* qspi_slave_transfer_callback_t)(qspi_slave_transfer_handle_t *psHandle, status_t eCompletionStatus, void *pUserData)
Parameters
baseQUEUEDSPI peripheral address.
handlePointer to the handle for the QUEUEDSPI slave.
statusSuccess or error code describing whether the transfer completed.
pUserDataArbitrary pointer-dataSized value passed from the application.

Enumeration Type Documentation

anonymous enum

Only used in transactional layer in this driver.

Enumerator
kStatus_QSPI_Busy 

QUEUEDSPI transfer is busy.

kStatus_QSPI_Error 

QUEUEDSPI driver error.

kStatus_QSPI_Idle 

QUEUEDSPI is idle.

kStatus_QSPI_OutOfRange 

QUEUEDSPI transfer out of range.

Enumerator
kQSPI_TxEmptyFlag 

Transmitter Empty Flag.

kQSPI_ModeFaultFlag 

Mode Fault Flag.

kQSPI_RxOverflowFlag 

Receiver Overflow Flag.

kQSPI_RxFullFlag 

Receiver Full Flag.

Enumerator
kQSPI_TxInterruptEnable 

SPTE interrupt enable.

kQSPI_RxInterruptEnable 

SPRF interrupt enable.

kQSPI_RxOverFlowInterruptEnable 

Bus error interrupt enable.

Enumerator
kQSPI_SlaveSelectDirectionInput 

SSB signal as input for slave mode or master mode with Mode fault enabled.

kQSPI_SlaveSelectDIrectionOutput 

SSB signal as output.

Enumerator
kQSPI_SlaveSelectLogicLow 

Slave select logic level low.

kQSPI_SlaveSelectLogicHigh 

Slave select logic level high.

Enumerator
kQSPI_TxFifoWatermarkEmpty 

Transmit interrupt active when Tx FIFO is empty.

kQSPI_TxFifoWatermarkOneWord 

Transmit interrupt active when Tx FIFO has one or fewer words available.

kQSPI_TxFifoWatermarkTwoWord 

Transmit interrupt active when Tx FIFO has two or fewer words available.

kQSPI_TxFifoWatermarkThreeWord 

Transmit interrupt active when Tx FIFO has three or fewer words available.

Enumerator
kQSPI_RxFifoWatermarkOneWord 

Receive interrupt active when Rx FIFO has at least one word used.

kQSPI_RxFifoWatermarkTwoWord 

Receive interrupt active when Rx FIFO has at least two words used.

kQSPI_RxFifoWatermarkThreeWord 

Receive interrupt active when Rx FIFO has at least three words used.

kQSPI_RxFifowatermarkFull 

Receive interrupt active when Rx FIFO is full.

Enumerator
kQSPI_Data2Bits 

2 bits data width

kQSPI_Data3Bits 

3 bits data width

kQSPI_Data4Bits 

4 bits data width

kQSPI_Data5Bits 

5 bits data width

kQSPI_Data6Bits 

6 bits data width

kQSPI_Data7Bits 

7 bits data width

kQSPI_Data8Bits 

8 bits data width

kQSPI_Data9Bits 

9 bits data width

kQSPI_Data10Bits 

10 bits data width

kQSPI_Data11Bits 

11 bits data width

kQSPI_Data12Bits 

12 bits data width

kQSPI_Data13Bits 

13 bits data width

kQSPI_Data14Bits 

14 bits data width

kQSPI_Data15Bits 

15 bits data width

kQSPI_Data16Bits 

16 bits data width

Enumerator
kQSPI_DmaRx 

Receive DMA Enable Flag.

kQSPI_DmaTx 

Transmit DMA Enable Flag.

Enumerator
kQSPI_Slave 

QUEUEDSPI peripheral operates in slave mode.

kQSPI_Master 

QUEUEDSPI peripheral operates in master mode.

Enumerator
kQSPI_ClockPolarityActiveRisingEdge 

CPOL=0.

Active-high QUEUEDSPI clock (idles low), rising edge of SCLK starts transaction.

kQSPI_ClockPolarityActiveFallingEdge 

CPOL=1.

Active-low QUEUEDSPI clock (idles high), falling edge of SCLK starts transaction.

Enumerator
kQSPI_ClockPhaseSlaveSelectHighBetweenWords 

CPHA=0, Slave Select toggle high during data frames.

kQSPI_ClockPhaseSlaveSelectLowBetweenWords 

CPHA=1, Slave Select keep low during data frames.

Enumerator
kQSPI_MsbFirst 

Data transfers start with most significant bit.

kQSPI_LsbFirst 

Data transfers start with least significant bit.

Enumerator
kQSPI_PcsActiveHigh 

Pcs Active High (idles low).

kQSPI_PcsActiveLow 

Pcs Active Low (idles high).

Enumerator
kQSPI_MasterPCSContinous 

Indicates whether the PCS signal de-asserts during transfer between frames, note this flag should not be used when CPHA is 0.

kQSPI_MasterActiveAfterTransfer 

Indicates whether the PCS signal is active after the last frame transfer, note 1.

this flag should not be used when CPHA is 0, 2. this flag can only be used when kQSPI_MasterPCSContinous is used.

Enumerator
kQSPI_Idle 

Nothing in the transmitter/receiver.

kQSPI_Busy 

Transfer queue is not finished.

kQSPI_Error 

Transfer error.

Function Documentation

void QSPI_MasterInit ( QSPI_Type *  base,
const qspi_master_config_t psConfig 
)

Use helpher function QSPI_MasterGetDefaultConfig to get ready-to-use structure.

Parameters
baseQUEUEDSPI peripheral address.
psConfigPointer to the structure qspi_master_config_t.
void QSPI_MasterGetDefaultConfig ( qspi_master_config_t psConfig,
uint32_t  u32ClockFreqHz 
)

The purpose of this API is to get the configuration structure initialized for the QSPI_MasterInit. Users may use the initialized structure unchanged in the QSPI_MasterInit or modify the structure before calling the QSPI_MasterInit. Example:

* qspi_master_config_t sMasterConfig;
* QSPI_MasterGetDefaultConfig(&sMasterConfig);
*

The default values are: Example:

// Parameter provided by user
psConfig->u32BaudRateBps = u32BaudRateBps;
psConfig->u32ClockFrequencyHz = u32ClockFreqHz;
psConfig->eDataWidth = eDataWidth;
// Default configuration
psConfig->eClkPolarity = kQSPI_ClockPolarityActiveRisingEdge;
psConfig->eShiftDirection = kQSPI_MsbFirst;
psConfig->u16DelayBetweenFrameInCLK = 1U;
psConfig->bEnableWiredOrMode = false;
psConfig->bEnableModeFault = false;
psConfig->u8DmaEnableFlags = 0U; // Disable TX/RX Dma
psConfig->bEnableFIFO = false;
psConfig->bEnableStopModeHoldOff = false;
psConfig->u8Interrupts = 0U;
psConfig->bEnableModule = false;
* @todo To be added
*
Parameters
psConfigpointer to qspi_master_config_t structure.
u32ClockFreqcyHzPeripheral clock frequency in Hz
void QSPI_SlaveInit ( QSPI_Type *  base,
const qspi_slave_config_t psConfig 
)

Use helpher function QSPI_SlaveGetDefaultConfig to get ready-to-use structure.

Parameters
baseQUEUEDSPI peripheral address.
psConfigPointer to the structure qspi_slave_config_t.
void QSPI_SlaveGetDefaultConfig ( qspi_slave_config_t psConfig)

The purpose of this API is to get the configuration structure initialized for the QSPI_SlaveInit. Users may use the initialized structure unchanged in the QSPI_SlaveInit or modify the structure before calling the QSPI_SlaveInit. Example:

* qspi_slave_config_t slaveConfig;
*

The default values are: Example:

* @todo
*
Parameters
psConfigPointer to the qspi_slave_config_t structure.
void QSPI_Deinit ( QSPI_Type *  base)
Parameters
baseQUEUEDSPI peripheral address.
static void QSPI_EnableInterrupts ( QSPI_Type *  base,
uint8_t  u8Interrupts 
)
inlinestatic

This function enable one or multiple interrupts.

Note
for TX and RX requests, while enabling the interrupt request the DMA request will be disabled as well. Do not use this API while QUEUEDSPI is in running state.
Parameters
baseQUEUEDSPI peripheral address.
u8InterruptsThe interrupt mask which is ORed by the _qspi_interrupt_enable.
static void QSPI_DisableInterrupts ( QSPI_Type *  base,
uint8_t  u8Interrupts 
)
inlinestatic

This function

Parameters
baseQUEUEDSPI peripheral address.
u8InterruptsThe interrupt mask which is ORed by the _qspi_interrupt_enable.
static void QSPI_EnableDMA ( QSPI_Type *  base,
uint8_t  u8DmaFlags 
)
inlinestatic

Note that if the DMA is enabled for Transmit or Receive, make sure the interurpt is disabled for Transmit or Receive.

Parameters
baseQUEUEDSPI peripheral address.
u8DmaFlagsDMA Flags ORed from _qspi_dma_enable_flags.
static void QSPI_DisableDMA ( QSPI_Type *  base,
uint8_t  u8DmaFlags 
)
inlinestatic

Note that if the DMA is enabled for Transmit or Receive, make sure the interurpt is disabled for Transmit or Receive.

Parameters
baseQUEUEDSPI peripheral address.
u8DmaFlagsDMA Flags ORed from _qspi_dma_enable_flags.
static uint32_t QSPI_GetTxRegisterAddress ( QSPI_Type *  base)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
Returns
The QUEUEDSPI master PUSHR data register address.
static uint32_t QSPI_GetRxRegisterAddress ( QSPI_Type *  base)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
Returns
The QUEUEDSPI POPR data register address.
static uint16_t QSPI_GetStatusFlags ( QSPI_Type *  base)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
Returns
QUEUEDSPI status.
static void QSPI_ClearStatusFlags ( QSPI_Type *  base,
uint16_t  u16StatusFlags 
)
inlinestatic

Clear the status flag only for mode fault.

Note
only kQSPI_ModeFaultFlag can be cleared by this API.
Parameters
baseQUEUEDSPI peripheral address.
u16StatusFlagsstatus flags ORed from _qspi_status_flags
static void QSPI_Enable ( QSPI_Type *  base,
bool  bEnable 
)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
bEnabletrue to enable module, otherwise disable module
uint32_t QSPI_MasterSetBaudRate ( QSPI_Type *  base,
uint32_t  u32BaudRateBps,
uint32_t  u32SrcClockHz 
)

This function takes in the desired baud rate, calculates the nearest possible baud rate, and returns the calculated baud rate in bits-per-second.

Parameters
baseQUEUEDSPI peripheral address.
u32BaudRateBpsThe desired baud rate in bits-per-second.
u32SrcClockHzModule source input clock in Hertz.
Returns
The actual calculated baud rate.
static void QSPI_SetMasterSlaveMode ( QSPI_Type *  base,
qspi_master_slave_mode_t  eMode 
)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
eModeMode setting of type qspi_master_slave_mode_t.
static bool QSPI_IsMaster ( QSPI_Type *  base)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
Returns
Returns true if the module is in master mode or false if the module is in slave mode.
static void QSPI_SetDataShiftOrder ( QSPI_Type *  base,
qspi_data_shift_direction_t  eDataShiftOrder 
)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
eDataShiftOrderMSB or LSB first from _qspi_shift_direction
static void QSPI_EnableModeFault ( QSPI_Type *  base,
bool  bEnable 
)
inlinestatic

If enable, allows the kQSPI_ModeFaultFlag flag to be set. If the kQSPI_ModeFaultFlag flag is set, disable the Mod detection does not clear the flag. If the mod detection is disabled, the level of the SS_B pin does not affect the operation of an enabled SPI configured as a master. If configured as a master and mod fault detection is enabled, a transaction in progress will stop if SS_B goes low. For an enabled SPI configured as a slave, having this feature disabled only prevents the flag from being set. It does not affect any other part of SPI operation

Parameters
baseQUEUEDSPI peripheral address.
bEnabletrue to enable Mode Fault detection, false to disable
static void QSPI_SetClockPolarity ( QSPI_Type *  base,
qspi_clock_polarity_t  ePolarity 
)
inlinestatic
Note
module shall be disabled before change the polarity by calling QSPI_Enable.
Parameters
baseQUEUEDSPI peripheral address.
ePolarityclock polarity option
static void QSPI_SetClockPhase ( QSPI_Type *  base,
qspi_clock_phase_t  eClockPhase 
)
inlinestatic

Configure whether get the Slave Select signal toggle high during 2 data frames. Get the SS toggle high between data frames will lead to SPI to be trigged with transaction for the falling edge of SS signal. Otherwise, the data transaction is started on the first active SCLK edge.

Note
module shall be disabled before change the polarity by calling QSPI_Enable.
Do not use kQSPI_ClockPhaseSlaveSelectHighBetweenWords in DMA mode.
Parameters
baseQUEUEDSPI peripheral address.
eClockPhaseOption for clock phase
static void QSPI_EnableWiredORMode ( QSPI_Type *  base,
bool  bEnable 
)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
bEnabletrue to configure SPI pins as open-drain, false to configure as push-pull
static void QSPI_SetTransactionDataSize ( QSPI_Type *  base,
qspi_data_width_t  eDataWidth 
)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
eDataWidthdatawidth for bits in each data frame.
static void QSPI_MasterSetWaitDelay ( QSPI_Type *  base,
uint16_t  u16WaitDelayInPeriClockCount 
)
inlinestatic

This controls the time between data transactions in master mode. Delay will not be added if no word is waiting for transmitting.

Parameters
baseQUEUEDSPI peripheral address.
u16WaitDelayInPeriClockCountClock count for the delay during data frames
static void QSPI_EnableStopModeHoldOff ( QSPI_Type *  base,
bool  bEnable 
)
inlinestatic

When enabled, this bit allows the SPI module to hold off entry to chip level stop mode if a word is being transmitted or received. Stop mode will be entered after the SPI finishes transmitting/receiving. This bit does not allow the SPI to wake the chip from stop mode in any way. The SHEN bit can only delay the entry into stop mode. This bit should not be set in slave mode because the state of SS_B (which would be controlled by an external master device) may cause the logic to hold off stop mode entry forever.

Parameters
baseQUEUEDSPI peripheral address.
bEnabletrue to enable hold-off entrying stop mode if there is transmitting/receiving
uint32_t QSPI_GetInstance ( QSPI_Type *  base)

Get the instance index from the base address. User need not understand this function.

Parameters
baseQUEUEDSPI peripheral address.
Returns
uint32_t Index of the peripheral instance for given base address.
static qspi_ss_data_logic_level_t QSPI_MasterGetSlaveSelectLogicLevel ( QSPI_Type *  base)
inlinestatic

Get the value to drive on the SS_B pin. This bit is disabled when SSB_AUTO=1 or SSB_STRB=1. Only apply for Master mode.

Parameters
baseQUEUEDSPI peripheral address.
Returns
true SS_B input level High
false SS_B input level Low
static void QSPI_MasterSetSlaveSelectLogicLevel ( QSPI_Type *  base,
qspi_ss_data_logic_level_t  eLogicLevel 
)
inlinestatic

This feature is disabled if Slave Select automatic mode is enabled or Slave Select Strobe feature is enabled

Parameters
baseQUEUEDSPI peripheral address.
eLogicLevellogic level
static void QSPI_MasterEnableSlaveSelectOpenDrainMode ( QSPI_Type *  base,
bool  bEnable 
)
inlinestatic

Enable it means SS_B is configured for high and low drive. This mode is generally used in single master systems. Disable it means SS_B is configured as an open drain pin (only drives low output level). This mode is useful for multiple master systems

Parameters
baseQUEUEDSPI peripheral address.
bEnableEnable/Disable option.
static void QSPI_MasterEnableSlaveSelectAutomaticMode ( QSPI_Type *  base,
bool  bEnable 
)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
bEnableEnable/Disable option.
static void QSPI_SetSlaveSelectDirection ( QSPI_Type *  base,
qspi_ss_direction_t  eDirection 
)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
eDirectionoptions from _qspi_ssb_direction
static void QSPI_MasterEnableSlaveSelectStrobe ( QSPI_Type *  base,
bool  bEnable 
)
inlinestatic

If enabled, Slave select pulse high during data frames irrespective of Clock Phase configuration

Parameters
baseQUEUEDSPI peripheral address.
bEnableEnable/Disable option.
static void QSPI_EnableSlaveSelectOverride ( QSPI_Type *  base,
bool  bEnable 
)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
bEnableEnable/Disable option.
void QSPI_SetDummyData ( QSPI_Type *  base,
uint8_t  u8DummyData 
)
Parameters
baseQUEUEDSPI peripheral address.
u8DummyDataData to be transferred when tx buffer is NULL.
uint8_t QSPI_GetDummyData ( QSPI_Type *  base)
Parameters
baseQUEUEDSPI peripheral base address.
static void QSPI_WriteData ( QSPI_Type *  base,
uint16_t  data 
)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
dataThe data to send.
static uint16_t QSPI_ReadData ( QSPI_Type *  base)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
Returns
The data from the receive data register.
static void QSPI_EnableFifo ( QSPI_Type *  base,
bool  bEnable 
)
inlinestatic

This function allows the caller to disable or enable the TX and RX FIFOs together.

Parameters
baseQUEUEDSPI peripheral address.
bEnablePass true to enable, pass false to disable
static uint16_t QSPI_GetTxFIFOCount ( QSPI_Type *  base)
inlinestatic

This function gets how many words are in the TX FIFO.

Parameters
baseQUEUEDSPI peripheral address.
Returns
TX FIFO word count.
static uint16_t QSPI_GetRxFIFOCount ( QSPI_Type *  base)
inlinestatic

This function gets how many words are in the RX FIFO.

Parameters
baseQUEUEDSPI peripheral address.
Returns
RX FIFO word count.
static void QSPI_SetFifoWatermarks ( QSPI_Type *  base,
uint16_t  txWatermark,
uint16_t  rxWatermark 
)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
txWatermarkThe TX FIFO watermark value. Refer to qspi_txfifo_watermark_t for available values.
rxWatermarThe RX FIFO watermark value. Refer to qspi_rxfifo_watermark_t for available values.
static void QSPI_GetFifoWatermarks ( QSPI_Type *  base,
uint8_t *  pu8TxWatermark,
uint8_t *  pu8RxWatermark 
)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
pu8TxWatermarkThe TX FIFO watermark value.
pu8RxWatermarkThe RX FIFO watermark value.
static void QSPI_EmptyRxFifo ( QSPI_Type *  base)
inlinestatic
Parameters
baseQUEUEDSPI peripheral address.
void QSPI_MasterTransferCreateHandle ( QSPI_Type *  base,
qspi_master_transfer_handle_t *  psHandle,
qspi_master_transfer_callback_t  pfCallback,
void *  pUserData 
)

This function initializes the QUEUEDSPI handle, which can be used for other QUEUEDSPI transactional APIs. Usually, for a specified QUEUEDSPI instance, call this API once to get the initialized handle.

Note
If only use the QSPI_MasterTransferBlocking, this API is not necessary be called.
Parameters
psHandleQUEUEDSPI handle pointer to qspi_master_transfer_handle_t.
pfCallbackQUEUEDSPI callback.
pUserDataCallback function parameter.
status_t QSPI_MasterTransferBlocking ( QSPI_Type *  base,
qspi_transfer_t psXfer 
)

This function transfers data using a polling method for master. This is a blocking function, which does not return until all transfers have been completed.

Parameters
psXferPointer to the qspi_transfer_t structure.
Returns
status of status_t.
status_t QSPI_MasterTransferNonBlocking ( qspi_master_transfer_handle_t *  psHandle,
qspi_transfer_t psXfer 
)

This function transfers data using interrupts for master. This is a non-blocking function, which returns right away. When all data is transferred, the callback function is called.

Parameters
psHandleQUEUEDSPI handle pointer to qspi_master_transfer_handle_t.
psXferPointer to the qspi_transfer_t structure.
Returns
status of status_t.
status_t QSPI_MasterTransferGetCount ( qspi_master_transfer_handle_t *  psHandle,
uint16_t *  pu16Count 
)
Parameters
psHandleQUEUEDSPI handle pointer to qspi_master_transfer_handle_t.
pu16CountThe number of bytes transferred by using the non-blocking transaction.
Returns
status of status_t.
void QSPI_MasterTransferAbort ( qspi_master_transfer_handle_t *  psHandle)
Parameters
psHandleQUEUEDSPI handle pointer to qspi_master_transfer_handle_t.
void QSPI_MasterTransferHandleIRQ ( qspi_master_transfer_handle_t *  psHandle)

This function processes the QUEUEDSPI transmit and receive IRQ.

Parameters
psHandleQUEUEDSPI handle pointer to qspi_master_transfer_handle_t.
void QSPI_SlaveTransferCreateHandle ( QSPI_Type *  base,
qspi_slave_transfer_handle_t *  psHandle,
qspi_slave_transfer_callback_t  pfCallback,
void *  pUserData 
)

This function initializes the QUEUEDSPI handle, which can be used for other QUEUEDSPI transactional APIs. Usually, for a specified QUEUEDSPI instance, call this API once to get the initialized handle.

Parameters
baseQUEUEDSPI peripheral base address.
psHandleQUEUEDSPI handle pointer to the qspi_slave_transfer_handle_t.
pfCallbackQUEUEDSPI callback.
pUserDataCallback function parameter.
status_t QSPI_SlaveTransferNonBlocking ( qspi_slave_transfer_handle_t *  psHandle,
qspi_transfer_t psXfer 
)

This function transfers data using interrupts for slave. This is a non-blocking function, which returns right away. When all data is transferred, the callback function is called.

Parameters
baseQUEUEDSPI peripheral base address.
psHandlePointer to the qspi_slave_transfer_handle_t structure which stores the transfer state.
psXferPointer to the qspi_transfer_t structure.
Returns
status of status_t.
status_t QSPI_SlaveTransferGetCount ( qspi_slave_transfer_handle_t *  psHandle,
uint16_t *  pu16Count 
)
Parameters
psHandlePointer to the qspi_slave_transfer_handle_t structure which stores the transfer state.
pu16CountThe number of bytes transferred by using the non-blocking transaction.
Returns
status of status_t.
void QSPI_SlaveTransferAbort ( qspi_slave_transfer_handle_t *  psHandle)
Parameters
baseQUEUEDSPI peripheral base address.
psHandlePointer to the qspi_slave_transfer_handle_t structure which stores the transfer state.
void QSPI_SlaveTransferHandleIRQ ( qspi_slave_transfer_handle_t *  psHandle)

This function processes the QUEUEDSPI transmit and receive IRQ.

Parameters
psHandlePointer to the qspi_slave_transfer_handle_t structure which stores the transfer state.

Variable Documentation

volatile uint16_t g_u8QueuedSpiDummyData[]