MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
QSCI: Queued Serial Communications Interface 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

 QSCI Peripheral and Driver Overview
 Content including 1) peripheral features, work logic and work method; 2) driver design logic and use method; 3) typical use case.
 
 The Driver Change Log
 The current QSCI driver version is 2.0.0.
 

Data Structures

struct  qsci_config_t
 QSCI configuration structure. More...
 
struct  qsci_transfer_handle_t
 QSCI transfer handle. More...
 
struct  qsci_transfer_t
 QSCI transfer structure. More...
 

Macros

#define QSCI_RETRY_TIMES   0U /* Default defines to zero, driver keeps checking status flag untill it changes. */
 Retry times when checking status flags. More...
 
#define QSCI_GET_BUS_STATUS(psHandle)   (psHandle)->busStatus
 Macros to be used inside user callback. More...
 

Typedefs

typedef void(* qsci_transfer_callback_t )(qsci_transfer_handle_t *psHandle)
 QSCI interrupt transfer callback function definition. More...
 

Enumerations

enum  {
  kStatus_QSCI_TxBusy = MAKE_STATUS(kStatusGroup_QSCI, 0U),
  kStatus_QSCI_RxBusy = MAKE_STATUS(kStatusGroup_QSCI, 1U),
  kStatus_QSCI_TxIdle = MAKE_STATUS(kStatusGroup_QSCI, 2U),
  kStatus_QSCI_RxIdle = MAKE_STATUS(kStatusGroup_QSCI, 3U),
  kStatus_QSCI_FlagCannotClearManually,
  kStatus_QSCI_RxRingBufferOverrun = MAKE_STATUS(kStatusGroup_QSCI, 5U),
  kStatus_QSCI_RxHardwareOverrun = MAKE_STATUS(kStatusGroup_QSCI, 6U),
  kStatus_QSCI_NoiseError = MAKE_STATUS(kStatusGroup_QSCI, 7U),
  kStatus_QSCI_FramingError = MAKE_STATUS(kStatusGroup_QSCI, 8U),
  kStatus_QSCI_ParityError = MAKE_STATUS(kStatusGroup_QSCI, 9U),
  kStatus_QSCI_BaudrateNotSupport,
  kStatus_QSCI_IdleLineDetected = MAKE_STATUS(kStatusGroup_QSCI, 11),
  kStatus_QSCI_Timeout
}
 Status codes for the QSCI driver. More...
 
enum  _qsci_status_flags {
  kQSCI_TxDataRegEmptyFlag = QSCI_STAT_TDRE_MASK,
  kQSCI_TxIdleFlag = QSCI_STAT_TIDLE_MASK,
  kQSCI_RxDataRegFullFlag = QSCI_STAT_RDRF_MASK,
  kQSCI_RxIdleLineFlag = QSCI_STAT_RIDLE_MASK,
  kQSCI_RxOverrunFlag = QSCI_STAT_OR_MASK,
  kQSCI_RxNoiseFlag = QSCI_STAT_NF_MASK,
  kQSCI_RxFrameErrorFlag = QSCI_STAT_FE_MASK,
  kQSCI_RxParityErrorFlag,
  kQSCI_RxInputEdgeFlag,
  kQSCI_LINSyncErrorFlag = QSCI_STAT_LSE_MASK,
  kQSCI_TxDMARequestFlag = QSCI_STAT_TDMA_MASK,
  kQSCI_RxDMARequestFlag = QSCI_STAT_RDMA_MASK ,
  kQSCI_Group0Flags,
  kQSCI_Group1Flags,
  kQSCI_Group2Flags
}
 QSCI hardware status flags. More...
 
enum  _qsci_interrupt_enable {
  kQSCI_TxEmptyInterruptEnable = QSCI_CTRL1_TEIE_MASK,
  kQSCI_TxIdleInterruptEnable = QSCI_CTRL1_TIIE_MASK,
  kQSCI_RxFullInterruptEnable = QSCI_CTRL1_RFIE_MASK,
  kQSCI_RxErrorInterruptEnable = QSCI_CTRL1_REIE_MASK,
  kQSCI_RxInputEdgeInterruptEnable = QSCI_CTRL2_RIEIE_MASK >> 2U,
  kQSCI_RxIdleLineInterruptEnable = QSCI_CTRL2_RIIE_MASK >> 2U
}
 QSCI interrupt enable/disable source. More...
 
enum  qsci_transfer_mode_t {
  kQSCI_Normal = 0U,
  kQSCI_LoopInternal = 1U,
  kQSCI_SingleWire = 2U
}
 QSCI transmiter/receiver loop mode. More...
 
enum  qsci_data_bit_mode_t {
  kQSCI_Data8Bit = 0U,
  kQSCI_Data9Bit
}
 QSCI data bit count. More...
 
enum  qsci_wakeup_mode_t {
  kQSCI_WakeupOnIdleLine = 0U,
  kQSCI_WakeupOnAddressMark = 1U
}
 QSCI wakeup mode. More...
 
enum  qsci_polarity_mode_t {
  kQSCI_PolarityNormal = 0U,
  kQSCI_PolarityInvert = 1U
}
 QSCI signal polarity mode. More...
 
