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

Overview

Data Structures

struct  usart_config_t
 USART configuration structure. More...
 
struct  usart_transfer_t
 USART transfer structure. More...
 
struct  usart_handle_t
 USART handle structure. More...
 

Typedefs

typedef void(* usart_transfer_callback_t )(USART_Type *base, usart_handle_t *handle, status_t status, void *userData)
 USART transfer callback function. More...
 

Enumerations

enum  _usart_status {
  kStatus_USART_TxBusy = MAKE_STATUS(kStatusGroup_LPC_USART, 0),
  kStatus_USART_RxBusy = MAKE_STATUS(kStatusGroup_LPC_USART, 1),
  kStatus_USART_TxIdle = MAKE_STATUS(kStatusGroup_LPC_USART, 2),
  kStatus_USART_RxIdle = MAKE_STATUS(kStatusGroup_LPC_USART, 3),
  kStatus_USART_TxError = MAKE_STATUS(kStatusGroup_LPC_USART, 7),
  kStatus_USART_RxError = MAKE_STATUS(kStatusGroup_LPC_USART, 9),
  kStatus_USART_RxRingBufferOverrun = MAKE_STATUS(kStatusGroup_LPC_USART, 8),
  kStatus_USART_NoiseError = MAKE_STATUS(kStatusGroup_LPC_USART, 10),
  kStatus_USART_FramingError = MAKE_STATUS(kStatusGroup_LPC_USART, 11),
  kStatus_USART_ParityError = MAKE_STATUS(kStatusGroup_LPC_USART, 12),
  kStatus_USART_BaudrateNotSupport
}
 Error codes for the USART driver. More...
 
enum  usart_sync_mode_t {
  kUSART_SyncModeDisabled = 0x0U,
  kUSART_SyncModeSlave = 0x2U,
  kUSART_SyncModeMaster = 0x3U
}
 USART synchronous mode. More...
 
enum  usart_parity_mode_t {
  kUSART_ParityDisabled = 0x0U,
  kUSART_ParityEven = 0x2U,
  kUSART_ParityOdd = 0x3U
}
 USART parity mode. More...
 
enum  usart_stop_bit_count_t {
  kUSART_OneStopBit = 0U,
  kUSART_TwoStopBit = 1U
}
 USART stop bit count. More...
 
enum  usart_data_len_t {
  kUSART_7BitsPerChar = 0U,
  kUSART_8BitsPerChar = 1U
}
 USART data size. More...
 
enum  usart_clock_polarity_t {
  kUSART_RxSampleOnFallingEdge = 0x0U,
  kUSART_RxSampleOnRisingEdge = 0x1U
}
 USART clock polarity configuration, used in sync mode. More...
 
enum  usart_txfifo_watermark_t {
  kUSART_TxFifo0 = 0,
  kUSART_TxFifo1 = 1,
  kUSART_TxFifo2 = 2,
  kUSART_TxFifo3 = 3,
  kUSART_TxFifo4 = 4,
  kUSART_TxFifo5 = 5,
  kUSART_TxFifo6 = 6,
  kUSART_TxFifo7 = 7
}
 txFIFO watermark values More...
 
enum  usart_rxfifo_watermark_t {
  kUSART_RxFifo1 = 0,
  kUSART_RxFifo2 = 1,
  kUSART_RxFifo3 = 2,
  kUSART_RxFifo4 = 3,
  kUSART_RxFifo5 = 4,
  kUSART_RxFifo6 = 5,
  kUSART_RxFifo7 = 6,
  kUSART_RxFifo8 = 7
}
 rxFIFO watermark values More...
 
enum  _usart_interrupt_enable
 USART interrupt configuration structure, default settings all disabled.
 
