1 /*
2  * Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2021 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef _FSL_FLEXIO_UART_H_
10 #define _FSL_FLEXIO_UART_H_
11 
12 #include "fsl_common.h"
13 #include "fsl_flexio.h"
14 
15 /*!
16  * @addtogroup flexio_uart
17  * @{
18  */
19 
20 /*******************************************************************************
21  * Definitions
22  ******************************************************************************/
23 
24 /*! @name Driver version */
25 /*@{*/
26 /*! @brief FlexIO UART driver version. */
27 #define FSL_FLEXIO_UART_DRIVER_VERSION (MAKE_VERSION(2, 4, 0))
28 /*@}*/
29 
30 /*! @brief Retry times for waiting flag. */
31 #ifndef UART_RETRY_TIMES
32 #define UART_RETRY_TIMES 0U /* Defining to zero means to keep waiting for the flag until it is assert/deassert. */
33 #endif
34 
35 /*! @brief Error codes for the UART driver. */
36 enum
37 {
38     kStatus_FLEXIO_UART_TxBusy = MAKE_STATUS(kStatusGroup_FLEXIO_UART, 0), /*!< Transmitter is busy. */
39     kStatus_FLEXIO_UART_RxBusy = MAKE_STATUS(kStatusGroup_FLEXIO_UART, 1), /*!< Receiver is busy. */
40     kStatus_FLEXIO_UART_TxIdle = MAKE_STATUS(kStatusGroup_FLEXIO_UART, 2), /*!< UART transmitter is idle. */
41     kStatus_FLEXIO_UART_RxIdle = MAKE_STATUS(kStatusGroup_FLEXIO_UART, 3), /*!< UART receiver is idle. */
42     kStatus_FLEXIO_UART_ERROR  = MAKE_STATUS(kStatusGroup_FLEXIO_UART, 4), /*!< ERROR happens on UART. */
43     kStatus_FLEXIO_UART_RxRingBufferOverrun =
44         MAKE_STATUS(kStatusGroup_FLEXIO_UART, 5), /*!< UART RX software ring buffer overrun. */
45     kStatus_FLEXIO_UART_RxHardwareOverrun = MAKE_STATUS(kStatusGroup_FLEXIO_UART, 6), /*!< UART RX receiver overrun. */
46     kStatus_FLEXIO_UART_Timeout           = MAKE_STATUS(kStatusGroup_FLEXIO_UART, 7), /*!< UART times out. */
47     kStatus_FLEXIO_UART_BaudrateNotSupport =
48         MAKE_STATUS(kStatusGroup_FLEXIO_UART, 8) /*!< Baudrate is not supported in current clock source */
49 };
50 
51 /*! @brief FlexIO UART bit count per char. */
52 typedef enum _flexio_uart_bit_count_per_char
53 {
54     kFLEXIO_UART_7BitsPerChar = 7U, /*!< 7-bit data characters */
55     kFLEXIO_UART_8BitsPerChar = 8U, /*!< 8-bit data characters */
56     kFLEXIO_UART_9BitsPerChar = 9U, /*!< 9-bit data characters */
57 } flexio_uart_bit_count_per_char_t;
58 
59 /*! @brief Define FlexIO UART interrupt mask. */
60 enum _flexio_uart_interrupt_enable
61 {
62     kFLEXIO_UART_TxDataRegEmptyInterruptEnable = 0x1U, /*!< Transmit buffer empty interrupt enable. */
63     kFLEXIO_UART_RxDataRegFullInterruptEnable  = 0x2U, /*!< Receive buffer full interrupt enable. */
64 };
65 
66 /*! @brief Define FlexIO UART status mask. */
67 enum _flexio_uart_status_flags
68 {
69     kFLEXIO_UART_TxDataRegEmptyFlag = 0x1U, /*!< Transmit buffer empty flag. */
70     kFLEXIO_UART_RxDataRegFullFlag  = 0x2U, /*!< Receive buffer full flag. */
71     kFLEXIO_UART_RxOverRunFlag      = 0x4U, /*!< Receive buffer over run flag. */
72 };
73 
74 /*! @brief Define FlexIO UART access structure typedef. */
75 typedef struct _flexio_uart_type
76 {
77     FLEXIO_Type *flexioBase; /*!< FlexIO base pointer. */
78     uint8_t TxPinIndex;      /*!< Pin select for UART_Tx. */
79     uint8_t RxPinIndex;      /*!< Pin select for UART_Rx. */
80     uint8_t shifterIndex[2]; /*!< Shifter index used in FlexIO UART. */
81     uint8_t timerIndex[2];   /*!< Timer index used in FlexIO UART. */
82 } FLEXIO_UART_Type;
83 
84 /*! @brief Define FlexIO UART user configuration structure. */
85 typedef struct _flexio_uart_config
86 {
87     bool enableUart;                                  /*!< Enable/disable FlexIO UART TX & RX. */
88     bool enableInDoze;                                /*!< Enable/disable FlexIO operation in doze mode*/
89     bool enableInDebug;                               /*!< Enable/disable FlexIO operation in debug mode*/
90     bool enableFastAccess;                            /*!< Enable/disable fast access to FlexIO registers,
91                                                        fast access requires the FlexIO clock to be at least
92                                                        twice the frequency of the bus clock. */
93     uint32_t baudRate_Bps;                            /*!< Baud rate in Bps. */
94     flexio_uart_bit_count_per_char_t bitCountPerChar; /*!< number of bits, 7/8/9 -bit */
95 } flexio_uart_config_t;
96 
97 /*! @brief Define FlexIO UART transfer structure. */
98 typedef struct _flexio_uart_transfer
99 {
100     /*
101      * Use separate TX and RX data pointer, because TX data is const data.
102      * The member data is kept for backward compatibility.
103      */
104     union
105     {
106         uint8_t *data;         /*!< The buffer of data to be transfer.*/
107         uint8_t *rxData;       /*!< The buffer to receive data. */
108         const uint8_t *txData; /*!< The buffer of data to be sent. */
109     };
110     size_t dataSize; /*!< Transfer size*/
111 } flexio_uart_transfer_t;
112 
113 /* Forward declaration of the handle typedef. */
114 typedef struct _flexio_uart_handle flexio_uart_handle_t;
115 
116 /*! @brief FlexIO UART transfer callback function. */
117 typedef void (*flexio_uart_transfer_callback_t)(FLEXIO_UART_Type *base,
118                                                 flexio_uart_handle_t *handle,
119                                                 status_t status,
120                                                 void *userData);
121 
122 /*! @brief Define FLEXIO UART handle structure*/
123 struct _flexio_uart_handle
124 {
125     const uint8_t *volatile txData; /*!< Address of remaining data to send. */
126     volatile size_t txDataSize;     /*!< Size of the remaining data to send. */
127     uint8_t *volatile rxData;       /*!< Address of remaining data to receive. */
128     volatile size_t rxDataSize;     /*!< Size of the remaining data to receive. */
129     size_t txDataSizeAll;           /*!< Total bytes to be sent. */
130     size_t rxDataSizeAll;           /*!< Total bytes to be received. */
131 
132     uint8_t *rxRingBuffer;              /*!< Start address of the receiver ring buffer. */
133     size_t rxRingBufferSize;            /*!< Size of the ring buffer. */
134     volatile uint16_t rxRingBufferHead; /*!< Index for the driver to store received data into ring buffer. */
135     volatile uint16_t rxRingBufferTail; /*!< Index for the user to get data from the ring buffer. */
136 
137     flexio_uart_transfer_callback_t callback; /*!< Callback function. */
138     void *userData;                           /*!< UART callback function parameter.*/
139 
140     volatile uint8_t txState; /*!< TX transfer state. */
141     volatile uint8_t rxState; /*!< RX transfer state */
142 };
143 
144 /*******************************************************************************
145  * API
146  ******************************************************************************/
147 
148 #if defined(__cplusplus)
149 extern "C" {
150 #endif /*_cplusplus*/
151 
152 /*!
153  * @name Initialization and deinitialization
154  * @{
155  */
156 
157 /*!
158  * @brief Ungates the FlexIO clock, resets the FlexIO module, configures FlexIO UART
159  * hardware, and configures the FlexIO UART with FlexIO UART configuration.
160  * The configuration structure can be filled by the user or be set with
161  * default values by FLEXIO_UART_GetDefaultConfig().
162  *
163  * Example
164    @code
165    FLEXIO_UART_Type base = {
166    .flexioBase = FLEXIO,
167    .TxPinIndex = 0,
168    .RxPinIndex = 1,
169    .shifterIndex = {0,1},
170    .timerIndex = {0,1}
171    };
172    flexio_uart_config_t config = {
173    .enableInDoze = false,
174    .enableInDebug = true,
175    .enableFastAccess = false,
176    .baudRate_Bps = 115200U,
177    .bitCountPerChar = 8
178    };
179    FLEXIO_UART_Init(base, &config, srcClock_Hz);
180    @endcode
181  *
182  * @param base Pointer to the FLEXIO_UART_Type structure.
183  * @param userConfig Pointer to the flexio_uart_config_t structure.
184  * @param srcClock_Hz FlexIO source clock in Hz.
185  * @retval kStatus_Success Configuration success.
186  * @retval kStatus_FLEXIO_UART_BaudrateNotSupport Baudrate is not supported for current clock source frequency.
187 */
188 status_t FLEXIO_UART_Init(FLEXIO_UART_Type *base, const flexio_uart_config_t *userConfig, uint32_t srcClock_Hz);
189 
190 /*!
191  * @brief Resets the FlexIO UART shifter and timer config.
192  *
193  * @note After calling this API, call the FLEXO_UART_Init to use the FlexIO UART module.
194  *
195  * @param base Pointer to FLEXIO_UART_Type structure
196  */
197 void FLEXIO_UART_Deinit(FLEXIO_UART_Type *base);
198 
199 /*!
200  * @brief Gets the default configuration to configure the FlexIO UART. The configuration
201  * can be used directly for calling the FLEXIO_UART_Init().
202  * Example:
203    @code
204    flexio_uart_config_t config;
205    FLEXIO_UART_GetDefaultConfig(&userConfig);
206    @endcode
207  * @param userConfig Pointer to the flexio_uart_config_t structure.
208 */
209 void FLEXIO_UART_GetDefaultConfig(flexio_uart_config_t *userConfig);
210 
211 /* @} */
212 
213 /*!
214  * @name Status
215  * @{
216  */
217 
218 /*!
219  * @brief Gets the FlexIO UART status flags.
220  *
221  * @param base Pointer to the FLEXIO_UART_Type structure.
222  * @return FlexIO UART status flags.
223  */
224 
225 uint32_t FLEXIO_UART_GetStatusFlags(FLEXIO_UART_Type *base);
226 
227 /*!
228  * @brief Gets the FlexIO UART status flags.
229  *
230  * @param base Pointer to the FLEXIO_UART_Type structure.
231  * @param mask Status flag.
232  *      The parameter can be any combination of the following values:
233  *          @arg kFLEXIO_UART_TxDataRegEmptyFlag
234  *          @arg kFLEXIO_UART_RxEmptyFlag
235  *          @arg kFLEXIO_UART_RxOverRunFlag
236  */
237 
238 void FLEXIO_UART_ClearStatusFlags(FLEXIO_UART_Type *base, uint32_t mask);
239 
240 /* @} */
241 
242 /*!
243  * @name Interrupts
244  * @{
245  */
246 
247 /*!
248  * @brief Enables the FlexIO UART interrupt.
249  *
250  * This function enables the FlexIO UART interrupt.
251  *
252  * @param base Pointer to the FLEXIO_UART_Type structure.
253  * @param mask Interrupt source.
254  */
255 void FLEXIO_UART_EnableInterrupts(FLEXIO_UART_Type *base, uint32_t mask);
256 
257 /*!
258  * @brief Disables the FlexIO UART interrupt.
259  *
260  * This function disables the FlexIO UART interrupt.
261  *
262  * @param base Pointer to the FLEXIO_UART_Type structure.
263  * @param mask Interrupt source.
264  */
265 void FLEXIO_UART_DisableInterrupts(FLEXIO_UART_Type *base, uint32_t mask);
266 
267 /* @} */
268 
269 /*!
270  * @name DMA Control
271  * @{
272  */
273 
274 /*!
275  * @brief Gets the FlexIO UARt transmit data register address.
276  *
277  * This function returns the UART data register address, which is mainly used by DMA/eDMA.
278  *
279  * @param base Pointer to the FLEXIO_UART_Type structure.
280  * @return FlexIO UART transmit data register address.
281  */
FLEXIO_UART_GetTxDataRegisterAddress(FLEXIO_UART_Type * base)282 static inline uint32_t FLEXIO_UART_GetTxDataRegisterAddress(FLEXIO_UART_Type *base)
283 {
284     return FLEXIO_GetShifterBufferAddress(base->flexioBase, kFLEXIO_ShifterBuffer, base->shifterIndex[0]);
285 }
286 
287 /*!
288  * @brief Gets the FlexIO UART receive data register address.
289  *
290  * This function returns the UART data register address, which is mainly used by DMA/eDMA.
291  *
292  * @param base Pointer to the FLEXIO_UART_Type structure.
293  * @return FlexIO UART receive data register address.
294  */
FLEXIO_UART_GetRxDataRegisterAddress(FLEXIO_UART_Type * base)295 static inline uint32_t FLEXIO_UART_GetRxDataRegisterAddress(FLEXIO_UART_Type *base)
296 {
297     return FLEXIO_GetShifterBufferAddress(base->flexioBase, kFLEXIO_ShifterBufferByteSwapped, base->shifterIndex[1]);
298 }
299 
300 /*!
301  * @brief Enables/disables the FlexIO UART transmit DMA.
302  * This function enables/disables the FlexIO UART Tx DMA,
303  * which means asserting the kFLEXIO_UART_TxDataRegEmptyFlag does/doesn't trigger the DMA request.
304  *
305  * @param base Pointer to the FLEXIO_UART_Type structure.
306  * @param enable True to enable, false to disable.
307  */
FLEXIO_UART_EnableTxDMA(FLEXIO_UART_Type * base,bool enable)308 static inline void FLEXIO_UART_EnableTxDMA(FLEXIO_UART_Type *base, bool enable)
309 {
310     FLEXIO_EnableShifterStatusDMA(base->flexioBase, 1UL << base->shifterIndex[0], enable);
311 }
312 
313 /*!
314  * @brief Enables/disables the FlexIO UART receive DMA.
315  * This function enables/disables the FlexIO UART Rx DMA,
316  * which means asserting kFLEXIO_UART_RxDataRegFullFlag does/doesn't trigger the DMA request.
317  *
318  * @param base Pointer to the FLEXIO_UART_Type structure.
319  * @param enable True to enable, false to disable.
320  */
FLEXIO_UART_EnableRxDMA(FLEXIO_UART_Type * base,bool enable)321 static inline void FLEXIO_UART_EnableRxDMA(FLEXIO_UART_Type *base, bool enable)
322 {
323     FLEXIO_EnableShifterStatusDMA(base->flexioBase, 1UL << base->shifterIndex[1], enable);
324 }
325 
326 /* @} */
327 
328 /*!
329  * @name Bus Operations
330  * @{
331  */
332 
333 /*!
334  * @brief Enables/disables the FlexIO UART module operation.
335  *
336  * @param base Pointer to the FLEXIO_UART_Type.
337  * @param enable True to enable, false does not have any effect.
338  */
FLEXIO_UART_Enable(FLEXIO_UART_Type * base,bool enable)339 static inline void FLEXIO_UART_Enable(FLEXIO_UART_Type *base, bool enable)
340 {
341     if (enable)
342     {
343         base->flexioBase->CTRL |= FLEXIO_CTRL_FLEXEN_MASK;
344     }
345 }
346 
347 /*!
348  * @brief Writes one byte of data.
349  *
350  * @note This is a non-blocking API, which returns directly after the data is put into the
351  * data register. Ensure that the TxEmptyFlag is asserted before calling
352  * this API.
353  *
354  * @param base Pointer to the FLEXIO_UART_Type structure.
355  * @param buffer The data bytes to send.
356  */
FLEXIO_UART_WriteByte(FLEXIO_UART_Type * base,const uint8_t * buffer)357 static inline void FLEXIO_UART_WriteByte(FLEXIO_UART_Type *base, const uint8_t *buffer)
358 {
359     base->flexioBase->SHIFTBUF[base->shifterIndex[0]] = *buffer;
360 }
361 
362 /*!
363  * @brief Reads one byte of data.
364  *
365  * @note This is a non-blocking API, which returns directly after the data is read from the
366  * data register. Ensure that the RxFullFlag is asserted before calling this API.
367  *
368  * @param base Pointer to the FLEXIO_UART_Type structure.
369  * @param buffer The buffer to store the received bytes.
370  */
FLEXIO_UART_ReadByte(FLEXIO_UART_Type * base,uint8_t * buffer)371 static inline void FLEXIO_UART_ReadByte(FLEXIO_UART_Type *base, uint8_t *buffer)
372 {
373     *buffer = (uint8_t)(base->flexioBase->SHIFTBUFBYS[base->shifterIndex[1]]);
374 }
375 
376 /*!
377  * @brief Sends a buffer of data bytes.
378  *
379  * @note This function blocks using the polling method until all bytes have been sent.
380  *
381  * @param base Pointer to the FLEXIO_UART_Type structure.
382  * @param txData The data bytes to send.
383  * @param txSize The number of data bytes to send.
384  * @retval kStatus_FLEXIO_UART_Timeout Transmission timed out and was aborted.
385  * @retval kStatus_Success Successfully wrote all data.
386  */
387 status_t FLEXIO_UART_WriteBlocking(FLEXIO_UART_Type *base, const uint8_t *txData, size_t txSize);
388 
389 /*!
390  * @brief Receives a buffer of bytes.
391  *
392  * @note This function blocks using the polling method until all bytes have been received.
393  *
394  * @param base Pointer to the FLEXIO_UART_Type structure.
395  * @param rxData The buffer to store the received bytes.
396  * @param rxSize The number of data bytes to be received.
397  * @retval kStatus_FLEXIO_UART_Timeout Transmission timed out and was aborted.
398  * @retval kStatus_Success Successfully received all data.
399  */
400 status_t FLEXIO_UART_ReadBlocking(FLEXIO_UART_Type *base, uint8_t *rxData, size_t rxSize);
401 
402 /* @} */
403 
404 /*!
405  * @name Transactional
406  * @{
407  */
408 
409 /*!
410  * @brief Initializes the UART handle.
411  *
412  * This function initializes the FlexIO UART handle, which can be used for other FlexIO
413  * UART transactional APIs. Call this API once to get the
414  * initialized handle.
415  *
416  * The UART driver supports the "background" receiving, which means that users can set up
417  * a RX ring buffer optionally. Data received is stored into the ring buffer even when
418  * the user doesn't call the FLEXIO_UART_TransferReceiveNonBlocking() API. If there is already data
419  * received in the ring buffer, users can get the received data from the ring buffer
420  * directly. The ring buffer is disabled if passing NULL as @p ringBuffer.
421  *
422  * @param base to FLEXIO_UART_Type structure.
423  * @param handle Pointer to the flexio_uart_handle_t structure to store the transfer state.
424  * @param callback The callback function.
425  * @param userData The parameter of the callback function.
426  * @retval kStatus_Success Successfully create the handle.
427  * @retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range.
428  */
429 status_t FLEXIO_UART_TransferCreateHandle(FLEXIO_UART_Type *base,
430                                           flexio_uart_handle_t *handle,
431                                           flexio_uart_transfer_callback_t callback,
432                                           void *userData);
433 
434 /*!
435  * @brief Sets up the RX ring buffer.
436  *
437  * This function sets up the RX ring buffer to a specific UART handle.
438  *
439  * When the RX ring buffer is used, data received is stored into the ring buffer even when
440  * the user doesn't call the UART_ReceiveNonBlocking() API. If there is already data received
441  * in the ring buffer, users can get the received data from the ring buffer directly.
442  *
443  * @note When using the RX ring buffer, one byte is reserved for internal use. In other
444  * words, if @p ringBufferSize is 32, only 31 bytes are used for saving data.
445  *
446  * @param base Pointer to the FLEXIO_UART_Type structure.
447  * @param handle Pointer to the flexio_uart_handle_t structure to store the transfer state.
448  * @param ringBuffer Start address of ring buffer for background receiving. Pass NULL to disable the ring buffer.
449  * @param ringBufferSize Size of the ring buffer.
450  */
451 void FLEXIO_UART_TransferStartRingBuffer(FLEXIO_UART_Type *base,
452                                          flexio_uart_handle_t *handle,
453                                          uint8_t *ringBuffer,
454                                          size_t ringBufferSize);
455 
456 /*!
457  * @brief Aborts the background transfer and uninstalls the ring buffer.
458  *
459  * This function aborts the background transfer and uninstalls the ring buffer.
460  *
461  * @param base Pointer to the FLEXIO_UART_Type structure.
462  * @param handle Pointer to the flexio_uart_handle_t structure to store the transfer state.
463  */
464 void FLEXIO_UART_TransferStopRingBuffer(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle);
465 
466 /*!
467  * @brief Transmits a buffer of data using the interrupt method.
468  *
469  * This function sends data using an interrupt method. This is a non-blocking function,
470  * which returns directly without waiting for all data to be written to the TX register. When
471  * all data is written to the TX register in ISR, the FlexIO UART driver calls the callback
472  * function and passes the @ref kStatus_FLEXIO_UART_TxIdle as status parameter.
473  *
474  * @note The kStatus_FLEXIO_UART_TxIdle is passed to the upper layer when all data is written
475  * to the TX register. However, it does not ensure that all data is sent out.
476  *
477  * @param base Pointer to the FLEXIO_UART_Type structure.
478  * @param handle Pointer to the flexio_uart_handle_t structure to store the transfer state.
479  * @param xfer FlexIO UART transfer structure. See #flexio_uart_transfer_t.
480  * @retval kStatus_Success Successfully starts the data transmission.
481  * @retval kStatus_UART_TxBusy Previous transmission still not finished, data not written to the TX register.
482  */
483 status_t FLEXIO_UART_TransferSendNonBlocking(FLEXIO_UART_Type *base,
484                                              flexio_uart_handle_t *handle,
485                                              flexio_uart_transfer_t *xfer);
486 
487 /*!
488  * @brief Aborts the interrupt-driven data transmit.
489  *
490  * This function aborts the interrupt-driven data sending. Get the remainBytes to find out
491  * how many bytes are still not sent out.
492  *
493  * @param base Pointer to the FLEXIO_UART_Type structure.
494  * @param handle Pointer to the flexio_uart_handle_t structure to store the transfer state.
495  */
496 void FLEXIO_UART_TransferAbortSend(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle);
497 
498 /*!
499  * @brief Gets the number of bytes sent.
500  *
501  * This function gets the number of bytes sent driven by interrupt.
502  *
503  * @param base Pointer to the FLEXIO_UART_Type structure.
504  * @param handle Pointer to the flexio_uart_handle_t structure to store the transfer state.
505  * @param count Number of bytes sent so far by the non-blocking transaction.
506  * @retval kStatus_NoTransferInProgress transfer has finished or no transfer in progress.
507  * @retval kStatus_Success Successfully return the count.
508  */
509 status_t FLEXIO_UART_TransferGetSendCount(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, size_t *count);
510 
511 /*!
512  * @brief Receives a buffer of data using the interrupt method.
513  *
514  * This function receives data using the interrupt method. This is a non-blocking function,
515  * which returns without waiting for all data to be received.
516  * If the RX ring buffer is used and not empty, the data in ring buffer is copied and
517  * the parameter @p receivedBytes shows how many bytes are copied from the ring buffer.
518  * After copying, if the data in ring buffer is not enough to read, the receive
519  * request is saved by the UART driver. When new data arrives, the receive request
520  * is serviced first. When all data is received, the UART driver notifies the upper layer
521  * through a callback function and passes the status parameter kStatus_UART_RxIdle.
522  * For example, if the upper layer needs 10 bytes but there are only 5 bytes in the ring buffer,
523  * the 5 bytes are copied to xfer->data. This function returns with the
524  * parameter @p receivedBytes set to 5. For the last 5 bytes, newly arrived data is
525  * saved from the xfer->data[5]. When 5 bytes are received, the UART driver notifies upper layer.
526  * If the RX ring buffer is not enabled, this function enables the RX and RX interrupt
527  * to receive data to xfer->data. When all data is received, the upper layer is notified.
528  *
529  * @param base Pointer to the FLEXIO_UART_Type structure.
530  * @param handle Pointer to the flexio_uart_handle_t structure to store the transfer state.
531  * @param xfer UART transfer structure. See #flexio_uart_transfer_t.
532  * @param receivedBytes Bytes received from the ring buffer directly.
533  * @retval kStatus_Success Successfully queue the transfer into the transmit queue.
534  * @retval kStatus_FLEXIO_UART_RxBusy Previous receive request is not finished.
535  */
536 status_t FLEXIO_UART_TransferReceiveNonBlocking(FLEXIO_UART_Type *base,
537                                                 flexio_uart_handle_t *handle,
538                                                 flexio_uart_transfer_t *xfer,
539                                                 size_t *receivedBytes);
540 
541 /*!
542  * @brief Aborts the receive data which was using IRQ.
543  *
544  * This function aborts the receive data which was using IRQ.
545  *
546  * @param base Pointer to the FLEXIO_UART_Type structure.
547  * @param handle Pointer to the flexio_uart_handle_t structure to store the transfer state.
548  */
549 void FLEXIO_UART_TransferAbortReceive(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle);
550 
551 /*!
552  * @brief Gets the number of bytes received.
553  *
554  * This function gets the number of bytes received driven by interrupt.
555  *
556  * @param base Pointer to the FLEXIO_UART_Type structure.
557  * @param handle Pointer to the flexio_uart_handle_t structure to store the transfer state.
558  * @param count Number of bytes received so far by the non-blocking transaction.
559  * @retval kStatus_NoTransferInProgress transfer has finished or no transfer in progress.
560  * @retval kStatus_Success Successfully return the count.
561  */
562 status_t FLEXIO_UART_TransferGetReceiveCount(FLEXIO_UART_Type *base, flexio_uart_handle_t *handle, size_t *count);
563 
564 /*!
565  * @brief FlexIO UART IRQ handler function.
566  *
567  * This function processes the FlexIO UART transmit and receives the IRQ request.
568  *
569  * @param uartType Pointer to the FLEXIO_UART_Type structure.
570  * @param uartHandle Pointer to the flexio_uart_handle_t structure to store the transfer state.
571  */
572 void FLEXIO_UART_TransferHandleIRQ(void *uartType, void *uartHandle);
573 
574 /*@}*/
575 
576 #if defined(__cplusplus)
577 }
578 #endif /*_cplusplus*/
579 /*@}*/
580 
581 #endif /*_FSL_FLEXIO_UART_H_*/
582