enum  qsci_parity_mode_t {
  kQSCI_ParityDisabled = 0x0U,
  kQSCI_ParityEven = 0x1U,
  kQSCI_ParityOdd = 0x2U
}
 QSCI parity mode. More...
 
enum  qsci_tx_water_t {
  kQSCI_TxWater0Word = 0x0U,
  kQSCI_TxWater1Word = 0x1U,
  kQSCI_TxWater2Word = 0x2U,
  kQSCI_TxWater3Word = 0x3U
}
 QSCI transmitter watermark level. More...
 
enum  qsci_rx_water_t {
  kQSCI_RxWater1Word = 0x0U,
  kQSCI_RxWater2Word = 0x1U,
  kQSCI_RxWater3Word = 0x2U,
  kQSCI_RxWater4Word = 0x3U
}
 QSCI receiver watermark level. More...
 

Functions

uint16_t QSCI_GetInstance (QSCI_Type *base)
 Get the QSCI instance from peripheral base address. More...
 

Driver version

#define FSL_QSCI_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 

Module Init/Deinit Sub-group

void QSCI_GetDefaultConfig (qsci_config_t *psConfig, uint32_t u32BaudRateBps, uint32_t u32SrcClockHz)
 Sets the QSCI configuration structure to default values. More...
 
status_t QSCI_Init (QSCI_Type *base, qsci_config_t *psConfig)
 Initializes the QSCI instance with a user configuration structure. More...
 
void QSCI_Deinit (QSCI_Type *base)
 Deinitializes a QSCI instance. More...
 

Hardware Status Flags Sub-group

static uint16_t QSCI_GetStatusFlags (QSCI_Type *base)
 Gets QSCI hardware status flags. More...
 
void QSCI_ClearStatusFlags (QSCI_Type *base, uint16_t u16StatusFlags)
 Clears QSCI status flags. More...
 

Interrupt Sub-group

void QSCI_EnableInterrupts (QSCI_Type *base, uint8_t u8Interrupts)
 Enables QSCI interrupts according to the provided mask. More...
 
void QSCI_DisableInterrupts (QSCI_Type *base, uint8_t u8Interrupts)
 Disables QSCI interrupts according to the provided mask. More...
 
uint8_t QSCI_GetEnabledInterrupts (QSCI_Type *base)
 Gets the enabled QSCI interrupts. More...
 

General Peripheral Configuration Sub-group

static void QSCI_Reset (QSCI_Type *base)
 Sets the QSCI register value to reset value. More...
 
static void QSCI_EnableTx (QSCI_Type *base, bool bEnable)
 Enables or disables the QSCI transmitter. More...
 
static void QSCI_EnableRx (QSCI_Type *base, bool bEnable)
 Enables or disables the QSCI receiver. More...
 
static void QSCI_EnableStopInWait (QSCI_Type *base, bool bEnable)
 Enables/disables stop in wait. More...
 
static void QSCI_Enable9bitMode (QSCI_Type *base, bool bEnable)
 Enables/Disables 9-bit data mode for QSCI. More...
 
static void QSCI_EnableStandbyMode (QSCI_Type *base, bool bEnable)
 Enables/Disables standby mode. More...
 
static void QSCI_EnableLINSlaveMode (QSCI_Type *base, bool bEnable)
 Enable/Disable LIN slave mode. More...
 
static void QSCI_EnableStopHold (QSCI_Type *base, bool bEnable)
 Enable/Disable stop mode hold off. More...
 
static void QSCI_SetTransferMode (QSCI_Type *base, qsci_transfer_mode_t eTransferMode)
 Sets the QSCI transfer mode. More...
 
static void QSCI_SetWakeupMode (QSCI_Type *base, qsci_wakeup_mode_t eWakeupMode)
 Sets wakeup mode for QSCI. More...
 
static void QSCI_SetPolarityMode (QSCI_Type *base, qsci_polarity_mode_t ePolarityMode)
 Sets polarity mode for QSCI. More...
 
static void QSCI_SetParityMode (QSCI_Type *base, qsci_parity_mode_t eParityMode)
 Sets parity mode for QSCI. More...
 
status_t QSCI_SetBaudRate (QSCI_Type *base, uint32_t u32BaudRateBps, uint32_t u32SrcClockHz)
 Sets the QSCI instance baud rate. More...
 

FIFO Configuration Sub-group

static void QSCI_EnableFifo (QSCI_Type *base, bool bEnable)
 Enables/Disables transmitter/receiver FIFO. More...
 
static void QSCI_SetTxWaterMark (QSCI_Type *base, qsci_tx_water_t eTxFifoWatermark)
 Sets transmitter watermark. More...
 
static void QSCI_SetRxWaterMark (QSCI_Type *base, qsci_rx_water_t eRxFifoWatermark)
 Sets receiver watermark. More...
 

DMA Configuration Sub-group

static void QSCI_EnableTxDMA (QSCI_Type *base, bool bEnable)
 Enables or disables the QSCI transmitter DMA request. More...
 