enum  _usart_flags {
  kUSART_TxError = (USART_FIFOSTAT_TXERR_MASK),
  kUSART_RxError = (USART_FIFOSTAT_RXERR_MASK),
  kUSART_TxFifoEmptyFlag = (USART_FIFOSTAT_TXEMPTY_MASK),
  kUSART_TxFifoNotFullFlag = (USART_FIFOSTAT_TXNOTFULL_MASK),
  kUSART_RxFifoNotEmptyFlag = (USART_FIFOSTAT_RXNOTEMPTY_MASK),
  kUSART_RxFifoFullFlag = (USART_FIFOSTAT_RXFULL_MASK)
}
 USART status flags. More...
 

Functions

uint32_t USART_GetInstance (USART_Type *base)
 Returns instance number for USART peripheral base address. More...
 

Driver version

#define FSL_USART_DRIVER_VERSION   (MAKE_VERSION(2, 1, 0))
 USART driver version 2.1.0. More...
 

Initialization and deinitialization

status_t USART_Init (USART_Type *base, const usart_config_t *config, uint32_t srcClock_Hz)
 Initializes a USART instance with user configuration structure and peripheral clock. More...
 
void USART_Deinit (USART_Type *base)
 Deinitializes a USART instance. More...
 
void USART_GetDefaultConfig (usart_config_t *config)
 Gets the default configuration structure. More...
 
status_t USART_SetBaudRate (USART_Type *base, uint32_t baudrate_Bps, uint32_t srcClock_Hz)
 Sets the USART instance baud rate. More...
 

Status

static uint32_t USART_GetStatusFlags (USART_Type *base)
 Get USART status flags. More...
 
static void USART_ClearStatusFlags (USART_Type *base, uint32_t mask)
 Clear USART status flags. More...
 

Interrupts

static void USART_EnableInterrupts (USART_Type *base, uint32_t mask)
 Enables USART interrupts according to the provided mask. More...
 
static void USART_DisableInterrupts (USART_Type *base, uint32_t mask)
 Disables USART interrupts according to a provided mask. More...
 
static uint32_t USART_GetEnabledInterrupts (USART_Type *base)
 Returns enabled USART interrupts. More...
 
static void USART_EnableTxDMA (USART_Type *base, bool enable)
 Enable DMA for Tx.
 
static void USART_EnableRxDMA (USART_Type *base, bool enable)
 Enable DMA for Rx.
 
static void USART_EnableCTS (USART_Type *base, bool enable)
 Enable CTS. More...
 
static void USART_EnableContinuousSCLK (USART_Type *base, bool enable)
 Continuous Clock generation. More...
 
static void USART_EnableAutoClearSCLK (USART_Type *base, bool enable)
 Enable Continuous Clock generation bit auto clear. More...
 

Bus Operations

static void USART_WriteByte (USART_Type *base, uint8_t data)
 Writes to the FIFOWR register. More...
 
static uint8_t USART_ReadByte (USART_Type *base)
 Reads the FIFORD register directly. More...
 
void USART_WriteBlocking (USART_Type *base, const uint8_t *data, size_t length)
 Writes to the TX register using a blocking method. More...
 
status_t USART_ReadBlocking (USART_Type *base, uint8_t *data, size_t length)
 Read RX data register using a blocking method. More...
 

Transactional

status_t USART_TransferCreateHandle (USART_Type *base, usart_handle_t *handle, usart_transfer_callback_t callback, void *userData)
 Initializes the USART handle. More...
 
status_t USART_TransferSendNonBlocking (USART_Type *base, usart_handle_t *handle, usart_transfer_t *xfer)
 Transmits a buffer of data using the interrupt method. More...
 
void USART_TransferStartRingBuffer (USART_Type *base, usart_handle_t *handle, uint8_t *ringBuffer, size_t ringBufferSize)
 Sets up the RX ring buffer. More...
 
void USART_TransferStopRingBuffer (USART_Type *base, usart_handle_t *handle)
 Aborts the background transfer and uninstalls the ring buffer. More...
 
size_t USART_TransferGetRxRingBufferLength (usart_handle_t *handle)
 Get the length of received data in RX ring buffer. More...
 
