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