static void QSCI_EnableRxDMA (QSCI_Type *base, bool bEnable)
 Enables or disables the QSCI receiver DMA request. More...
 
static uint32_t QSCI_GetDataRegisterAddress (QSCI_Type *base)
 Gets the QSCI data register byte address. More...
 

Bus Operation Sub-group

static void QSCI_WriteByte (QSCI_Type *base, uint8_t u8Data)
 Writes to the TX register. More...
 
static void QSCI_SendAddress (QSCI_Type *base, uint8_t u8Address)
 Sends an address frame in 9-bit data mode. More...
 
static uint8_t QSCI_ReadByte (QSCI_Type *base)
 Reads the RX register directly. More...
 
void QSCI_WriteBlocking (QSCI_Type *base, const uint8_t *pu8Data, uint32_t u32Length)
 Writes TX register using a blocking method. More...
 
status_t QSCI_ReadBlocking (QSCI_Type *base, uint8_t *pu8Data, uint32_t u32Length)
 Reads RX data register using a blocking method. More...
 
static void QSCI_SendBreak (QSCI_Type *base)
 Sends one break character (10 or 11 bits of zeroes). More...
 

Transactional APIs

void QSCI_TransferCreateHandle (QSCI_Type *base, qsci_transfer_handle_t *psHhandle, qsci_transfer_callback_t pfCallback, void *pUserData)
 Initializes the QSCI handle. More...
 
void QSCI_TransferStartRingBuffer (qsci_transfer_handle_t *psHandle, uint8_t *pu8RxRingBuffer, uint16_t u16RxRingBufferSize)
 Sets up the RX ring buffer. More...
 
void QSCI_TransferStopRingBuffer (qsci_transfer_handle_t *psHandle)
 Aborts the background transfer and uninstalls the ring buffer. More...
 
uint16_t QSCI_TransferGetRxRingBufferLength (qsci_transfer_handle_t *psHandle)
 Get the ring buffer valid data length. More...
 
status_t QSCI_TransferSendNonBlocking (qsci_transfer_handle_t *psHandle, qsci_transfer_t *psTransfer)
 Transmits a buffer of data using the interrupt method. More...
 
void QSCI_TransferAbortSend (qsci_transfer_handle_t *psHandle)
 Aborts the interrupt-driven data transmit. More...
 
status_t QSCI_TransferGetSendCount (qsci_transfer_handle_t *psHandle, uint32_t *pu32Count)
 Gets the number of bytes sent out to bus. More...
 
status_t QSCI_TransferReceiveNonBlocking (qsci_transfer_handle_t *psHandle, qsci_transfer_t *psTransfer, size_t *pu32ReceivedBytes)
 Receives a buffer of data using an interrupt method. More...
 
void QSCI_TransferAbortReceive (qsci_transfer_handle_t *psHandle)
 Aborts the interrupt-driven data receiving. More...
 
status_t QSCI_TransferGetReceiveCount (qsci_transfer_handle_t *psHandle, uint32_t *pu32Count)
 Gets the number of bytes that have been received. More...
 

Data Structure Documentation

struct qsci_config_t

Data Fields

qsci_transfer_mode_t eTransferMode: 2
 Transmitter/receiver loop mode. More...
 
bool bStopInWaitEnable: 1
 Enable/disable module stops working in wait mode. More...
 
qsci_data_bit_mode_t eDataBitMode: 1
 Number of data bits. More...
 
qsci_wakeup_mode_t eWakeupMode: 1
 Receiver wakeup mode, idle line or addressmark. More...
 
qsci_polarity_mode_t ePolarityMode: 1
 Polarity of transmit/receive data. More...
 
qsci_parity_mode_t eParityMode: 2
 Parity mode, disabled (default), even, odd. More...
 
bool bEnableStopHold: 1
 Control the stop hold enable. More...
 
bool bEnableTx: 1
 Enable TX.
 
bool bEnableRx: 1
 Enable RX.
 
bool bEnableFifo: 1
 Enable Tx/Rx FIFO.
 
bool bEnableTxDMA: 1
 Enable Tx DMA.
 
bool bEnableRxDMA: 1
 Enable Rx DMA.
 
qsci_tx_water_t eTxFifoWatermark: 2
 TX FIFO watermark.
 
qsci_rx_water_t eRxFifoWatermark: 2
 RX FIFO watermark.
 
uint8_t u8Interrupts
 Mask of QSCI interrupt sources to enable. More...
 
uint32_t u32BaudRateBps
 QSCI baud rate.
 
uint32_t u32SrcClockHz
 The clock source frequency for QSCI module. More...
 

Field Documentation

qsci_transfer_mode_t qsci_config_t::eTransferMode
bool qsci_config_t::bStopInWaitEnable
qsci_data_bit_mode_t qsci_config_t::eDataBitMode
qsci_wakeup_mode_t qsci_config_t::eWakeupMode
qsci_polarity_mode_t qsci_config_t::ePolarityMode
qsci_parity_mode_t qsci_config_t::eParityMode
bool qsci_config_t::bEnableStopHold
uint8_t qsci_config_t::u8Interrupts
uint32_t qsci_config_t::u32SrcClockHz
struct _qsci_transfer_handle_t
Note
If user wants to use the transactional API to transfer data in interrupt way, one QSCI instance should and can only be allocated one handle.
The handle is maintained by QSCI driver internally, which means the transfer state is retained and user shall not modify its state u8TxState or u8RxState in application level. If user only wish to use transactional APIs without understanding its machanism, it is not necessary to understand these members.