void USART_TransferAbortSend (USART_Type *base, usart_handle_t *handle)
 Aborts the interrupt-driven data transmit. More...
 
status_t USART_TransferGetSendCount (USART_Type *base, usart_handle_t *handle, uint32_t *count)
 Get the number of bytes that have been written to USART TX register. More...
 
status_t USART_TransferReceiveNonBlocking (USART_Type *base, usart_handle_t *handle, usart_transfer_t *xfer, size_t *receivedBytes)
 Receives a buffer of data using an interrupt method. More...
 
void USART_TransferAbortReceive (USART_Type *base, usart_handle_t *handle)
 Aborts the interrupt-driven data receiving. More...
 
status_t USART_TransferGetReceiveCount (USART_Type *base, usart_handle_t *handle, uint32_t *count)
 Get the number of bytes that have been received. More...
 
void USART_TransferHandleIRQ (USART_Type *base, usart_handle_t *handle)
 USART IRQ handle function. More...
 

Data Structure Documentation

struct usart_config_t

Data Fields

uint32_t baudRate_Bps
 USART baud rate.
 
usart_parity_mode_t parityMode
 Parity mode, disabled (default), even, odd.
 
usart_stop_bit_count_t stopBitCount
 Number of stop bits, 1 stop bit (default) or 2 stop bits.
 
usart_data_len_t bitCountPerChar
 Data length - 7 bit, 8 bit.
 
bool loopback
 Enable peripheral loopback.
 
bool enableRx
 Enable RX.
 
bool enableTx
 Enable TX.
 
bool enableContinuousSCLK
 USART continuous Clock generation enable in synchronous master mode. More...
 
usart_txfifo_watermark_t txWatermark
 txFIFO watermark
 
usart_rxfifo_watermark_t rxWatermark
 rxFIFO watermark
 
usart_sync_mode_t syncMode
 Transfer mode select - asynchronous, synchronous master, synchronous slave. More...
 
usart_clock_polarity_t clockPolarity
 Selects the clock polarity and sampling edge in synchronous mode. More...
 

Field Documentation

bool usart_config_t::enableContinuousSCLK
usart_sync_mode_t usart_config_t::syncMode
usart_clock_polarity_t usart_config_t::clockPolarity
struct usart_transfer_t

Data Fields

uint8_t * data
 The buffer of data to be transfer. More...
 
size_t dataSize
 The byte count to be transfer. More...
 

Field Documentation

uint8_t* usart_transfer_t::data
size_t usart_transfer_t::dataSize
struct _usart_handle

Data Fields

uint8_t *volatile txData
 Address of remaining data to send. More...
 
volatile size_t txDataSize
 Size of the remaining data to send. More...
 
size_t txDataSizeAll
 Size of the data to send out. More...
 
uint8_t *volatile rxData
 Address of remaining data to receive. More...
 
volatile size_t rxDataSize
 Size of the remaining data to receive. More...
 
size_t rxDataSizeAll
 Size of the data to receive. More...
 
uint8_t * rxRingBuffer
 Start address of the receiver ring buffer. More...
 
size_t rxRingBufferSize
 Size of the ring buffer. More...
 
volatile uint16_t rxRingBufferHead
 Index for the driver to store received data into ring buffer. More...
 
volatile uint16_t rxRingBufferTail
 Index for the user to get data from the ring buffer. More...
 
usart_transfer_callback_t callback
 Callback function. More...
 
void * userData
 USART callback function parameter. More...
 
volatile uint8_t txState
 TX transfer state. More...
 
volatile uint8_t rxState
 RX transfer state.
 
usart_txfifo_watermark_t txWatermark
 txFIFO watermark
 
usart_rxfifo_watermark_t rxWatermark
 rxFIFO watermark
 

Field Documentation

