9#ifndef _FSL_FLEXIO_UART_H_
10#define _FSL_FLEXIO_UART_H_
12#include "fsl_common.h"
13#include "fsl_flexio.h"
27#define FSL_FLEXIO_UART_DRIVER_VERSION (MAKE_VERSION(2, 4, 0))
31#ifndef UART_RETRY_TIMES
32#define UART_RETRY_TIMES 0U
148#if defined(__cplusplus)
282static inline uint32_t FLEXIO_UART_GetTxDataRegisterAddress(
FLEXIO_UART_Type *base)
295static inline uint32_t FLEXIO_UART_GetRxDataRegisterAddress(
FLEXIO_UART_Type *base)
308static inline void FLEXIO_UART_EnableTxDMA(
FLEXIO_UART_Type *base,
bool enable)
310 FLEXIO_EnableShifterStatusDMA(base->flexioBase, 1UL << base->shifterIndex[0], enable);
321static inline void FLEXIO_UART_EnableRxDMA(
FLEXIO_UART_Type *base,
bool enable)
323 FLEXIO_EnableShifterStatusDMA(base->flexioBase, 1UL << base->shifterIndex[1], enable);
343 base->flexioBase->CTRL |= FLEXIO_CTRL_FLEXEN_MASK;
357static inline void FLEXIO_UART_WriteByte(
FLEXIO_UART_Type *base,
const uint8_t *buffer)
359 base->flexioBase->SHIFTBUF[base->shifterIndex[0]] = *buffer;
371static inline void FLEXIO_UART_ReadByte(
FLEXIO_UART_Type *base, uint8_t *buffer)
373 *buffer = (uint8_t)(base->flexioBase->SHIFTBUFBYS[base->shifterIndex[1]]);
454 size_t ringBufferSize);
539 size_t *receivedBytes);
576#if defined(__cplusplus)
uint32_t FLEXIO_GetShifterBufferAddress(FLEXIO_Type *base, flexio_shifter_buffer_type_t type, uint8_t index)
Gets the shifter buffer address for the DMA transfer usage.
Definition: fsl_flexio.c:173
@ kFLEXIO_ShifterBuffer
Definition: fsl_flexio.h:223
@ kFLEXIO_ShifterBufferByteSwapped
Definition: fsl_flexio.h:225
bool enableFastAccess
Definition: fsl_flexio_uart.h:90
void FLEXIO_UART_TransferAbortSend(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle)
Aborts the interrupt-driven data transmit.
Definition: fsl_flexio_uart.c:649
const uint8_t * txData
Definition: fsl_flexio_uart.h:108
void FLEXIO_UART_TransferStartRingBuffer(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, uint8_t *ringBuffer, size_t ringBufferSize)
Sets up the RX ring buffer.
Definition: fsl_flexio_uart.c:547
void * userData
Definition: fsl_flexio_uart.h:138
void FLEXIO_UART_ClearStatusFlags(FLEXIO_UART_Type *base, uint32_t mask)
Gets the FlexIO UART status flags.
Definition: fsl_flexio_uart.c:379
volatile uint16_t rxRingBufferHead
Definition: fsl_flexio_uart.h:134
void(* flexio_uart_transfer_callback_t)(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, status_t status, void *userData)
FlexIO UART transfer callback function.
Definition: fsl_flexio_uart.h:117
void FLEXIO_UART_TransferAbortReceive(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle)
Aborts the receive data which was using IRQ.
Definition: fsl_flexio_uart.c:834
const uint8_t *volatile txData
Definition: fsl_flexio_uart.h:125
volatile uint8_t rxState
Definition: fsl_flexio_uart.h:141
status_t FLEXIO_UART_TransferGetReceiveCount(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, size_t *count)
Gets the number of bytes received.
Definition: fsl_flexio_uart.c:858
void FLEXIO_UART_TransferHandleIRQ(void *uartType, void *uartHandle)
FlexIO UART IRQ handler function.
Definition: fsl_flexio_uart.c:881
size_t rxDataSizeAll
Definition: fsl_flexio_uart.h:130
status_t FLEXIO_UART_TransferGetSendCount(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, size_t *count)
Gets the number of bytes sent.
Definition: fsl_flexio_uart.c:669
struct _flexio_uart_type FLEXIO_UART_Type
Define FlexIO UART access structure typedef.
volatile uint16_t rxRingBufferTail
Definition: fsl_flexio_uart.h:135
void FLEXIO_UART_Deinit(FLEXIO_UART_Type *base)
Resets the FlexIO UART shifter and timer config.
Definition: fsl_flexio_uart.c:260
uint32_t baudRate_Bps
Definition: fsl_flexio_uart.h:93
flexio_uart_bit_count_per_char_t bitCountPerChar
Definition: fsl_flexio_uart.h:94
uint8_t shifterIndex[2]
Definition: fsl_flexio_uart.h:80
struct _flexio_uart_transfer flexio_uart_transfer_t
Define FlexIO UART transfer structure.
uint8_t * rxData
Definition: fsl_flexio_uart.h:107
size_t rxRingBufferSize
Definition: fsl_flexio_uart.h:133
void FLEXIO_UART_EnableInterrupts(FLEXIO_UART_Type *base, uint32_t mask)
Enables the FlexIO UART interrupt.
Definition: fsl_flexio_uart.c:315
uint8_t RxPinIndex
Definition: fsl_flexio_uart.h:79
status_t FLEXIO_UART_ReadBlocking(FLEXIO_UART_Type *base, uint8_t *rxData, size_t rxSize)
Receives a buffer of bytes.
Definition: fsl_flexio_uart.c:449
status_t FLEXIO_UART_Init(FLEXIO_UART_Type *base, const flexio_uart_config_t *userConfig, uint32_t srcClock_Hz)
Ungates the FlexIO clock, resets the FlexIO module, configures FlexIO UART hardware,...
Definition: fsl_flexio_uart.c:124
size_t txDataSizeAll
Definition: fsl_flexio_uart.h:129
enum _flexio_uart_bit_count_per_char flexio_uart_bit_count_per_char_t
FlexIO UART bit count per char.
volatile size_t txDataSize
Definition: fsl_flexio_uart.h:126
flexio_uart_transfer_callback_t callback
Definition: fsl_flexio_uart.h:137
uint8_t * data
Definition: fsl_flexio_uart.h:106
size_t dataSize
Definition: fsl_flexio_uart.h:110
bool enableInDebug
Definition: fsl_flexio_uart.h:89
uint8_t TxPinIndex
Definition: fsl_flexio_uart.h:78
status_t FLEXIO_UART_WriteBlocking(FLEXIO_UART_Type *base, const uint8_t *txData, size_t txSize)
Sends a buffer of data bytes.
Definition: fsl_flexio_uart.c:406
void FLEXIO_UART_TransferStopRingBuffer(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle)
Aborts the background transfer and uninstalls the ring buffer.
Definition: fsl_flexio_uart.c:575
_flexio_uart_interrupt_enable
Define FlexIO UART interrupt mask.
Definition: fsl_flexio_uart.h:61
uint8_t *volatile rxData
Definition: fsl_flexio_uart.h:127
status_t FLEXIO_UART_TransferSendNonBlocking(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, flexio_uart_transfer_t *xfer)
Transmits a buffer of data using the interrupt method.
Definition: fsl_flexio_uart.c:607
status_t FLEXIO_UART_TransferReceiveNonBlocking(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, flexio_uart_transfer_t *xfer, size_t *receivedBytes)
Receives a buffer of data using the interrupt method.
Definition: fsl_flexio_uart.c:709
void FLEXIO_UART_GetDefaultConfig(flexio_uart_config_t *userConfig)
Gets the default configuration to configure the FlexIO UART. The configuration can be used directly f...
Definition: fsl_flexio_uart.c:290
_flexio_uart_status_flags
Define FlexIO UART status mask.
Definition: fsl_flexio_uart.h:68
_flexio_uart_bit_count_per_char
FlexIO UART bit count per char.
Definition: fsl_flexio_uart.h:53
uint8_t * rxRingBuffer
Definition: fsl_flexio_uart.h:132
bool enableInDoze
Definition: fsl_flexio_uart.h:88
status_t FLEXIO_UART_TransferCreateHandle(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, flexio_uart_transfer_callback_t callback, void *userData)
Initializes the UART handle.
Definition: fsl_flexio_uart.c:501
struct _flexio_uart_config flexio_uart_config_t
Define FlexIO UART user configuration structure.
FLEXIO_Type * flexioBase
Definition: fsl_flexio_uart.h:77
volatile size_t rxDataSize
Definition: fsl_flexio_uart.h:128
bool enableUart
Definition: fsl_flexio_uart.h:87
uint32_t FLEXIO_UART_GetStatusFlags(FLEXIO_UART_Type *base)
Gets the FlexIO UART status flags.
Definition: fsl_flexio_uart.c:354
void FLEXIO_UART_DisableInterrupts(FLEXIO_UART_Type *base, uint32_t mask)
Disables the FlexIO UART interrupt.
Definition: fsl_flexio_uart.c:335
uint8_t timerIndex[2]
Definition: fsl_flexio_uart.h:81
volatile uint8_t txState
Definition: fsl_flexio_uart.h:140
@ kFLEXIO_UART_TxDataRegEmptyInterruptEnable
Definition: fsl_flexio_uart.h:62
@ kFLEXIO_UART_RxDataRegFullInterruptEnable
Definition: fsl_flexio_uart.h:63
@ kFLEXIO_UART_RxOverRunFlag
Definition: fsl_flexio_uart.h:71
@ kFLEXIO_UART_RxDataRegFullFlag
Definition: fsl_flexio_uart.h:70
@ kFLEXIO_UART_TxDataRegEmptyFlag
Definition: fsl_flexio_uart.h:69
@ kFLEXIO_UART_9BitsPerChar
Definition: fsl_flexio_uart.h:56
@ kFLEXIO_UART_8BitsPerChar
Definition: fsl_flexio_uart.h:55
@ kFLEXIO_UART_7BitsPerChar
Definition: fsl_flexio_uart.h:54
@ kStatus_FLEXIO_UART_BaudrateNotSupport
Definition: fsl_flexio_uart.h:47
@ kStatus_FLEXIO_UART_ERROR
Definition: fsl_flexio_uart.h:42
@ kStatus_FLEXIO_UART_RxIdle
Definition: fsl_flexio_uart.h:41
@ kStatus_FLEXIO_UART_RxRingBufferOverrun
Definition: fsl_flexio_uart.h:43
@ kStatus_FLEXIO_UART_Timeout
Definition: fsl_flexio_uart.h:46
@ kStatus_FLEXIO_UART_TxBusy
Definition: fsl_flexio_uart.h:38
@ kStatus_FLEXIO_UART_TxIdle
Definition: fsl_flexio_uart.h:40
@ kStatus_FLEXIO_UART_RxBusy
Definition: fsl_flexio_uart.h:39
@ kStatus_FLEXIO_UART_RxHardwareOverrun
Definition: fsl_flexio_uart.h:45
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:225
#define MAKE_STATUS(group, code)
Construct a status code value from a group and code number.
Definition: fsl_common.h:47
@ kStatusGroup_FLEXIO_UART
Definition: fsl_common.h:90
Definition: MIMXRT1052.h:20511
Define FlexIO UART user configuration structure.
Definition: fsl_flexio_uart.h:86
Define FLEXIO UART handle structure.
Definition: fsl_flexio_uart.h:124
Define FlexIO UART transfer structure.
Definition: fsl_flexio_uart.h:99
Define FlexIO UART access structure typedef.
Definition: fsl_flexio_uart.h:76