Data Fields

QSCI_Type * base
 QSCI base pointer to the instance belongs to this handle. More...
 
uint8_t * pu8TxData
 Address of remaining data to send. More...
 
volatile uint32_t u32TxRemainingSize
 Size of the remaining data to send. More...
 
uint32_t u32TxDataSize
 Size of the data to send out. More...
 
uint8_t * pu8RxData
 Address of remaining data to receive. More...
 
volatile uint32_t u32RxRemainingSize
 Size of the remaining data to receive. More...
 
uint32_t u32RxDataSize
 Size of the data to receive. More...
 
uint8_t * pu8RxRingBuffer
 Start address of the receiver ring buffer. More...
 
uint16_t u16RxRingBufferSize
 Size of the ring buffer. More...
 
volatile uint16_t u16RxRingBufferHead
 Index for the driver to store received data into ring buffer. More...
 
volatile uint16_t u16RxRingBufferTail
 Index for the user to get data from the ring buffer. More...
 
qsci_transfer_callback_t pfCallback
 Callback function. More...
 
void * pUserData
 QSCI callback function parameter. More...
 
volatile uint8_t u8TxState
 TX transfer state. More...
 
volatile uint8_t u8RxState
 RX transfer state.
 
status_t busStatus
 QSCI bus status. More...
 

Field Documentation

QSCI_Type* qsci_transfer_handle_t::base
uint8_t* qsci_transfer_handle_t::pu8TxData
volatile uint32_t qsci_transfer_handle_t::u32TxRemainingSize
uint32_t qsci_transfer_handle_t::u32TxDataSize
uint8_t* qsci_transfer_handle_t::pu8RxData
volatile uint32_t qsci_transfer_handle_t::u32RxRemainingSize
uint32_t qsci_transfer_handle_t::u32RxDataSize
uint8_t* qsci_transfer_handle_t::pu8RxRingBuffer
uint16_t qsci_transfer_handle_t::u16RxRingBufferSize
volatile uint16_t qsci_transfer_handle_t::u16RxRingBufferHead
volatile uint16_t qsci_transfer_handle_t::u16RxRingBufferTail
qsci_transfer_callback_t qsci_transfer_handle_t::pfCallback
void* qsci_transfer_handle_t::pUserData
volatile uint8_t qsci_transfer_handle_t::u8TxState
status_t qsci_transfer_handle_t::busStatus
struct qsci_transfer_t

Data Fields

uint8_t * pu8Data
 The buffer pointer of data to be transferred. More...
 
uint32_t u32DataSize
 The byte count to be transferred. More...
 

Field Documentation

uint8_t* qsci_transfer_t::pu8Data
uint32_t qsci_transfer_t::u32DataSize

Macro Definition Documentation

#define QSCI_RETRY_TIMES   0U /* Default defines to zero, driver keeps checking status flag untill it changes. */
#define QSCI_GET_BUS_STATUS (   psHandle)    (psHandle)->busStatus

Typedef Documentation

typedef void(* qsci_transfer_callback_t)(qsci_transfer_handle_t *psHandle)

Defines the interface of user callback function used in QSCI interrupt transfer using transactional APIs. The callback function shall be defined and declared in application level by user. Before starting QSCI transmiting or receiving by calling QSCI_TransferSendNonBlocking or QSCI_TransferReceiveNonBlocking, call QSCI_TransferCreateHandle to install the user callback. When the transmiting or receiving ends or any bus error like hardware overrun occurs, user callback will be invoked by driver.

Parameters
psHandleTransfer handle that contains bus status, user data.

Enumeration Type Documentation

anonymous enum
Enumerator
kStatus_QSCI_TxBusy 

Transmitter is busy.

kStatus_QSCI_RxBusy 

Receiver is busy.

kStatus_QSCI_TxIdle 

Transmitter is idle.

kStatus_QSCI_RxIdle 

Receiver is idle.

kStatus_QSCI_FlagCannotClearManually 

Status flag can't be manually cleared.

kStatus_QSCI_RxRingBufferOverrun 

QSCI RX software ring buffer overrun.

kStatus_QSCI_RxHardwareOverrun 

QSCI receiver hardware overrun.

kStatus_QSCI_NoiseError 

QSCI noise error.

kStatus_QSCI_FramingError 

QSCI framing error.

kStatus_QSCI_ParityError 

QSCI parity error.

kStatus_QSCI_BaudrateNotSupport 

Baudrate is not supported in current clock source.

kStatus_QSCI_IdleLineDetected 

QSCI IDLE line detected.

kStatus_QSCI_Timeout 

Timeout happens when waiting for status flags to change.

These enumerations can be ORed together to form bit masks.

Enumerator
kQSCI_TxDataRegEmptyFlag 

TX data register empty flag.