uint8_t* volatile usart_handle_t::txData
volatile size_t usart_handle_t::txDataSize
size_t usart_handle_t::txDataSizeAll
uint8_t* volatile usart_handle_t::rxData
volatile size_t usart_handle_t::rxDataSize
size_t usart_handle_t::rxDataSizeAll
uint8_t* usart_handle_t::rxRingBuffer
size_t usart_handle_t::rxRingBufferSize
volatile uint16_t usart_handle_t::rxRingBufferHead
volatile uint16_t usart_handle_t::rxRingBufferTail
usart_transfer_callback_t usart_handle_t::callback
void* usart_handle_t::userData
volatile uint8_t usart_handle_t::txState

Macro Definition Documentation

#define FSL_USART_DRIVER_VERSION   (MAKE_VERSION(2, 1, 0))

Typedef Documentation

typedef void(* usart_transfer_callback_t)(USART_Type *base, usart_handle_t *handle, status_t status, void *userData)

Enumeration Type Documentation

Enumerator
kStatus_USART_TxBusy 

Transmitter is busy.

kStatus_USART_RxBusy 

Receiver is busy.

kStatus_USART_TxIdle 

USART transmitter is idle.

kStatus_USART_RxIdle 

USART receiver is idle.

kStatus_USART_TxError 

Error happens on txFIFO.

kStatus_USART_RxError 

Error happens on rxFIFO.

kStatus_USART_RxRingBufferOverrun 

Error happens on rx ring buffer.

kStatus_USART_NoiseError 

USART noise error.

kStatus_USART_FramingError 

USART framing error.

kStatus_USART_ParityError 

USART parity error.

kStatus_USART_BaudrateNotSupport 

Baudrate is not support in current clock source.

Enumerator
kUSART_SyncModeDisabled 

Asynchronous mode.

kUSART_SyncModeSlave 

Synchronous slave mode.

kUSART_SyncModeMaster 

Synchronous master mode.

Enumerator
kUSART_ParityDisabled 

Parity disabled.

kUSART_ParityEven 

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

kUSART_ParityOdd 

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

Enumerator
kUSART_OneStopBit 

One stop bit.

kUSART_TwoStopBit 

Two stop bits.

Enumerator
kUSART_7BitsPerChar 

Seven bit mode.

kUSART_8BitsPerChar 

Eight bit mode.

Enumerator
kUSART_RxSampleOnFallingEdge 

Un_RXD is sampled on the falling edge of SCLK.

kUSART_RxSampleOnRisingEdge 

Un_RXD is sampled on the rising edge of SCLK.

Enumerator
kUSART_TxFifo0 

USART tx watermark is empty.

kUSART_TxFifo1 

USART tx watermark at 1 item.

kUSART_TxFifo2 

USART tx watermark at 2 items.

kUSART_TxFifo3 

USART tx watermark at 3 items.

kUSART_TxFifo4 

USART tx watermark at 4 items.

kUSART_TxFifo5 

USART tx watermark at 5 items.

kUSART_TxFifo6 

USART tx watermark at 6 items.

kUSART_TxFifo7 

USART tx watermark at 7 items.

Enumerator
kUSART_RxFifo1 

USART rx watermark at 1 item.

kUSART_RxFifo2 

USART rx watermark at 2 items.

kUSART_RxFifo3 

USART rx watermark at 3 items.

kUSART_RxFifo4 

USART rx watermark at 4 items.

kUSART_RxFifo5 

USART rx watermark at 5 items.

kUSART_RxFifo6 

USART rx watermark at 6 items.

kUSART_RxFifo7 

USART rx watermark at 7 items.

kUSART_RxFifo8 

USART rx watermark at 8 items.

This provides constants for the USART status flags for use in the USART functions.

Enumerator
kUSART_TxError 

TEERR bit, sets if TX buffer is error.

kUSART_RxError 

RXERR bit, sets if RX buffer is error.

kUSART_TxFifoEmptyFlag 

TXEMPTY bit, sets if TX buffer is empty.

