![]() |
MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
The MCUXpresso SDK provides a peripheral driver for the Low Power UART (UART) module of MCUXpresso SDK devices.
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/uart
Data Structures | |
struct | uart_fifo_config_t |
UART FIFO Configuration Structure definition. More... | |
struct | uart_autobaud_config_t |
UART Auto baud detect and set Configuration Structure definition. More... | |
struct | uart_infrared_config_t |
UART Infrared Configuration Structure type definition. More... | |
struct | uart_config_t |
UART configuration structure. More... | |
struct | uart_handle_t |
UART transfer handle. More... | |
struct | uart_transfer_t |
UART transfer structure. More... | |
Macros | |
#define | UART_RETRY_TIMES 0U /* Defining to zero means to keep waiting for the flag until it is asserts/deasserts. */ |
Retry times for waiting flag. More... | |
Typedefs | |
typedef void(* | uart_transfer_callback_t )(UART_Type *base, uart_handle_t *handle, status_t status, void *userData) |
UART interrupt transfer callback function definition. More... | |
Functions | |
uint32_t | UART_GetInstance (UART_Type *base) |
Get the UART instance from peripheral base address. More... | |
Driver version | |
#define | FSL_UART_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) |
UART driver version. More... | |
Initialization and deinitialization | |
status_t | UART_Init (UART_Type *base, const uart_config_t *config, uint32_t srcClock_Hz) |
Initializes an UART instance with the user configuration structure and the peripheral clock frequency. More... | |
void | UART_Deinit (UART_Type *base) |
Deinitializes a UART instance. More... | |
void | UART_GetDefaultConfig (uart_config_t *config) |
Gets the default configuration structure. More... | |
Hardware Status Flags | |
uint16_t | UART_GetStatusFlags (UART_Type *base) |
Gets UART hardware status flags. More... | |
Interrupt | |
void | UART_EnableInterrupts (UART_Type *base, uint8_t interrupts) |
Enables UART interrupts according to the provided mask. More... | |
void | UART_DisableInterrupts (UART_Type *base, uint8_t interrupts) |
Disables UART interrupts according to the provided mask. More... | |
uint8_t | UART_GetEnabledInterrupts (UART_Type *base) |
Gets the enabled UART interrupts. More... | |
General Peripheral Configuration | |
static void | UART_Enable (UART_Type *base, bool enable) |
Enables or disables the UART module. More... | |
static void | UART_EnableHighSpeed (UART_Type *base, bool enable) |
Enables or disables the UART high speed mode. More... | |
static void | UART_EnableDMA (UART_Type *base, bool enable) |
Enables or disables the UART dma request. More... | |
static void | UART_SetFifoConfig (UART_Type *base, uart_fifo_config_t *fifoConfig) |
Set the UART FIFO configuration. More... | |
static bool | UART_IsFifoEnabled (UART_Type *base) |
Checks the UART FIFO enable status. More... | |
static void | UART_EnablCts (UART_Type *base, bool enable) |
Enables or disables the UART CTS input. More... | |
static void | UART_EnableRts (UART_Type *base, bool enable) |
Enables or disables the UART RTS output. More... | |
static bool | UART_IsCtsAsserted (UART_Type *base) |
Checks the CTS pin status. More... | |
static void | UART_EnableLoop (UART_Type *base, bool enable) |
Enables or disables the UART loop mode. More... | |
static void | UART_SetParity (UART_Type *base, uart_parity_mode_t parity) |
Set the UART parity type. More... | |
static void | UART_EnableStickyParity (UART_Type *base, bool enable) |
Enables or disables sticky parity. More... | |
static void | UART_SetDataBits (UART_Type *base, uart_data_bits_t dataBits) |
Set the UART data bits. More... | |
static void | UART_SetStopBits (UART_Type *base, uart_stop_bit_count_t stopBits) |
Set the UART stop bits. More... | |
static uint8_t | UART_GetRxFifoLevel (UART_Type *base) |
Get current UART receive FIFO level. More... | |
status_t | UART_SetBaudRate (UART_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz) |
Sets the UART instance baudrate. More... | |
void | UART_SetAutoBaudConfig (UART_Type *base, uart_autobaud_config_t *autoBaudConfig) |
Sets the UART auto baud configuration. More... | |
static uint16_t | UART_GetAutoBaudCount (UART_Type *base) |
Get UART auto baud count number. More... | |
void | UART_SetAutoBaud (UART_Type *base) |
Set DL register according to Auto Baud Detect Count value. More... | |
void | UART_SetInfraredConfig (UART_Type *base, uart_infrared_config_t *infraredConfig) |
Sets the UART auto baud configuration. More... | |
Bus Operation | |
static uint32_t | UART_GetRxDataRegisterAddress (UART_Type *base) |
Gets the UART receive data register byte address. More... | |
static uint32_t | UART_GetTxDataRegisterAddress (UART_Type *base) |
Gets the UART transmit data register byte address. More... | |
static void | UART_WriteByte (UART_Type *base, uint8_t data) |
Writes to the TX register. More... | |
static uint8_t | UART_ReadByte (UART_Type *base) |
Reads the RX register directly. More... | |
static void | UART_Write9bits (UART_Type *base, uint16_t data) |
Send 9 bit data to the UART peripheral. More... | |
uint16_t | UART_Read9bits (UART_Type *base) |
Read 9 bit data from the UART peripheral. More... | |
status_t | UART_WriteBlocking (UART_Type *base, const uint8_t *data, uint32_t length) |
Writes TX register using a blocking method. More... | |
status_t | UART_ReadBlocking (UART_Type *base, uint8_t *data, uint32_t length) |
Reads RX data register using a blocking method. More... | |
static void | UART_EnableBreakCondition (UART_Type *base, bool enable) |
Enables or disables break condition. More... | |
Transactional | |
void | UART_TransferCreateHandle (UART_Type *base, uart_handle_t *handle, uart_transfer_callback_t callback, void *userData) |
Initializes the UART handle. More... | |
void | UART_TransferStartRingBuffer (UART_Type *base, uart_handle_t *handle, uint8_t *ringBuffer, size_t ringBufferSize) |
Sets up the RX ring buffer. More... | |
void | UART_TransferStopRingBuffer (UART_Type *base, uart_handle_t *handle) |
Aborts the background transfer and uninstalls the ring buffer. More... | |
size_t | UART_TransferGetRxRingBufferLength (UART_Type *base, uart_handle_t *handle) |
Get the length of received data in RX ring buffer. More... | |
status_t | UART_TransferSendNonBlocking (UART_Type *base, uart_handle_t *handle, uart_transfer_t *xfer) |
Transmits a buffer of data using the interrupt method. More... | |
status_t | UART_TransferGetSendCount (UART_Type *base, uart_handle_t *handle, uint32_t *count) |
Gets the number of bytes that have been sent out to bus. More... | |
void | UART_TransferAbortSend (UART_Type *base, uart_handle_t *handle) |
Aborts the interrupt-driven data transmit. More... | |
status_t | UART_TransferReceiveNonBlocking (UART_Type *base, uart_handle_t *handle, uart_transfer_t *xfer, size_t *receivedBytes) |
Receives a buffer of data using the interrupt method. More... | |
status_t | UART_TransferGetReceiveCount (UART_Type *base, uart_handle_t *handle, uint32_t *count) |
Gets the number of bytes that have been received. More... | |
void | UART_TransferAbortReceive (UART_Type *base, uart_handle_t *handle) |
Aborts the interrupt-driven data receiving. More... | |
void | UART_TransferHandleIRQ (UART_Type *base, uart_handle_t *handle) |
UART IRQ handle function. More... | |
void | UART_TransferHandleErrorIRQ (UART_Type *base, uart_handle_t *handle) |
UART Error IRQ handle function. More... | |
struct uart_fifo_config_t |
Data Fields | |
uart_txfifo_watermark_t | txFifoWatermark |
TX FIFO watermark. More... | |
uart_rxfifo_watermark_t | rxFifoWatermark |
RX FIFO watermark. More... | |
bool | resetTxFifo |
Tx FIFO reset. More... | |
bool | resetRxFifo |
Rx FIFO reset. More... | |
bool | fifoEnable |
FIFO enable. More... | |
uart_txfifo_watermark_t uart_fifo_config_t::txFifoWatermark |
FCR[TIL]
uart_rxfifo_watermark_t uart_fifo_config_t::rxFifoWatermark |
FCR[ITL]
bool uart_fifo_config_t::resetTxFifo |
FCR[RESETTF]
bool uart_fifo_config_t::resetRxFifo |
FCR[RESETRF]
bool uart_fifo_config_t::fifoEnable |
FCR[TRFIFOE]
struct uart_autobaud_config_t |
Data Fields | |
bool | autoBaudEnable |
Enable or Disable Auto Baud Function. More... | |
uart_autobaud_program_t | baudProgramType |
Uart Auto Baud Program type. More... | |
uart_autobaud_calculation_t | baudCalType |
Uart Auto Baud calculation type. More... | |
bool uart_autobaud_config_t::autoBaudEnable |
ABR[ABE]
uart_autobaud_program_t uart_autobaud_config_t::baudProgramType |
ABR[ABUP]
uart_autobaud_calculation_t uart_autobaud_config_t::baudCalType |
ABR[ABT]
struct uart_infrared_config_t |
Data Fields | |
bool | txIrEnable |
Enable or Disable Uart Transmit IR Function. More... | |
bool | rxIrEnable |
Enable or Disable Uart Receive IR Function. More... | |
uart_infrared_polarity_t | txIrPolarity |
Transmit IR Polarity type. More... | |
uart_infrared_polarity_t | rxIrPolarity |
Receive IR Polarity type. More... | |
uart_infrared_pulsewidth_t | irPulseWidth |
IR Pulse Width type. More... | |
bool uart_infrared_config_t::txIrEnable |
ISR[XMITIR]
bool uart_infrared_config_t::rxIrEnable |
ISR[RCVEIR]
uart_infrared_polarity_t uart_infrared_config_t::txIrPolarity |
ISR[TXPL]
uart_infrared_polarity_t uart_infrared_config_t::rxIrPolarity |
ISR[RXPL]
uart_infrared_pulsewidth_t uart_infrared_config_t::irPulseWidth |
ISR[XMODE]
struct uart_config_t |
Data Fields | |
uint32_t | baudRate_Bps |
UART baud rate. More... | |
uart_parity_mode_t | parityMode |
Parity mode, disabled (default), even, odd. More... | |
bool | enableStickyParity |
Sticky parity, when enabled the parity bit remains unchanged and is opposite to PEN bit. More... | |
uart_data_bits_t | dataBitCount |
Data bits count, eight (default), seven. More... | |
uart_stop_bit_count_t | stopBitCount |
Number of stop bits, 1 stop bit (default) or 2 stop bits. More... | |
uart_fifo_config_t | fifoConfig |
FIFO configuration. More... | |
uart_autobaud_config_t | autoBaudConfig |
Auto baud detect and set configuration. More... | |
uart_infrared_config_t | infraredConfig |
Infrared function configuration. More... | |
bool | enableHighSpeed |
High speed enable. More... | |
bool | enableLoop |
Loop mode MCR[LOOP]. | |
bool | enableTxCTS |
TX CTS enable. More... | |
bool | enableRxRTS |
RX RTS enable. More... | |
bool | enable |
Enable UART. More... | |
uint32_t uart_config_t::baudRate_Bps |
DLL, DLH
uart_parity_mode_t uart_config_t::parityMode |
LCR[EPS][PEN]
bool uart_config_t::enableStickyParity |
LCR[STKYP]
uart_data_bits_t uart_config_t::dataBitCount |
LCR[WLS10]
uart_stop_bit_count_t uart_config_t::stopBitCount |
LCR[STB]
uart_fifo_config_t uart_config_t::fifoConfig |
uart_autobaud_config_t uart_config_t::autoBaudConfig |
uart_infrared_config_t uart_config_t::infraredConfig |
bool uart_config_t::enableHighSpeed |
IER[HSE] = 1
bool uart_config_t::enableTxCTS |
MCR[AFE] = 1
bool uart_config_t::enableRxRTS |
To enable RTS, CTS must be enabled. MCR[AFE][RTS] = 11
bool uart_config_t::enable |
IER[UUE]
struct _uart_handle_t |
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... | |
uart_transfer_callback_t | callback |
Callback function. More... | |
void * | userData |
uart callback function parameter. More... | |
volatile uint8_t | txState |
TX transfer state. More... | |
volatile uint8_t | rxState |
RX transfer state. More... | |
uint8_t* volatile uart_handle_t::txData |
volatile size_t uart_handle_t::txDataSize |
size_t uart_handle_t::txDataSizeAll |
uint8_t* volatile uart_handle_t::rxData |
volatile size_t uart_handle_t::rxDataSize |
size_t uart_handle_t::rxDataSizeAll |
uint8_t* uart_handle_t::rxRingBuffer |
size_t uart_handle_t::rxRingBufferSize |
volatile uint16_t uart_handle_t::rxRingBufferHead |
volatile uint16_t uart_handle_t::rxRingBufferTail |
uart_transfer_callback_t uart_handle_t::callback |
void* uart_handle_t::userData |
volatile uint8_t uart_handle_t::txState |
volatile uint8_t uart_handle_t::rxState |
struct uart_transfer_t |
#define FSL_UART_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) |
#define UART_RETRY_TIMES 0U /* Defining to zero means to keep waiting for the flag until it is asserts/deasserts. */ |
typedef void(* uart_transfer_callback_t)(UART_Type *base, uart_handle_t *handle, status_t status, void *userData) |
Defines the interface of user callback function used in UART interrupt transfer using transactional APIs. The callback function shall be defined and declared in application level by user. Before starting UART transmiting or receiving by calling UART_TransferSendNonBlocking or UART_TransferReceiveNonBlocking, call UART_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.
base | UART peripheral base address. |
handle | Transfer handle. |
status | Transfer status |
userData | Pointer to user specified data or structure etc. |
anonymous enum |
This structure contains the settings for all of the UART interrupt configurations.
enum _uart_status_flags |
This provides constants for the UART status flags for use in the UART functions.
enum uart_parity_mode_t |
enum uart_data_bits_t |
When choosing kUART_BaudrateProgramAuto for baud rate program method, this is used to configure the baudrate calculation method of UART.
uint32_t UART_GetInstance | ( | UART_Type * | base | ) |
base | UART peripheral base address. |
status_t UART_Init | ( | UART_Type * | base, |
const uart_config_t * | config, | ||
uint32_t | srcClock_Hz | ||
) |
This function configures the UART module with user-defined settings. Call the UART_GetDefaultConfig function to get the configuration structure configured with default settings. The example below shows how to use this API to configure the UART.
base | UART peripheral base address. |
config | Pointer to a user-defined configuration structure. |
srcClock_Hz | UART clock source frequency in Hz. |
kStatus_UART_BaudrateNotSupport | Baudrate is not support in current clock source. |
kStatus_Success | UART initialize succeed |
void UART_Deinit | ( | UART_Type * | base | ) |
This function waits for transmit to complete, disables TX and RX, and disables the UART clock.
base | UART peripheral base address. |
void UART_GetDefaultConfig | ( | uart_config_t * | config | ) |
This function initializes the UART configuration structure to a default value. The example below shows how to use this API to configure the UART.
config | Pointer to a configuration structure. |
uint16_t UART_GetStatusFlags | ( | UART_Type * | base | ) |
base | UART peripheral base address. |
void UART_EnableInterrupts | ( | UART_Type * | base, |
uint8_t | interrupts | ||
) |
This function enables the UART interrupts according to the provided mask. The mask is a logical OR of enumeration members in _uart_interrupt_enable.
base | UART peripheral base address. |
interrupts | The interrupt source mask, can be a single source or several sources in _uart_interrupt_enable combined by OR. |
void UART_DisableInterrupts | ( | UART_Type * | base, |
uint8_t | interrupts | ||
) |
This function disables the UART interrupts according to the provided mask. The mask is a logical OR of enumeration members in _uart_interrupt_enable.
base | UART peripheral base address. |
interrupts | The interrupt source mask, can be a single source or several sources in _uart_interrupt_enable combined by OR. |
uint8_t UART_GetEnabledInterrupts | ( | UART_Type * | base | ) |
This function gets the enabled UART interrupts. The enabled interrupts are returned as the logical OR value of the enumerators _uart_interrupt_enable.
base | UART peripheral base address. |
|
inlinestatic |
base | UART peripheral base address. |
enable | True to enable, false to disable. |
|
inlinestatic |
base | UART peripheral base address. |
enable | True to enable, false to disable. |
|
inlinestatic |
base | UART peripheral base address. |
enable | True to enable, false to disable. |
|
inlinestatic |
base | UART peripheral base address |
fifoConfig | Pointer to FIFO configuration structure |
|
inlinestatic |
base | UART peripheral base address. |
|
inlinestatic |
base | UART peripheral base address. |
enable | True to enable, false to disable. |
|
inlinestatic |
base | UART peripheral base address. |
enable | True to enable, false to disable. |
|
inlinestatic |
base | UART peripheral base address. |
|
inlinestatic |
base | UART peripheral base address. |
enable | True to enable, false to disable. |
|
inlinestatic |
base | UART peripheral base address. |
parity | parity type |
|
inlinestatic |
base | UART peripheral base address. |
enable | True to enable, false to disable. |
|
inlinestatic |
base | UART peripheral base address. |
dataBits | bits to set |
|
inlinestatic |
base | UART peripheral base address. |
stopBits | stop bits to set |
|
inlinestatic |
base | Select the UART port, should be kUART1_Id, kUART2_Id. |
status_t UART_SetBaudRate | ( | UART_Type * | base, |
uint32_t | baudRate_Bps, | ||
uint32_t | srcClock_Hz | ||
) |
This API configures the UART module baudrate. This API can be used to update the UART module baudrate after the UART module is initialized by the UART_Init.
base | UART peripheral base address. |
baudRate_Bps | UART baudrate to be set. |
srcClock_Hz | UART clock source frequency in HZ. |
kStatus_UART_BaudrateNotSupport | Baudrate is not supported in the current clock source. |
kStatus_Success | Set baudrate succeeded. |
void UART_SetAutoBaudConfig | ( | UART_Type * | base, |
uart_autobaud_config_t * | autoBaudConfig | ||
) |
This API configures the UART auto baud function, including enable/disable, calculation type, program type.
base | UART peripheral base address. |
autoBaudConfig | pointer to UART auto baud configuration. |
|
inlinestatic |
base | UART peripheral base address |
void UART_SetAutoBaud | ( | UART_Type * | base | ) |
base | UART peripheral base address. |
void UART_SetInfraredConfig | ( | UART_Type * | base, |
uart_infrared_config_t * | infraredConfig | ||
) |
This API configures the UART auto baud function, including enable/disable, calculation type, program type.
base | UART peripheral base address. |
infraredConfig | pointer to UART infrared configuration. |
|
inlinestatic |
This function returns the UART receive data register address, which is mainly used by DMA/eDMA.
base | UART peripheral base address. |
|
inlinestatic |
This function returns the UART transmit data register address, which is mainly used by DMA/eDMA.
base | UART peripheral base address. |
|
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.
base | UART peripheral base address. |
data | The byte to write. |
|
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.
base | UART peripheral base address. |
|
inlinestatic |
Before calling this API, make sure parity and sticky parity are enabled, and tx register empty or room in tx FIFO.
base | UART peripheral base address. |
data | The data to be sent |
uint16_t UART_Read9bits | ( | UART_Type * | base | ) |
Before calling this API, make sure parity is enabled, and rx register full or data available in rx FIFO.
base | UART peripheral base address. |
status_t UART_WriteBlocking | ( | UART_Type * | base, |
const uint8_t * | data, | ||
uint32_t | length | ||
) |
This function polls the TX register, waits TX register to be empty or TX FIFO have room then writes data to the TX buffer.
base | UART peripheral base address. |
data | Start address of the data to write. |
length | Size of the data to write. |
status_t UART_ReadBlocking | ( | UART_Type * | base, |
uint8_t * | data, | ||
uint32_t | length | ||
) |
This function polls the RX register, waits RX register to be full or RX FIFO have data, then reads data from the RX register.
base | UART peripheral base address. |
data | Start address of the buffer to store the received data. |
length | Size of the buffer. |
kStatus_Fail | Receiver error occurred while receiving data. |
kStatus_UART_RxHardwareOverrun | Receiver overrun occurred while receiving data |
kStatus_UART_NoiseError | Noise error occurred while receiving data |
kStatus_UART_FramingErrorFraming | error occurred while receiving data |
kStatus_UART_ParityError | Parity error occurred while receiving data |
kStatus_Success | Successfully received all data. |
|
inlinestatic |
When break condition is enabled tx pin is pulled low by UART, when disabled the pin is high.
base | UART peripheral base address. |
enable | True to enable, false to disable. |
void UART_TransferCreateHandle | ( | UART_Type * | base, |
uart_handle_t * | handle, | ||
uart_transfer_callback_t | callback, | ||
void * | userData | ||
) |
This function initializes the UART handle, which can be used for other UART transactional APIs. Usually, for a specified UART instance, call this API once to get the initialized handle.
The UART driver supports the "background" receiving, which means that user can set up an RX ring buffer optionally. Data received is stored into the ring buffer even when the user doesn't call the UART_TransferReceiveNonBlocking() API. If there is already data received in the ring buffer, the user can get the received data from the ring buffer directly. The ring buffer is disabled if passing NULL as ringBuffer
.
base | UART peripheral base address. |
handle | UART handle pointer. |
callback | Callback function. |
userData | User data. |
void UART_TransferStartRingBuffer | ( | UART_Type * | base, |
uart_handle_t * | handle, | ||
uint8_t * | ringBuffer, | ||
size_t | ringBufferSize | ||
) |
This function sets up the RX ring buffer to a specific UART handle.
When the RX ring buffer is used, data received is stored into the ring buffer even when the user doesn't call the UART_TransferReceiveNonBlocking() API. If there is already data received in the ring buffer, the user can get the received data from the ring buffer directly.
ringBufferSize
is 32, then only 31 bytes are used for saving data.base | UART peripheral base address. |
handle | UART handle pointer. |
ringBuffer | Start address of ring buffer for background receiving. Pass NULL to disable the ring buffer. |
ringBufferSize | size of the ring buffer. |
void UART_TransferStopRingBuffer | ( | UART_Type * | base, |
uart_handle_t * | handle | ||
) |
This function aborts the background transfer and uninstalls the ring buffer.
base | UART peripheral base address. |
handle | UART handle pointer. |
size_t UART_TransferGetRxRingBufferLength | ( | UART_Type * | base, |
uart_handle_t * | handle | ||
) |
base | UART peripheral base address. |
handle | UART handle pointer. |
status_t UART_TransferSendNonBlocking | ( | UART_Type * | base, |
uart_handle_t * | handle, | ||
uart_transfer_t * | xfer | ||
) |
This function send data using an interrupt method. This is a non-blocking function, which returns directly without waiting for all data written to the transmitter register. When all data is written to the TX register in the ISR, the UART driver calls the callback function and passes the kStatus_UART_TxIdle as status parameter.
base | UART peripheral base address. |
handle | UART handle pointer. |
xfer | UART transfer structure, see uart_transfer_t. |
kStatus_Success | Successfully start the data transmission. |
kStatus_UART_TxBusy | Previous transmission still not finished, data not all written to the TX register. |
kStatus_InvalidArgument | Invalid argument. |
status_t UART_TransferGetSendCount | ( | UART_Type * | base, |
uart_handle_t * | handle, | ||
uint32_t * | count | ||
) |
This function gets the number of bytes that have been sent out to bus by an interrupt method.
base | UART peripheral base address. |
handle | UART handle pointer. |
count | Send bytes count. |
kStatus_NoTransferInProgress | No send in progress. |
kStatus_InvalidArgument | Parameter is invalid. |
kStatus_Success | Get successfully through the parameter count ; |
void UART_TransferAbortSend | ( | UART_Type * | base, |
uart_handle_t * | handle | ||
) |
This function aborts the interrupt driven data sending. The user can get the remainBtyes to find out how many bytes are not sent out.
base | UART peripheral base address. |
handle | UART handle pointer. |
status_t UART_TransferReceiveNonBlocking | ( | UART_Type * | base, |
uart_handle_t * | handle, | ||
uart_transfer_t * | xfer, | ||
size_t * | receivedBytes | ||
) |
This function receives data using an interrupt method. This is a non-blocking function which returns without waiting to ensure that all data are 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 for read, the receive request is saved by the UART driver. When the new data arrives, the receive request is serviced first. When all data is received, the UART driver notifies the upper layer through a callback function and passes a status parameter kStatus_UART_RxIdle. For example, the upper layer needs 10 bytes but there are only 5 bytes in ring buffer. The 5 bytes are copied to xfer->data, which returns with the parameter receivedBytes
set to 5. For the remaining 5 bytes, the newly arrived data is saved from xfer->data[5]. When 5 bytes are received, the UART 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 xfer->data. When all data is received, the upper layer is notified.
base | UART peripheral base address. |
handle | UART handle pointer. |
xfer | UART transfer structure, see uart_transfer_t. |
receivedBytes | Bytes received from the ring buffer directly. |
kStatus_Success | Successfully queue the transfer into the transmit queue. |
kStatus_UART_RxBusy | Previous receive request is not finished. |
kStatus_InvalidArgument | Invalid argument. |
status_t UART_TransferGetReceiveCount | ( | UART_Type * | base, |
uart_handle_t * | handle, | ||
uint32_t * | count | ||
) |
This function gets the number of bytes that have been received.
base | UART peripheral base address. |
handle | UART handle pointer. |
count | Receive bytes count. |
kStatus_NoTransferInProgress | No receive in progress. |
kStatus_InvalidArgument | Parameter is invalid. |
kStatus_Success | Get successfully through the parameter count ; |
void UART_TransferAbortReceive | ( | UART_Type * | base, |
uart_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.
base | UART peripheral base address. |
handle | UART handle pointer. |
void UART_TransferHandleIRQ | ( | UART_Type * | base, |
uart_handle_t * | handle | ||
) |
This function handles the UART transmit and receive IRQ request.
base | UART peripheral base address. |
handle | UART handle pointer. |
void UART_TransferHandleErrorIRQ | ( | UART_Type * | base, |
uart_handle_t * | handle | ||
) |
This function handles the UART error IRQ request.
base | UART peripheral base address. |
handle | UART handle pointer. |