kQSCI_TxIdleFlag 

Transmission idle flag.

kQSCI_RxDataRegFullFlag 

RX data register full flag.

kQSCI_RxIdleLineFlag 

Rx Idle line flag.

kQSCI_RxOverrunFlag 

RX overrun flag.

kQSCI_RxNoiseFlag 

RX detect noise on Rx input.

kQSCI_RxFrameErrorFlag 

Rx frame error flag, sets if logic 0 was detected for stop bit.

kQSCI_RxParityErrorFlag 

Rx parity error if parity enabled, sets upon parity error detection.

kQSCI_RxInputEdgeFlag 

RX pin active edge interrupt flag, sets when active edge detected.

kQSCI_LINSyncErrorFlag 

Only for LIN mode.

kQSCI_TxDMARequestFlag 

Tx DMA request is ongoing.

kQSCI_RxDMARequestFlag 

Rx DMA request is ongoing.

kQSCI_Group0Flags 

Members in kQSCI_Group0Flags can't be cleared by QSCI_ClearStatusFlags, they are handled by HW.

kQSCI_Group1Flags 

Whole kQSCI_Group1Flags will be cleared if trying to clear any member in kQSCI_Group1Flags or kQSCI_Group2Flags in the mask.

kQSCI_Group2Flags 

Member in kQSCI_Group2Flags can be cleared individually.

These enumerations can be ORed together to form bit masks.

Enumerator
kQSCI_TxEmptyInterruptEnable 

Transmit data register empty interrupt.

kQSCI_TxIdleInterruptEnable 

Transmission idle interrupt.

kQSCI_RxFullInterruptEnable 

Receive data register full interrupt.

kQSCI_RxErrorInterruptEnable 

Receive error interrupt.

kQSCI_RxInputEdgeInterruptEnable 

Receive input edge interrupt.

kQSCI_RxIdleLineInterruptEnable 

Receive idle interrupt.

Enumerator
kQSCI_Normal 

Normal mode, 2 signal pins, no loop.

kQSCI_LoopInternal 

Loop mode with internal TXD fed back to RXD.

kQSCI_SingleWire 

Use tx pin as input and output half-duplex transfer.

Enumerator
kQSCI_Data8Bit 

1 start bit, 8 data bit, 1 stop bit

kQSCI_Data9Bit 

1 start bit, 9 data bit, 1 stop bit.

This mode actually is not supported yet in driver.

Enumerator
kQSCI_WakeupOnIdleLine 

Idle condition wakes the QSCI module.

kQSCI_WakeupOnAddressMark 

Address mark wakes the QSCI module.

Enumerator
kQSCI_PolarityNormal 

Normal mode, no inversion.

kQSCI_PolarityInvert 

Invert transmit and receive data bits.

Enumerator
kQSCI_ParityDisabled 

Parity disabled.

kQSCI_ParityEven 

Parity enabled, type even, bit setting: PE|PT = 10.

kQSCI_ParityOdd 

Parity enabled, type odd, bit setting: PE|PT = 11.

Enumerator
kQSCI_TxWater0Word 

Tx interrupt sets when tx fifo empty.

kQSCI_TxWater1Word 

Tx interrupt sets when tx fifo has 1 or few word.

kQSCI_TxWater2Word 

Tx interrupt sets when tx fifo has 2 or few words.

kQSCI_TxWater3Word 

Tx interrupt sets when tx fifo not full.

Enumerator
kQSCI_RxWater1Word 

Rx interrupt sets when rx fifo not empty.

kQSCI_RxWater2Word 

Rx interrupt sets when rx fifo has at least 1 word.

kQSCI_RxWater3Word 

Rx interrupt sets when rx fifo has at least 2 words.

kQSCI_RxWater4Word 

Rx interrupt sets when rx fifo full.

Function Documentation

void QSCI_GetDefaultConfig ( qsci_config_t psConfig,
uint32_t  u32BaudRateBps,
uint32_t  u32SrcClockHz 
)

The purpose of this API is to initialize the configuration structure to default value for QSCI_Init to use. Use the unchanged structure in QSCI_Init or modify the structure before calling QSCI_Init. This is an example:

* qsci_config_t sConfig;
* QSCI_GetDefaultConfig(&sConfig, 115200, 12000000U);
* QSCI_Init(QSCI0, &config);
*
Parameters
psConfigPointer to configuration structure.
u32BaudRateBpsBaudrate setting.
u32SrcClockHzThe clock source frequency for QSCI module.
status_t QSCI_Init ( QSCI_Type *  base,
qsci_config_t psConfig 
)

This function configures the QSCI module with the customed settings. User can configure the configuration structure manually or get the default configuration by using the QSCI_GetDefaultConfig function. The example below shows how to use this API to configure QSCI.

* qsci_config_t sConfig;
* QSCI_GetDefaultConfig(&sConfig, 115200, 12000000U);
* QSCI_Init(QSCI0, &sConfig);
*
Parameters
baseQSCI peripheral base address.
psConfigPointer to the user-defined configuration structure.
Return values
kStatus_QSCI_BaudrateNotSupportBaudrate is not supported in the current clock source.
kStatus_SuccessSet baudrate succeeded.
void QSCI_Deinit ( QSCI_Type *  base)