kUSART_TxFifoNotFullFlag 

TXNOTFULL bit, sets if TX buffer is not full.

kUSART_RxFifoNotEmptyFlag 

RXNOEMPTY bit, sets if RX buffer is not empty.

kUSART_RxFifoFullFlag 

RXFULL bit, sets if RX buffer is full.

Function Documentation

uint32_t USART_GetInstance ( USART_Type *  base)
status_t USART_Init ( USART_Type *  base,
const usart_config_t config,
uint32_t  srcClock_Hz 
)

This function configures the USART module with the user-defined settings. The user can configure the configuration structure and also get the default configuration by using the USART_GetDefaultConfig() function. Example below shows how to use this API to configure USART.

* usart_config_t usartConfig;
* usartConfig.baudRate_Bps = 115200U;
* USART_Init(USART1, &usartConfig, 20000000U);
*
Parameters
baseUSART peripheral base address.
configPointer to user-defined configuration structure.
srcClock_HzUSART clock source frequency in HZ.
Return values
kStatus_USART_BaudrateNotSupportBaudrate is not support in current clock source.
kStatus_InvalidArgumentUSART base address is not valid
kStatus_SuccessStatus USART initialize succeed
void USART_Deinit ( USART_Type *  base)

This function waits for TX complete, disables TX and RX, and disables the USART clock.

Parameters
baseUSART peripheral base address.
void USART_GetDefaultConfig ( usart_config_t config)

This function initializes the USART configuration structure to a default value. The default values are: usartConfig->baudRate_Bps = 115200U; usartConfig->parityMode = kUSART_ParityDisabled; usartConfig->stopBitCount = kUSART_OneStopBit; usartConfig->bitCountPerChar = kUSART_8BitsPerChar; usartConfig->loopback = false; usartConfig->enableTx = false; usartConfig->enableRx = false;

Parameters
configPointer to configuration structure.
status_t USART_SetBaudRate ( USART_Type *  base,
uint32_t  baudrate_Bps,
uint32_t  srcClock_Hz 
)

This function configures the USART module baud rate. This function is used to update the USART module baud rate after the USART module is initialized by the USART_Init.

* USART_SetBaudRate(USART1, 115200U, 20000000U);
*
Parameters
baseUSART peripheral base address.
baudrate_BpsUSART baudrate to be set.
srcClock_HzUSART clock source frequency in HZ.
Return values
kStatus_USART_BaudrateNotSupportBaudrate is not support in current clock source.
kStatus_SuccessSet baudrate succeed.
kStatus_InvalidArgumentOne or more arguments are invalid.
static uint32_t USART_GetStatusFlags ( USART_Type *  base)
inlinestatic

This function get all USART status flags, the flags are returned as the logical OR value of the enumerators _usart_flags. To check a specific status, compare the return value with enumerators in _usart_flags. For example, to check whether the TX is empty:

* {
* ...
* }
*
Parameters
baseUSART peripheral base address.
Returns
USART status flags which are ORed by the enumerators in the _usart_flags.
static void USART_ClearStatusFlags ( USART_Type *  base,
uint32_t  mask 
)
inlinestatic

This function clear supported USART status flags Flags that can be cleared or set are: kUSART_TxError kUSART_RxError For example:

Parameters
baseUSART peripheral base address.
maskstatus flags to be cleared.
static void USART_EnableInterrupts ( USART_Type *  base,
uint32_t  mask 
)
inlinestatic

This function enables the USART interrupts according to the provided mask. The mask is a logical OR of enumeration members. See _usart_interrupt_enable. For example, to enable TX empty interrupt and RX full interrupt:

* USART_EnableInterrupts(USART1, kUSART_TxLevelInterruptEnable | kUSART_RxLevelInterruptEnable);
*
Parameters
baseUSART peripheral base address.
maskThe interrupts to enable. Logical OR of _usart_interrupt_enable.
static void USART_DisableInterrupts ( USART_Type *  base,
uint32_t  mask 
)
inlinestatic

