MCUXpresso SDK API Reference Manual
Rev. 1
NXP Semiconductors
|
Data Structures | |
struct | hal_uart_config_t |
uart configuration structure. More... | |
struct | hal_uart_transfer_t |
uart transfer structure. More... | |
Macros | |
#define | UART_ADAPTER_NON_BLOCKING_MODE (0U) |
Enable or disable Uart adapter non-blocking mode (1 - enable, 0 - disable) | |
#define | HAL_UART_TRANSFER_MODE (0U) |
Whether enable transactional function of the uart. More... | |
Typedefs | |
typedef void(* | hal_uart_transfer_callback_t )(hal_uart_handle_t handle, hal_uart_status_t status, void *callbackParam) |
uart transfer callback function. More... | |
Enumerations | |
enum | hal_uart_status_t { kStatus_HAL_UartSuccess = kStatus_Success, kStatus_HAL_UartTxBusy = MAKE_STATUS(kStatusGroup_HAL_UART, 1), kStatus_HAL_UartRxBusy = MAKE_STATUS(kStatusGroup_HAL_UART, 2), kStatus_HAL_UartTxIdle = MAKE_STATUS(kStatusGroup_HAL_UART, 3), kStatus_HAL_UartRxIdle = MAKE_STATUS(kStatusGroup_HAL_UART, 4), kStatus_HAL_UartBaudrateNotSupport, kStatus_HAL_UartProtocolError, kStatus_HAL_UartError = MAKE_STATUS(kStatusGroup_HAL_UART, 7) } |
uart status More... | |
enum | hal_uart_parity_mode_t { kHAL_UartParityDisabled = 0x0U, kHAL_UartParityEven = 0x1U, kHAL_UartParityOdd = 0x2U } |
uart parity mode. More... | |
enum | hal_uart_stop_bit_count_t { kHAL_UartOneStopBit = 0U, kHAL_UartTwoStopBit = 1U } |
uart stop bit count. More... | |
Functions | |
void | HAL_UartIsrFunction (hal_uart_handle_t handle) |
uart IRQ handle function. More... | |
Initialization and deinitialization | |
hal_uart_status_t | HAL_UartInit (hal_uart_handle_t handle, hal_uart_config_t *config) |
Initializes a uart instance with the uart handle and the user configuration structure. More... | |
hal_uart_status_t | HAL_UartDeinit (hal_uart_handle_t handle) |
Deinitializes a uart instance. More... | |
Blocking bus Operations | |
hal_uart_status_t | HAL_UartReceiveBlocking (hal_uart_handle_t handle, uint8_t *data, size_t length) |
Reads RX data register using a blocking method. More... | |
hal_uart_status_t | HAL_UartSendBlocking (hal_uart_handle_t handle, const uint8_t *data, size_t length) |
Writes to the TX register using a blocking method. More... | |
Functional API with non-blocking mode. | |
| |
hal_uart_status_t | HAL_UartInstallCallback (hal_uart_handle_t handle, hal_uart_transfer_callback_t callback, void *callbackParam) |
Installs a callback and callback parameter. More... | |
hal_uart_status_t | HAL_UartReceiveNonBlocking (hal_uart_handle_t handle, uint8_t *data, size_t length) |
Receives a buffer of data using an interrupt method. More... | |
hal_uart_status_t | HAL_UartSendNonBlocking (hal_uart_handle_t handle, const uint8_t *data, size_t length) |
Transmits a buffer of data using the interrupt method. More... | |
hal_uart_status_t | HAL_UartGetReceiveCount (hal_uart_handle_t handle, uint32_t *count) |
Gets the number of bytes that have been received. More... | |
hal_uart_status_t | HAL_UartGetSendCount (hal_uart_handle_t handle, uint32_t *count) |
Gets the number of bytes written to the uart TX register. More... | |
hal_uart_status_t | HAL_UartAbortReceive (hal_uart_handle_t handle) |
Aborts the interrupt-driven data receiving. More... | |
hal_uart_status_t | HAL_UartAbortSend (hal_uart_handle_t handle) |
Aborts the interrupt-driven data sending. More... | |
struct hal_uart_config_t |
Data Fields | |
uint32_t | srcClock_Hz |
Source clock. | |
uint32_t | baudRate_Bps |
Baud rate. | |
hal_uart_parity_mode_t | parityMode |
Parity mode, disabled (default), even, odd. | |
hal_uart_stop_bit_count_t | stopBitCount |
Number of stop bits, 1 stop bit (default) or 2 stop bits. | |
uint8_t | enableRx |
Enable RX. | |
uint8_t | enableTx |
Enable TX. | |
uint8_t | instance |
Instance (0 - UART0, 1 - UART1, ...), detail information please refer to the SOC corresponding RM. More... | |
uint8_t hal_uart_config_t::instance |
Invalid instance value will cause initialization failure.
struct hal_uart_transfer_t |
#define HAL_UART_TRANSFER_MODE (0U) |
(0 - disable, 1 - enable)
typedef void(* hal_uart_transfer_callback_t)(hal_uart_handle_t handle, hal_uart_status_t status, void *callbackParam) |
enum hal_uart_status_t |
hal_uart_status_t HAL_UartInit | ( | hal_uart_handle_t | handle, |
hal_uart_config_t * | config | ||
) |
This function configures the uart module with user-defined settings. The user can configure the configuration structure. The parameter handle is a pointer to point to a memory space of size #HAL_UART_HANDLE_SIZE allocated by the caller. Example below shows how to use this API to configure the uart.
handle | Pointer to point to a memory space of size #HAL_UART_HANDLE_SIZE allocated by the caller. |
config | Pointer to user-defined configuration structure. |
kStatus_HAL_UartBaudrateNotSupport | Baudrate is not support in current clock source. |
kStatus_HAL_UartSuccess | uart initialization succeed |
hal_uart_status_t HAL_UartDeinit | ( | hal_uart_handle_t | handle | ) |
This function waits for TX complete, disables TX and RX, and disables the uart clock.
handle | uart handle pointer. |
kStatus_HAL_UartSuccess | uart de-initialization succeed |
hal_uart_status_t HAL_UartReceiveBlocking | ( | hal_uart_handle_t | handle, |
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 reads data from the RX register.
handle | uart handle pointer. |
data | Start address of the buffer to store the received data. |
length | Size of the buffer. |
kStatus_HAL_UartError | An error occurred while receiving data. |
kStatus_HAL_UartParityError | A parity error occurred while receiving data. |
kStatus_HAL_UartSuccess | Successfully received all data. |
hal_uart_status_t HAL_UartSendBlocking | ( | hal_uart_handle_t | handle, |
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.
handle | uart handle pointer. |
data | Start address of the data to write. |
length | Size of the data to write. |
kStatus_HAL_UartSuccess | Successfully sent all data. |
hal_uart_status_t HAL_UartInstallCallback | ( | hal_uart_handle_t | handle, |
hal_uart_transfer_callback_t | callback, | ||
void * | callbackParam | ||
) |
This function is used to install the callback and callback parameter for uart module. When non-blocking sending or receiving finished, the adapter will notify the upper layer by the installed callback function. And the status is also passed as status parameter when the callback is called.
handle | uart handle pointer. |
callback | The callback function. |
callbackParam | The parameter of the callback function. |
kStatus_HAL_UartSuccess | Successfully install the callback. |
hal_uart_status_t HAL_UartReceiveNonBlocking | ( | hal_uart_handle_t | handle, |
uint8_t * | data, | ||
size_t | length | ||
) |
This function receives data using an interrupt method. This is a non-blocking function, which returns directly without waiting for all data to be received. The receive request is saved by the uart adapter. When the new data arrives, the receive request is serviced first. When all data is received, the uart adapter notifies the upper layer through a callback function and passes the status parameter kStatus_UART_RxIdle.
handle | uart handle pointer. |
data | Start address of the data to write. |
length | Size of the data to write. |
kStatus_HAL_UartSuccess | Successfully queue the transfer into transmit queue. |
kStatus_HAL_UartRxBusy | Previous receive request is not finished. |
kStatus_HAL_UartError | An error occurred. |
hal_uart_status_t HAL_UartSendNonBlocking | ( | hal_uart_handle_t | handle, |
const uint8_t * | data, | ||
size_t | length | ||
) |
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 ISR, the uart driver calls the callback function and passes the kStatus_UART_TxIdle as status parameter.
handle | uart handle pointer. |
data | Start address of the data to write. |
length | Size of the data to write. |
kStatus_HAL_UartSuccess | Successfully start the data transmission. |
kStatus_HAL_UartTxBusy | Previous transmission still not finished; data not all written to TX register yet. |
kStatus_HAL_UartError | An error occurred. |
hal_uart_status_t HAL_UartGetReceiveCount | ( | hal_uart_handle_t | handle, |
uint32_t * | count | ||
) |
This function gets the number of bytes that have been received.
handle | uart handle pointer. |
count | Receive bytes count. |
kStatus_HAL_UartError | An error occurred. |
kStatus_Success | Get successfully through the parameter count . |
hal_uart_status_t HAL_UartGetSendCount | ( | hal_uart_handle_t | handle, |
uint32_t * | count | ||
) |
This function gets the number of bytes written to the uart TX register by using the interrupt method.
handle | uart handle pointer. |
count | Send bytes count. |
kStatus_HAL_UartError | An error occurred. |
kStatus_Success | Get successfully through the parameter count . |
hal_uart_status_t HAL_UartAbortReceive | ( | hal_uart_handle_t | handle | ) |
This function aborts the interrupt-driven data receiving. The user can get the remainBytes to know how many bytes are not received yet.
handle | uart handle pointer. |
kStatus_Success | Get successfully abort the receiving. |
hal_uart_status_t HAL_UartAbortSend | ( | hal_uart_handle_t | handle | ) |
This function aborts the interrupt-driven data sending. The user can get the remainBytes to find out how many bytes are not sent out.
handle | uart handle pointer. |
kStatus_Success | Get successfully abort the sending. |
void HAL_UartIsrFunction | ( | hal_uart_handle_t | handle | ) |
This function handles the uart transmit and receive IRQ request.
handle | uart handle pointer. |