This function waits for transmiting complete, then disables TX and RX.

Parameters
baseQSCI peripheral base address.
static uint16_t QSCI_GetStatusFlags ( QSCI_Type *  base)
inlinestatic
Parameters
baseQSCI peripheral base address.
Returns
QSCI status flags, can be a single flag or several flags in _qsci_status_flags combined by OR.
void QSCI_ClearStatusFlags ( QSCI_Type *  base,
uint16_t  u16StatusFlags 
)

This function clears QSCI status flags. Members in kQSCI_Group0Flags can't be cleared by this function, they are cleared or set by hardware.

Parameters
baseQSCI peripheral base address.
u16StatusFlagsThe status flag mask, can be a single flag or several flags in _qsci_status_flags combined by OR.
void QSCI_EnableInterrupts ( QSCI_Type *  base,
uint8_t  u8Interrupts 
)

This function enables the QSCI interrupts according to the provided mask. The mask is a logical OR of enumeration members in _qsci_interrupt_enable.

Parameters
baseQSCI peripheral base address.
u8InterruptsThe interrupt source mask, can be a single source or several sources in _qsci_interrupt_enable combined by OR.
void QSCI_DisableInterrupts ( QSCI_Type *  base,
uint8_t  u8Interrupts 
)

This function disables the QSCI interrupts according to the provided mask. The mask is a logical OR of enumeration members in _qsci_interrupt_enable.

Parameters
baseQSCI peripheral base address.
u8InterruptsThe interrupt source mask, can be a single source or several sources in _qsci_interrupt_enable combined by OR.
uint8_t QSCI_GetEnabledInterrupts ( QSCI_Type *  base)

This function gets the enabled QSCI interrupts. The enabled interrupts are returned as the logical OR value of the enumerators _qsci_interrupt_enable.

Parameters
baseQSCI peripheral base address.
Returns
The interrupt source mask, can be a single source or several sources in _qsci_interrupt_enable combined by OR.
static void QSCI_Reset ( QSCI_Type *  base)
inlinestatic
Parameters
baseQSCI peripheral base address.
static void QSCI_EnableTx ( QSCI_Type *  base,
bool  bEnable 
)
inlinestatic

This function enables or disables the QSCI transmitter.

Parameters
baseQSCI peripheral base address.
bEnableTrue to enable, false to disable.
static void QSCI_EnableRx ( QSCI_Type *  base,
bool  bEnable 
)
inlinestatic

This function enables or disables the QSCI receiver.

Parameters
baseQSCI peripheral base address.
bEnableTrue to enable, false to disable.
static void QSCI_EnableStopInWait ( QSCI_Type *  base,
bool  bEnable 
)
inlinestatic
Parameters
baseQSCI peripheral base address.
bEnabletrue to enable, QSCI stops working in wait mode, false to disable, QSCI keeps working in wait mode
static void QSCI_Enable9bitMode ( QSCI_Type *  base,
bool  bEnable 
)
inlinestatic
Parameters
baseQSCI peripheral base address.
bEnabletrue to enable, false to disable.
static void QSCI_EnableStandbyMode ( QSCI_Type *  base,
bool  bEnable 
)
inlinestatic

When QSCI is in standby mode, further receiver interrupt requests are inhibited waiting to be wake up. The wakeup mode can be configured by QSCI_SetWakeupMode. Hardware wakes the receiver by automatically disabling standby.

Parameters
baseQSCI peripheral base address.
bEnabletrue to enable, false to disable.
static void QSCI_EnableLINSlaveMode ( QSCI_Type *  base,
bool  bEnable 
)
inlinestatic

If enabled QSCI is in LIN slave mode. When break is detected, the baudrate register is automatically adjusted to match the value measured from the sync character that follows.

Parameters
baseQSCI peripheral base address.
bEnabletrue to enable, false to disable.
static void QSCI_EnableStopHold ( QSCI_Type *  base,
bool  bEnable 
)
inlinestatic

When enabled, if chip level stop mode occurs and transmiter or receiver is still busy, QSCI will hold off stop mode until both transmiter and receiver are idle.

Parameters
baseQSCI peripheral base address.
bEnabletrue to enable, false to disable.
static void QSCI_SetTransferMode ( QSCI_Type *  base,
qsci_transfer_mode_t  eTransferMode 
)
inlinestatic
Parameters
baseQSCI peripheral base address.
eTransferModeThe QSCI tx/rx loop mode, kQSCI_Normal to use normal transfer, kQSCI_LoopInternal to let internal tx feed back to rx, kQSCI_SingleWire to use single wire mode using tx pin as tx and rx.
static void QSCI_SetWakeupMode ( QSCI_Type *  base,
qsci_wakeup_mode_t  eWakeupMode 
)
inlinestatic
Parameters
baseQSCI peripheral base address.
eWakeupModeWakeup mode, kQSCI_WakeupOnIdleLine or kQSCI_WakeupOnAddressMark.
static void QSCI_SetPolarityMode ( QSCI_Type *  base,
qsci_polarity_mode_t  ePolarityMode 
)
inlinestatic
Parameters
baseQSCI peripheral base address.
ePolarityModePolarity mode, kQSCI_PolarityNormal or kQSCI_PolarityInvert.
static void QSCI_SetParityMode ( QSCI_Type *  base,
qsci_parity_mode_t  eParityMode 
)
inlinestatic
Parameters
baseQSCI peripheral base address.
eParityModePolarity mode, kQSCI_ParityDisabled, kQSCI_ParityEven or kQSCI_ParityOdd.
status_t QSCI_SetBaudRate ( QSCI_Type *  base,
uint32_t  u32BaudRateBps,
uint32_t  u32SrcClockHz 
)