This function disables the USART interrupts according to a provided mask. The mask is a logical OR of enumeration members. See _usart_interrupt_enable. This example shows how to disable the TX empty interrupt and RX full interrupt:

* USART_DisableInterrupts(USART1, kUSART_TxLevelInterruptEnable | kUSART_RxLevelInterruptEnable);
*
Parameters
baseUSART peripheral base address.
maskThe interrupts to disable. Logical OR of _usart_interrupt_enable.
static uint32_t USART_GetEnabledInterrupts ( USART_Type *  base)
inlinestatic

This function returns the enabled USART interrupts.

Parameters
baseUSART peripheral base address.
static void USART_EnableCTS ( USART_Type *  base,
bool  enable 
)
inlinestatic

This function will determine whether CTS is used for flow control.

Parameters
baseUSART peripheral base address.
enableEnable CTS or not, true for enable and false for disable.
static void USART_EnableContinuousSCLK ( USART_Type *  base,
bool  enable 
)
inlinestatic

By default, SCLK is only output while data is being transmitted in synchronous mode. Enable this funciton, SCLK will run continuously in synchronous mode, allowing characters to be received on Un_RxD independently from transmission on Un_TXD).

Parameters
baseUSART peripheral base address.
enableEnable Continuous Clock generation mode or not, true for enable and false for disable.
static void USART_EnableAutoClearSCLK ( USART_Type *  base,
bool  enable 
)
inlinestatic

While enable this cuntion, the Continuous Clock bit is automatically cleared when a complete character has been received. This bit is cleared at the same time.

Parameters
baseUSART peripheral base address.
enableEnable auto clear or not, true for enable and false for disable.
static void USART_WriteByte ( USART_Type *  base,
uint8_t  data 
)
inlinestatic

This function writes data to the txFIFO directly. The upper layer must ensure that txFIFO has space for data to write before calling this function.

Parameters
baseUSART peripheral base address.
dataThe byte to write.
static uint8_t USART_ReadByte ( USART_Type *  base)
inlinestatic

This function reads data from the rxFIFO directly. The upper layer must ensure that the rxFIFO is not empty before calling this function.

Parameters
baseUSART peripheral base address.
Returns
The byte read from USART data register.
void USART_WriteBlocking ( USART_Type *  base,
const uint8_t *  data,
size_t  length 
)

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

Parameters
baseUSART peripheral base address.
dataStart address of the data to write.
lengthSize of the data to write.
status_t USART_ReadBlocking ( USART_Type *  base,
uint8_t *  data,
size_t  length 
)

This function polls the RX register, waits for the RX register to be full or for RX FIFO to have data and read data from the TX register.

Parameters
baseUSART peripheral base address.
dataStart address of the buffer to store the received data.
lengthSize of the buffer.
Return values
kStatus_USART_FramingErrorReceiver overrun happened while receiving data.
kStatus_USART_ParityErrorNoise error happened while receiving data.
kStatus_USART_NoiseErrorFraming error happened while receiving data.
kStatus_USART_RxErrorOverflow or underflow rxFIFO happened.
kStatus_SuccessSuccessfully received all data.
status_t USART_TransferCreateHandle ( USART_Type *  base,
usart_handle_t *  handle,
usart_transfer_callback_t  callback,
void *  userData 
)

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

Parameters
baseUSART peripheral base address.
handleUSART handle pointer.
callbackThe callback function.
userDataThe parameter of the callback function.
status_t USART_TransferSendNonBlocking ( USART_Type *  base,
usart_handle_t *  handle,
usart_transfer_t xfer 
)

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 written to the TX register in the IRQ handler, the USART driver calls the callback function and passes the kStatus_USART_TxIdle as status parameter.

Note
The kStatus_USART_TxIdle is passed to the upper layer when all data is written to the TX register. However it does not ensure that all data are sent out. Before disabling the TX, check the kUSART_TransmissionCompleteFlag to ensure that the TX is finished.
Parameters
baseUSART peripheral base address.
handleUSART handle pointer.
xferUSART transfer structure. See usart_transfer_t.
Return values
kStatus_SuccessSuccessfully start the data transmission.
kStatus_USART_TxBusyPrevious transmission still not finished, data not all written to TX register yet.
kStatus_InvalidArgumentInvalid argument.
void USART_TransferStartRingBuffer ( USART_Type *  base,
usart_handle_t *  handle,
uint8_t *  ringBuffer,
size_t  ringBufferSize 
)

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

When the RX ring buffer is used, data received are stored into the ring buffer even when the user doesn't call the USART_TransferReceiveNonBlocking() API. If there is already data 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, then only 31 bytes are used for saving data.
Parameters
baseUSART peripheral base address.
handleUSART handle pointer.
ringBufferStart address of the ring buffer for background receiving. Pass NULL to disable the ring buffer.
ringBufferSizesize of the ring buffer.
void USART_TransferStopRingBuffer ( USART_Type *  base,
usart_handle_t *  handle 
)

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

Parameters
baseUSART peripheral base address.
handleUSART handle pointer.
size_t USART_TransferGetRxRingBufferLength ( usart_handle_t *  handle)
Parameters
handleUSART handle pointer.
Returns
Length of received data in RX ring buffer.
void USART_TransferAbortSend ( USART_Type *  base,
usart_handle_t *  handle 
)

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

Parameters
baseUSART peripheral base address.
handleUSART handle pointer.
status_t USART_TransferGetSendCount ( USART_Type *  base,
usart_handle_t *  handle,
uint32_t *  count 
)

This function gets the number of bytes that have been written to USART TX register by interrupt method.

Parameters
baseUSART peripheral base address.
handleUSART handle pointer.
countSend bytes count.
Return values
kStatus_NoTransferInProgressNo send in progress.
kStatus_InvalidArgumentParameter is invalid.
kStatus_SuccessGet successfully through the parameter count;
status_t USART_TransferReceiveNonBlocking ( USART_Type *  base,
usart_handle_t *  handle,
usart_transfer_t xfer,
size_t *  receivedBytes 
)

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 receivedBytes 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 USART driver. When the new data arrives, the receive request is serviced first. When all data is received, the USART driver notifies the upper layer through a callback function and passes the status parameter kStatus_USART_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 xfer->data and this function returns with the parameter receivedBytes set to 5. For the left 5 bytes, newly arrived data is saved from the xfer->data[5]. When 5 bytes are received, the USART 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 xfer->data. When all data is received, the upper layer is notified.

Parameters
baseUSART peripheral base address.
handleUSART handle pointer.
xferUSART transfer structure, see usart_transfer_t.
receivedBytesBytes received from the ring buffer directly.
Return values
kStatus_SuccessSuccessfully queue the transfer into transmit queue.
kStatus_USART_RxBusyPrevious receive request is not finished.
kStatus_InvalidArgumentInvalid argument.
void USART_TransferAbortReceive ( USART_Type *  base,
usart_handle_t *  handle 
)

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

Parameters
baseUSART peripheral base address.
handleUSART handle pointer.
status_t USART_TransferGetReceiveCount ( USART_Type *  base,
usart_handle_t *  handle,
uint32_t *  count 
)

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

Parameters
baseUSART peripheral base address.
handleUSART handle pointer.
countReceive bytes count.
Return values
kStatus_NoTransferInProgressNo receive in progress.
kStatus_InvalidArgumentParameter is invalid.
kStatus_SuccessGet successfully through the parameter count;
void USART_TransferHandleIRQ ( USART_Type *  base,
usart_handle_t *  handle 
)

This function handles the USART transmit and receive IRQ request.

Parameters
baseUSART peripheral base address.
handleUSART handle pointer.