This function configures the QSCI module baud rate. This function can be used to update QSCI module baud rate after the QSCI module is initialized by the QSCI_Init.

Parameters
baseQSCI peripheral base address.
u32BaudRateBpsQSCI baudrate to be set.
u32SrcClockHzQSCI clock source frequency in Hz.
Return values
kStatus_QSCI_BaudrateNotSupportBaudrate is not supported in the current clock source.
kStatus_SuccessSet baudrate succeeded.
static void QSCI_EnableFifo ( QSCI_Type *  base,
bool  bEnable 
)
inlinestatic
Parameters
baseQSCI peripheral base address.
bEnabletrue to enable, false to disable.
static void QSCI_SetTxWaterMark ( QSCI_Type *  base,
qsci_tx_water_t  eTxFifoWatermark 
)
inlinestatic
Parameters
baseQSCI peripheral base address.
eTxFifoWatermarkTx water mark level.
static void QSCI_SetRxWaterMark ( QSCI_Type *  base,
qsci_rx_water_t  eRxFifoWatermark 
)
inlinestatic
Parameters
baseQSCI peripheral base address.
eRxFifoWatermarkRx water mark level.
static void QSCI_EnableTxDMA ( QSCI_Type *  base,
bool  bEnable 
)
inlinestatic

This function enables or disables CTRL2[TDE], to generate the DMA requests when Tx data register is empty.

Parameters
baseQSCI peripheral base address.
bEnableTrue to enable, false to disable.
static void QSCI_EnableRxDMA ( QSCI_Type *  base,
bool  bEnable 
)
inlinestatic

This function enables or disables CTRL2[RDE], to generate DMA requests when receiver data register is full.

Parameters
baseQSCI peripheral base address.
bEnableTrue to enable, false to disable.
static uint32_t QSCI_GetDataRegisterAddress ( QSCI_Type *  base)
inlinestatic

This function returns the QSCI data register address, which is mainly used by DMA/eDMA.

Parameters
baseQSCI peripheral base address.
Returns
QSCI data register byte addresses which are used both by the transmitter and the receiver.
static void QSCI_WriteByte ( QSCI_Type *  base,
uint8_t  u8Data 
)
inlinestatic

This function writes data to the TX register directly. The upper layer must ensure that the TX register is empty or TX FIFO has room before calling this function.

Parameters
baseQSCI peripheral base address.
u8DataThe byte to write.
static void QSCI_SendAddress ( QSCI_Type *  base,
uint8_t  u8Address 
)
inlinestatic
Parameters
baseQSCI peripheral base address.
u8AddressQSCI slave address.
static uint8_t QSCI_ReadByte ( QSCI_Type *  base)
inlinestatic

This function reads data from the RX register directly. The upper layer must ensure that the RX register is full or that the TX FIFO has data before calling this function.

Parameters
baseQSCI peripheral base address.
Returns
The byte read from QSCI data register.
void QSCI_WriteBlocking ( QSCI_Type *  base,
const uint8_t *  pu8Data,
uint32_t  u32Length 
)

This function polls the TX register, waits TX register to be empty or TX FIFO have room then writes data to the TX buffer.

Parameters
baseQSCI peripheral base address.
pu8DataStart address of the data to write.
u32LengthSize of the data to write.
status_t QSCI_ReadBlocking ( QSCI_Type *  base,
uint8_t *  pu8Data,
uint32_t  u32Length 
)

This function polls the RX register, waits RX register to be full or RX FIFO have data, then reads data from the RX register.

Parameters
baseQSCI peripheral base address.
pu8DataStart address of the buffer to store the received data.
u32LengthSize of the buffer.
Return values
kStatus_FailReceiver error occurred while receiving data.
kStatus_QSCI_RxHardwareOverrunReceiver overrun occurred while receiving data
kStatus_QSCI_NoiseErrorNoise error occurred while receiving data
kStatus_QSCI_FramingErrorFramingerror occurred while receiving data
kStatus_QSCI_ParityErrorParity error occurred while receiving data
kStatus_SuccessSuccessfully received all data.
static void QSCI_SendBreak ( QSCI_Type *  base)
inlinestatic
Parameters
baseQSCI peripheral base address.
void QSCI_TransferCreateHandle ( QSCI_Type *  base,
qsci_transfer_handle_t *  psHhandle,
qsci_transfer_callback_t  pfCallback,
void *  pUserData 
)

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

Parameters
baseQSCI peripheral base address.
psHhandleQSCI handle pointer.
pfCallbackThe callback function.
pUserDataThe parameter of the callback function.
void QSCI_TransferStartRingBuffer ( qsci_transfer_handle_t *  psHandle,
uint8_t *  pu8RxRingBuffer,
uint16_t  u16RxRingBufferSize 
)

This function sets up the RX ring buffer to a specific QSCI handle.

When the RX ring buffer is used, data received are stored into the ring buffer even when the user doesn't call the QSCI_TransferReceiveNonBlocking() API. If data is already received in the ring buffer, the user can get the received data from the ring buffer directly.

Note
When using the RX ring buffer, one byte is reserved for internal use. In other words, if ringBufferSize is 32, only 31 bytes are used for saving data.
Parameters
psHandleQSCI handle pointer.
pu8RxRingBufferStart address of the ring buffer for background receiving. Pass NULL to disable the ring buffer.
u16RxRingBufferSizeSize of the ring buffer.
void QSCI_TransferStopRingBuffer ( qsci_transfer_handle_t *  psHandle)

This function aborts the background transfer and uninstalls the ring buffer.

Parameters
psHandleQSCI handle pointer.
uint16_t QSCI_TransferGetRxRingBufferLength ( qsci_transfer_handle_t *  psHandle)
Parameters
psHandleQSCI handle pointer.
Returns
Valid data length in ring buffer.
status_t QSCI_TransferSendNonBlocking ( qsci_transfer_handle_t *  psHandle,
qsci_transfer_t psTransfer 
)

This function sends data using an interrupt method. This is a non-blocking function, which returns directly without waiting for all data to be written to the TX register. When all data is sent out, the QSCI driver calls the callback function and passes the kStatus_QSCI_TxIdle as status parameter.

Parameters
psHandleQSCI handle pointer.
psTransferQSCI transfer structure. See qsci_transfer_t.
Return values
kStatus_SuccessSuccessfully start the data transmission.
kStatus_QSCI_TxBusyPrevious transmission still not finished; data not all written to TX register yet.
void QSCI_TransferAbortSend ( qsci_transfer_handle_t *  psHandle)

This function aborts the interrupt-driven data sending. The user can get the remainBytes to find out how many bytes are not sent out.

Parameters
psHandleQSCI handle pointer.
status_t QSCI_TransferGetSendCount ( qsci_transfer_handle_t *  psHandle,
uint32_t *  pu32Count 
)

This function gets the number of bytes sent out to bus by using the interrupt method.

Parameters
psHandleQSCI handle pointer.
pu32CountSend bytes count.
Return values
kStatus_NoTransferInProgressNo send in progress.
kStatus_SuccessGet successfully through the parameter count;
status_t QSCI_TransferReceiveNonBlocking ( qsci_transfer_handle_t *  psHandle,
qsci_transfer_t psTransfer,
size_t *  pu32ReceivedBytes 
)

This function receives data using an interrupt method. This is a non-blocking function, which returns without waiting for all data to be received. If the RX ring buffer is used and not empty, the data in the ring buffer is copied and the parameter pu32ReceivedBytes shows how many bytes are copied from the ring buffer. After copying, if the data in the ring buffer is not enough to read, the receive request is saved by the QSCI driver. When the new data arrives, the receive request is serviced first. When all data is received, the QSCI driver notifies the upper layer through a callback function and passes the status parameter kStatus_QSCI_RxIdle. For example, the upper layer needs 10 bytes but there are only 5 bytes in the ring buffer. The 5 bytes are copied to the psTransfer->data and this function returns with the parameter pu32ReceivedBytes set to 5. For the left 5 bytes, newly arrived data is saved from the psTransfer->data[5]. When 5 bytes are received, the QSCI driver notifies the upper layer. If the RX ring buffer is not enabled, this function enables the RX and RX interrupt to receive data to the psTransfer->data. When all data is received, the upper layer is notified.

Parameters
psHandleQSCI handle pointer.
psTransferQSCI transfer structure, see qsci_transfer_t.
pu32ReceivedBytesBytes received from the ring buffer directly.
Return values
kStatus_SuccessSuccessfully queue the transfer into transmit queue.
kStatus_QSCI_RxBusyPrevious receive request is not finished.
void QSCI_TransferAbortReceive ( qsci_transfer_handle_t *  psHandle)

This function aborts the interrupt-driven data receiving. The user can get the remainBytes to know how many bytes are not received yet.

Parameters
psHandleQSCI handle pointer.
status_t QSCI_TransferGetReceiveCount ( qsci_transfer_handle_t *  psHandle,
uint32_t *  pu32Count 
)

This function gets the number of bytes that have been received.

Parameters
psHandleQSCI handle pointer.
pu32CountReceive bytes count.
Return values
kStatus_NoTransferInProgressNo receive in progress.
kStatus_InvalidArgumentParameter is invalid.
kStatus_SuccessGet successfully through the parameter pu32Count;
uint16_t QSCI_GetInstance ( QSCI_Type *  base)
Parameters
baseQSCI peripheral base address.
Returns
QSCI instance.