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_K66F/TOOLCHAIN_IAR/fsl_uart.h@172:65be27845400, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 20:53:29 2019 +0000
- Revision:
- 172:65be27845400
- Parent:
- 171:3a7713b1edbc
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 143:86740a56073b | 1 | /* |
AnnaBridge | 143:86740a56073b | 2 | * Copyright (c) 2015-2016, Freescale Semiconductor, Inc. |
AnnaBridge | 143:86740a56073b | 3 | * Copyright 2016-2017 NXP |
AnnaBridge | 143:86740a56073b | 4 | * |
AnnaBridge | 143:86740a56073b | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 143:86740a56073b | 6 | * are permitted provided that the following conditions are met: |
AnnaBridge | 143:86740a56073b | 7 | * |
AnnaBridge | 143:86740a56073b | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
AnnaBridge | 143:86740a56073b | 9 | * of conditions and the following disclaimer. |
AnnaBridge | 143:86740a56073b | 10 | * |
AnnaBridge | 143:86740a56073b | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
AnnaBridge | 143:86740a56073b | 12 | * list of conditions and the following disclaimer in the documentation and/or |
AnnaBridge | 143:86740a56073b | 13 | * other materials provided with the distribution. |
AnnaBridge | 143:86740a56073b | 14 | * |
AnnaBridge | 143:86740a56073b | 15 | * o Neither the name of the copyright holder nor the names of its |
AnnaBridge | 143:86740a56073b | 16 | * contributors may be used to endorse or promote products derived from this |
AnnaBridge | 143:86740a56073b | 17 | * software without specific prior written permission. |
AnnaBridge | 143:86740a56073b | 18 | * |
AnnaBridge | 143:86740a56073b | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
AnnaBridge | 143:86740a56073b | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
AnnaBridge | 143:86740a56073b | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 143:86740a56073b | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
AnnaBridge | 143:86740a56073b | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
AnnaBridge | 143:86740a56073b | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
AnnaBridge | 143:86740a56073b | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
AnnaBridge | 143:86740a56073b | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AnnaBridge | 143:86740a56073b | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
AnnaBridge | 143:86740a56073b | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 143:86740a56073b | 29 | */ |
AnnaBridge | 143:86740a56073b | 30 | #ifndef _FSL_UART_H_ |
AnnaBridge | 143:86740a56073b | 31 | #define _FSL_UART_H_ |
AnnaBridge | 143:86740a56073b | 32 | |
AnnaBridge | 143:86740a56073b | 33 | #include "fsl_common.h" |
AnnaBridge | 143:86740a56073b | 34 | |
AnnaBridge | 143:86740a56073b | 35 | /*! |
AnnaBridge | 143:86740a56073b | 36 | * @addtogroup uart_driver |
AnnaBridge | 143:86740a56073b | 37 | * @{ |
AnnaBridge | 143:86740a56073b | 38 | */ |
AnnaBridge | 143:86740a56073b | 39 | |
AnnaBridge | 143:86740a56073b | 40 | /******************************************************************************* |
AnnaBridge | 143:86740a56073b | 41 | * Definitions |
AnnaBridge | 143:86740a56073b | 42 | ******************************************************************************/ |
AnnaBridge | 143:86740a56073b | 43 | |
AnnaBridge | 143:86740a56073b | 44 | /*! @name Driver version */ |
AnnaBridge | 143:86740a56073b | 45 | /*@{*/ |
AnnaBridge | 143:86740a56073b | 46 | /*! @brief UART driver version 2.1.4. */ |
AnnaBridge | 143:86740a56073b | 47 | #define FSL_UART_DRIVER_VERSION (MAKE_VERSION(2, 1, 4)) |
AnnaBridge | 143:86740a56073b | 48 | /*@}*/ |
AnnaBridge | 143:86740a56073b | 49 | |
AnnaBridge | 143:86740a56073b | 50 | /*! @brief Error codes for the UART driver. */ |
AnnaBridge | 143:86740a56073b | 51 | enum _uart_status |
AnnaBridge | 143:86740a56073b | 52 | { |
AnnaBridge | 143:86740a56073b | 53 | kStatus_UART_TxBusy = MAKE_STATUS(kStatusGroup_UART, 0), /*!< Transmitter is busy. */ |
AnnaBridge | 143:86740a56073b | 54 | kStatus_UART_RxBusy = MAKE_STATUS(kStatusGroup_UART, 1), /*!< Receiver is busy. */ |
AnnaBridge | 143:86740a56073b | 55 | kStatus_UART_TxIdle = MAKE_STATUS(kStatusGroup_UART, 2), /*!< UART transmitter is idle. */ |
AnnaBridge | 143:86740a56073b | 56 | kStatus_UART_RxIdle = MAKE_STATUS(kStatusGroup_UART, 3), /*!< UART receiver is idle. */ |
AnnaBridge | 143:86740a56073b | 57 | kStatus_UART_TxWatermarkTooLarge = MAKE_STATUS(kStatusGroup_UART, 4), /*!< TX FIFO watermark too large */ |
AnnaBridge | 143:86740a56073b | 58 | kStatus_UART_RxWatermarkTooLarge = MAKE_STATUS(kStatusGroup_UART, 5), /*!< RX FIFO watermark too large */ |
AnnaBridge | 143:86740a56073b | 59 | kStatus_UART_FlagCannotClearManually = |
AnnaBridge | 143:86740a56073b | 60 | MAKE_STATUS(kStatusGroup_UART, 6), /*!< UART flag can't be manually cleared. */ |
AnnaBridge | 143:86740a56073b | 61 | kStatus_UART_Error = MAKE_STATUS(kStatusGroup_UART, 7), /*!< Error happens on UART. */ |
AnnaBridge | 143:86740a56073b | 62 | kStatus_UART_RxRingBufferOverrun = MAKE_STATUS(kStatusGroup_UART, 8), /*!< UART RX software ring buffer overrun. */ |
AnnaBridge | 143:86740a56073b | 63 | kStatus_UART_RxHardwareOverrun = MAKE_STATUS(kStatusGroup_UART, 9), /*!< UART RX receiver overrun. */ |
AnnaBridge | 143:86740a56073b | 64 | kStatus_UART_NoiseError = MAKE_STATUS(kStatusGroup_UART, 10), /*!< UART noise error. */ |
AnnaBridge | 143:86740a56073b | 65 | kStatus_UART_FramingError = MAKE_STATUS(kStatusGroup_UART, 11), /*!< UART framing error. */ |
AnnaBridge | 143:86740a56073b | 66 | kStatus_UART_ParityError = MAKE_STATUS(kStatusGroup_UART, 12), /*!< UART parity error. */ |
AnnaBridge | 143:86740a56073b | 67 | kStatus_UART_BaudrateNotSupport = |
AnnaBridge | 143:86740a56073b | 68 | MAKE_STATUS(kStatusGroup_UART, 13), /*!< Baudrate is not support in current clock source */ |
AnnaBridge | 143:86740a56073b | 69 | }; |
AnnaBridge | 143:86740a56073b | 70 | |
AnnaBridge | 143:86740a56073b | 71 | /*! @brief UART parity mode. */ |
AnnaBridge | 143:86740a56073b | 72 | typedef enum _uart_parity_mode |
AnnaBridge | 143:86740a56073b | 73 | { |
AnnaBridge | 143:86740a56073b | 74 | kUART_ParityDisabled = 0x0U, /*!< Parity disabled */ |
AnnaBridge | 143:86740a56073b | 75 | kUART_ParityEven = 0x2U, /*!< Parity enabled, type even, bit setting: PE|PT = 10 */ |
AnnaBridge | 143:86740a56073b | 76 | kUART_ParityOdd = 0x3U, /*!< Parity enabled, type odd, bit setting: PE|PT = 11 */ |
AnnaBridge | 143:86740a56073b | 77 | } uart_parity_mode_t; |
AnnaBridge | 143:86740a56073b | 78 | |
AnnaBridge | 143:86740a56073b | 79 | /*! @brief UART stop bit count. */ |
AnnaBridge | 143:86740a56073b | 80 | typedef enum _uart_stop_bit_count |
AnnaBridge | 143:86740a56073b | 81 | { |
AnnaBridge | 143:86740a56073b | 82 | kUART_OneStopBit = 0U, /*!< One stop bit */ |
AnnaBridge | 143:86740a56073b | 83 | kUART_TwoStopBit = 1U, /*!< Two stop bits */ |
AnnaBridge | 143:86740a56073b | 84 | } uart_stop_bit_count_t; |
AnnaBridge | 143:86740a56073b | 85 | |
AnnaBridge | 143:86740a56073b | 86 | /*! |
AnnaBridge | 143:86740a56073b | 87 | * @brief UART interrupt configuration structure, default settings all disabled. |
AnnaBridge | 143:86740a56073b | 88 | * |
AnnaBridge | 143:86740a56073b | 89 | * This structure contains the settings for all of the UART interrupt configurations. |
AnnaBridge | 143:86740a56073b | 90 | */ |
AnnaBridge | 143:86740a56073b | 91 | enum _uart_interrupt_enable |
AnnaBridge | 143:86740a56073b | 92 | { |
AnnaBridge | 143:86740a56073b | 93 | #if defined(FSL_FEATURE_UART_HAS_LIN_BREAK_DETECT) && FSL_FEATURE_UART_HAS_LIN_BREAK_DETECT |
AnnaBridge | 143:86740a56073b | 94 | kUART_LinBreakInterruptEnable = (UART_BDH_LBKDIE_MASK), /*!< LIN break detect interrupt. */ |
AnnaBridge | 143:86740a56073b | 95 | #endif |
AnnaBridge | 143:86740a56073b | 96 | kUART_RxActiveEdgeInterruptEnable = (UART_BDH_RXEDGIE_MASK), /*!< RX active edge interrupt. */ |
AnnaBridge | 143:86740a56073b | 97 | kUART_TxDataRegEmptyInterruptEnable = (UART_C2_TIE_MASK << 8), /*!< Transmit data register empty interrupt. */ |
AnnaBridge | 143:86740a56073b | 98 | kUART_TransmissionCompleteInterruptEnable = (UART_C2_TCIE_MASK << 8), /*!< Transmission complete interrupt. */ |
AnnaBridge | 143:86740a56073b | 99 | kUART_RxDataRegFullInterruptEnable = (UART_C2_RIE_MASK << 8), /*!< Receiver data register full interrupt. */ |
AnnaBridge | 143:86740a56073b | 100 | kUART_IdleLineInterruptEnable = (UART_C2_ILIE_MASK << 8), /*!< Idle line interrupt. */ |
AnnaBridge | 143:86740a56073b | 101 | kUART_RxOverrunInterruptEnable = (UART_C3_ORIE_MASK << 16), /*!< Receiver overrun interrupt. */ |
AnnaBridge | 143:86740a56073b | 102 | kUART_NoiseErrorInterruptEnable = (UART_C3_NEIE_MASK << 16), /*!< Noise error flag interrupt. */ |
AnnaBridge | 143:86740a56073b | 103 | kUART_FramingErrorInterruptEnable = (UART_C3_FEIE_MASK << 16), /*!< Framing error flag interrupt. */ |
AnnaBridge | 143:86740a56073b | 104 | kUART_ParityErrorInterruptEnable = (UART_C3_PEIE_MASK << 16), /*!< Parity error flag interrupt. */ |
AnnaBridge | 143:86740a56073b | 105 | #if defined(FSL_FEATURE_UART_HAS_FIFO) && FSL_FEATURE_UART_HAS_FIFO |
AnnaBridge | 143:86740a56073b | 106 | kUART_RxFifoOverflowInterruptEnable = (UART_CFIFO_RXOFE_MASK << 24), /*!< RX FIFO overflow interrupt. */ |
AnnaBridge | 143:86740a56073b | 107 | kUART_TxFifoOverflowInterruptEnable = (UART_CFIFO_TXOFE_MASK << 24), /*!< TX FIFO overflow interrupt. */ |
AnnaBridge | 143:86740a56073b | 108 | kUART_RxFifoUnderflowInterruptEnable = (UART_CFIFO_RXUFE_MASK << 24), /*!< RX FIFO underflow interrupt. */ |
AnnaBridge | 143:86740a56073b | 109 | #endif |
AnnaBridge | 143:86740a56073b | 110 | kUART_AllInterruptsEnable = |
AnnaBridge | 143:86740a56073b | 111 | #if defined(FSL_FEATURE_UART_HAS_LIN_BREAK_DETECT) && FSL_FEATURE_UART_HAS_LIN_BREAK_DETECT |
AnnaBridge | 143:86740a56073b | 112 | kUART_LinBreakInterruptEnable | |
AnnaBridge | 143:86740a56073b | 113 | #endif |
AnnaBridge | 143:86740a56073b | 114 | kUART_RxActiveEdgeInterruptEnable | kUART_TxDataRegEmptyInterruptEnable | |
AnnaBridge | 143:86740a56073b | 115 | kUART_TransmissionCompleteInterruptEnable | kUART_RxDataRegFullInterruptEnable | kUART_IdleLineInterruptEnable | |
AnnaBridge | 143:86740a56073b | 116 | kUART_RxOverrunInterruptEnable | kUART_NoiseErrorInterruptEnable | kUART_FramingErrorInterruptEnable | |
AnnaBridge | 143:86740a56073b | 117 | kUART_ParityErrorInterruptEnable |
AnnaBridge | 143:86740a56073b | 118 | #if defined(FSL_FEATURE_UART_HAS_FIFO) && FSL_FEATURE_UART_HAS_FIFO |
AnnaBridge | 143:86740a56073b | 119 | | |
AnnaBridge | 143:86740a56073b | 120 | kUART_RxFifoOverflowInterruptEnable | kUART_TxFifoOverflowInterruptEnable | kUART_RxFifoUnderflowInterruptEnable |
AnnaBridge | 143:86740a56073b | 121 | #endif |
AnnaBridge | 143:86740a56073b | 122 | , |
AnnaBridge | 143:86740a56073b | 123 | }; |
AnnaBridge | 143:86740a56073b | 124 | |
AnnaBridge | 143:86740a56073b | 125 | /*! |
AnnaBridge | 143:86740a56073b | 126 | * @brief UART status flags. |
AnnaBridge | 143:86740a56073b | 127 | * |
AnnaBridge | 143:86740a56073b | 128 | * This provides constants for the UART status flags for use in the UART functions. |
AnnaBridge | 143:86740a56073b | 129 | */ |
AnnaBridge | 143:86740a56073b | 130 | enum _uart_flags |
AnnaBridge | 143:86740a56073b | 131 | { |
AnnaBridge | 143:86740a56073b | 132 | kUART_TxDataRegEmptyFlag = (UART_S1_TDRE_MASK), /*!< TX data register empty flag. */ |
AnnaBridge | 143:86740a56073b | 133 | kUART_TransmissionCompleteFlag = (UART_S1_TC_MASK), /*!< Transmission complete flag. */ |
AnnaBridge | 143:86740a56073b | 134 | kUART_RxDataRegFullFlag = (UART_S1_RDRF_MASK), /*!< RX data register full flag. */ |
AnnaBridge | 143:86740a56073b | 135 | kUART_IdleLineFlag = (UART_S1_IDLE_MASK), /*!< Idle line detect flag. */ |
AnnaBridge | 143:86740a56073b | 136 | kUART_RxOverrunFlag = (UART_S1_OR_MASK), /*!< RX overrun flag. */ |
AnnaBridge | 143:86740a56073b | 137 | kUART_NoiseErrorFlag = (UART_S1_NF_MASK), /*!< RX takes 3 samples of each received bit. |
AnnaBridge | 143:86740a56073b | 138 | If any of these samples differ, noise flag sets */ |
AnnaBridge | 143:86740a56073b | 139 | kUART_FramingErrorFlag = (UART_S1_FE_MASK), /*!< Frame error flag, sets if logic 0 was detected |
AnnaBridge | 143:86740a56073b | 140 | where stop bit expected */ |
AnnaBridge | 143:86740a56073b | 141 | kUART_ParityErrorFlag = (UART_S1_PF_MASK), /*!< If parity enabled, sets upon parity error detection */ |
AnnaBridge | 143:86740a56073b | 142 | #if defined(FSL_FEATURE_UART_HAS_LIN_BREAK_DETECT) && FSL_FEATURE_UART_HAS_LIN_BREAK_DETECT |
AnnaBridge | 143:86740a56073b | 143 | kUART_LinBreakFlag = |
AnnaBridge | 143:86740a56073b | 144 | (UART_S2_LBKDIF_MASK |
AnnaBridge | 143:86740a56073b | 145 | << 8), /*!< LIN break detect interrupt flag, sets when |
AnnaBridge | 143:86740a56073b | 146 | LIN break char detected and LIN circuit enabled */ |
AnnaBridge | 143:86740a56073b | 147 | #endif |
AnnaBridge | 143:86740a56073b | 148 | kUART_RxActiveEdgeFlag = |
AnnaBridge | 143:86740a56073b | 149 | (UART_S2_RXEDGIF_MASK << 8), /*!< RX pin active edge interrupt flag, |
AnnaBridge | 143:86740a56073b | 150 | sets when active edge detected */ |
AnnaBridge | 143:86740a56073b | 151 | kUART_RxActiveFlag = |
AnnaBridge | 143:86740a56073b | 152 | (UART_S2_RAF_MASK << 8), /*!< Receiver Active Flag (RAF), |
AnnaBridge | 143:86740a56073b | 153 | sets at beginning of valid start bit */ |
AnnaBridge | 143:86740a56073b | 154 | #if defined(FSL_FEATURE_UART_HAS_EXTENDED_DATA_REGISTER_FLAGS) && FSL_FEATURE_UART_HAS_EXTENDED_DATA_REGISTER_FLAGS |
AnnaBridge | 143:86740a56073b | 155 | kUART_NoiseErrorInRxDataRegFlag = (UART_ED_NOISY_MASK << 16), /*!< Noisy bit, sets if noise detected. */ |
AnnaBridge | 143:86740a56073b | 156 | kUART_ParityErrorInRxDataRegFlag = (UART_ED_PARITYE_MASK << 16), /*!< Paritye bit, sets if parity error detected. */ |
AnnaBridge | 143:86740a56073b | 157 | #endif |
AnnaBridge | 143:86740a56073b | 158 | #if defined(FSL_FEATURE_UART_HAS_FIFO) && FSL_FEATURE_UART_HAS_FIFO |
AnnaBridge | 143:86740a56073b | 159 | kUART_TxFifoEmptyFlag = (UART_SFIFO_TXEMPT_MASK << 24), /*!< TXEMPT bit, sets if TX buffer is empty */ |
AnnaBridge | 143:86740a56073b | 160 | kUART_RxFifoEmptyFlag = (UART_SFIFO_RXEMPT_MASK << 24), /*!< RXEMPT bit, sets if RX buffer is empty */ |
AnnaBridge | 143:86740a56073b | 161 | kUART_TxFifoOverflowFlag = (UART_SFIFO_TXOF_MASK << 24), /*!< TXOF bit, sets if TX buffer overflow occurred */ |
AnnaBridge | 143:86740a56073b | 162 | kUART_RxFifoOverflowFlag = (UART_SFIFO_RXOF_MASK << 24), /*!< RXOF bit, sets if receive buffer overflow */ |
AnnaBridge | 143:86740a56073b | 163 | kUART_RxFifoUnderflowFlag = (UART_SFIFO_RXUF_MASK << 24), /*!< RXUF bit, sets if receive buffer underflow */ |
AnnaBridge | 143:86740a56073b | 164 | #endif |
AnnaBridge | 143:86740a56073b | 165 | }; |
AnnaBridge | 143:86740a56073b | 166 | |
AnnaBridge | 143:86740a56073b | 167 | /*! @brief UART configuration structure. */ |
AnnaBridge | 143:86740a56073b | 168 | typedef struct _uart_config |
AnnaBridge | 143:86740a56073b | 169 | { |
AnnaBridge | 143:86740a56073b | 170 | uint32_t baudRate_Bps; /*!< UART baud rate */ |
AnnaBridge | 143:86740a56073b | 171 | uart_parity_mode_t parityMode; /*!< Parity mode, disabled (default), even, odd */ |
AnnaBridge | 143:86740a56073b | 172 | #if defined(FSL_FEATURE_UART_HAS_STOP_BIT_CONFIG_SUPPORT) && FSL_FEATURE_UART_HAS_STOP_BIT_CONFIG_SUPPORT |
AnnaBridge | 143:86740a56073b | 173 | uart_stop_bit_count_t stopBitCount; /*!< Number of stop bits, 1 stop bit (default) or 2 stop bits */ |
AnnaBridge | 143:86740a56073b | 174 | #endif |
AnnaBridge | 143:86740a56073b | 175 | #if defined(FSL_FEATURE_UART_HAS_FIFO) && FSL_FEATURE_UART_HAS_FIFO |
AnnaBridge | 143:86740a56073b | 176 | uint8_t txFifoWatermark; /*!< TX FIFO watermark */ |
AnnaBridge | 143:86740a56073b | 177 | uint8_t rxFifoWatermark; /*!< RX FIFO watermark */ |
AnnaBridge | 143:86740a56073b | 178 | #endif |
AnnaBridge | 143:86740a56073b | 179 | bool enableTx; /*!< Enable TX */ |
AnnaBridge | 143:86740a56073b | 180 | bool enableRx; /*!< Enable RX */ |
AnnaBridge | 143:86740a56073b | 181 | } uart_config_t; |
AnnaBridge | 143:86740a56073b | 182 | |
AnnaBridge | 143:86740a56073b | 183 | /*! @brief UART transfer structure. */ |
AnnaBridge | 143:86740a56073b | 184 | typedef struct _uart_transfer |
AnnaBridge | 143:86740a56073b | 185 | { |
AnnaBridge | 143:86740a56073b | 186 | uint8_t *data; /*!< The buffer of data to be transfer.*/ |
AnnaBridge | 143:86740a56073b | 187 | size_t dataSize; /*!< The byte count to be transfer. */ |
AnnaBridge | 143:86740a56073b | 188 | } uart_transfer_t; |
AnnaBridge | 143:86740a56073b | 189 | |
AnnaBridge | 143:86740a56073b | 190 | /* Forward declaration of the handle typedef. */ |
AnnaBridge | 143:86740a56073b | 191 | typedef struct _uart_handle uart_handle_t; |
AnnaBridge | 143:86740a56073b | 192 | |
AnnaBridge | 143:86740a56073b | 193 | /*! @brief UART transfer callback function. */ |
AnnaBridge | 143:86740a56073b | 194 | typedef void (*uart_transfer_callback_t)(UART_Type *base, uart_handle_t *handle, status_t status, void *userData); |
AnnaBridge | 143:86740a56073b | 195 | |
AnnaBridge | 143:86740a56073b | 196 | /*! @brief UART handle structure. */ |
AnnaBridge | 143:86740a56073b | 197 | struct _uart_handle |
AnnaBridge | 143:86740a56073b | 198 | { |
AnnaBridge | 143:86740a56073b | 199 | uint8_t *volatile txData; /*!< Address of remaining data to send. */ |
AnnaBridge | 143:86740a56073b | 200 | volatile size_t txDataSize; /*!< Size of the remaining data to send. */ |
AnnaBridge | 143:86740a56073b | 201 | size_t txDataSizeAll; /*!< Size of the data to send out. */ |
AnnaBridge | 143:86740a56073b | 202 | uint8_t *volatile rxData; /*!< Address of remaining data to receive. */ |
AnnaBridge | 143:86740a56073b | 203 | volatile size_t rxDataSize; /*!< Size of the remaining data to receive. */ |
AnnaBridge | 143:86740a56073b | 204 | size_t rxDataSizeAll; /*!< Size of the data to receive. */ |
AnnaBridge | 143:86740a56073b | 205 | |
AnnaBridge | 143:86740a56073b | 206 | uint8_t *rxRingBuffer; /*!< Start address of the receiver ring buffer. */ |
AnnaBridge | 143:86740a56073b | 207 | size_t rxRingBufferSize; /*!< Size of the ring buffer. */ |
AnnaBridge | 143:86740a56073b | 208 | volatile uint16_t rxRingBufferHead; /*!< Index for the driver to store received data into ring buffer. */ |
AnnaBridge | 143:86740a56073b | 209 | volatile uint16_t rxRingBufferTail; /*!< Index for the user to get data from the ring buffer. */ |
AnnaBridge | 143:86740a56073b | 210 | |
AnnaBridge | 143:86740a56073b | 211 | uart_transfer_callback_t callback; /*!< Callback function. */ |
AnnaBridge | 143:86740a56073b | 212 | void *userData; /*!< UART callback function parameter.*/ |
AnnaBridge | 143:86740a56073b | 213 | |
AnnaBridge | 143:86740a56073b | 214 | volatile uint8_t txState; /*!< TX transfer state. */ |
AnnaBridge | 143:86740a56073b | 215 | volatile uint8_t rxState; /*!< RX transfer state */ |
AnnaBridge | 143:86740a56073b | 216 | }; |
AnnaBridge | 143:86740a56073b | 217 | |
AnnaBridge | 143:86740a56073b | 218 | /******************************************************************************* |
AnnaBridge | 143:86740a56073b | 219 | * API |
AnnaBridge | 143:86740a56073b | 220 | ******************************************************************************/ |
AnnaBridge | 143:86740a56073b | 221 | |
AnnaBridge | 143:86740a56073b | 222 | #if defined(__cplusplus) |
AnnaBridge | 143:86740a56073b | 223 | extern "C" { |
AnnaBridge | 143:86740a56073b | 224 | #endif /* _cplusplus */ |
AnnaBridge | 143:86740a56073b | 225 | |
AnnaBridge | 143:86740a56073b | 226 | /*! |
AnnaBridge | 143:86740a56073b | 227 | * @name Initialization and deinitialization |
AnnaBridge | 143:86740a56073b | 228 | * @{ |
AnnaBridge | 143:86740a56073b | 229 | */ |
AnnaBridge | 143:86740a56073b | 230 | |
AnnaBridge | 143:86740a56073b | 231 | /*! |
AnnaBridge | 143:86740a56073b | 232 | * @brief Initializes a UART instance with a user configuration structure and peripheral clock. |
AnnaBridge | 143:86740a56073b | 233 | * |
AnnaBridge | 143:86740a56073b | 234 | * This function configures the UART module with the user-defined settings. The user can configure the configuration |
AnnaBridge | 143:86740a56073b | 235 | * structure and also get the default configuration by using the UART_GetDefaultConfig() function. |
AnnaBridge | 143:86740a56073b | 236 | * The example below shows how to use this API to configure UART. |
AnnaBridge | 143:86740a56073b | 237 | * @code |
AnnaBridge | 143:86740a56073b | 238 | * uart_config_t uartConfig; |
AnnaBridge | 143:86740a56073b | 239 | * uartConfig.baudRate_Bps = 115200U; |
AnnaBridge | 143:86740a56073b | 240 | * uartConfig.parityMode = kUART_ParityDisabled; |
AnnaBridge | 143:86740a56073b | 241 | * uartConfig.stopBitCount = kUART_OneStopBit; |
AnnaBridge | 143:86740a56073b | 242 | * uartConfig.txFifoWatermark = 0; |
AnnaBridge | 143:86740a56073b | 243 | * uartConfig.rxFifoWatermark = 1; |
AnnaBridge | 143:86740a56073b | 244 | * UART_Init(UART1, &uartConfig, 20000000U); |
AnnaBridge | 143:86740a56073b | 245 | * @endcode |
AnnaBridge | 143:86740a56073b | 246 | * |
AnnaBridge | 143:86740a56073b | 247 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 248 | * @param config Pointer to the user-defined configuration structure. |
AnnaBridge | 143:86740a56073b | 249 | * @param srcClock_Hz UART clock source frequency in HZ. |
AnnaBridge | 143:86740a56073b | 250 | * @retval kStatus_UART_BaudrateNotSupport Baudrate is not support in current clock source. |
AnnaBridge | 143:86740a56073b | 251 | * @retval kStatus_Success Status UART initialize succeed |
AnnaBridge | 143:86740a56073b | 252 | */ |
AnnaBridge | 143:86740a56073b | 253 | status_t UART_Init(UART_Type *base, const uart_config_t *config, uint32_t srcClock_Hz); |
AnnaBridge | 143:86740a56073b | 254 | |
AnnaBridge | 143:86740a56073b | 255 | /*! |
AnnaBridge | 143:86740a56073b | 256 | * @brief Deinitializes a UART instance. |
AnnaBridge | 143:86740a56073b | 257 | * |
AnnaBridge | 143:86740a56073b | 258 | * This function waits for TX complete, disables TX and RX, and disables the UART clock. |
AnnaBridge | 143:86740a56073b | 259 | * |
AnnaBridge | 143:86740a56073b | 260 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 261 | */ |
AnnaBridge | 143:86740a56073b | 262 | void UART_Deinit(UART_Type *base); |
AnnaBridge | 143:86740a56073b | 263 | |
AnnaBridge | 143:86740a56073b | 264 | /*! |
AnnaBridge | 143:86740a56073b | 265 | * @brief Gets the default configuration structure. |
AnnaBridge | 143:86740a56073b | 266 | * |
AnnaBridge | 143:86740a56073b | 267 | * This function initializes the UART configuration structure to a default value. The default |
AnnaBridge | 143:86740a56073b | 268 | * values are as follows. |
AnnaBridge | 143:86740a56073b | 269 | * uartConfig->baudRate_Bps = 115200U; |
AnnaBridge | 143:86740a56073b | 270 | * uartConfig->bitCountPerChar = kUART_8BitsPerChar; |
AnnaBridge | 143:86740a56073b | 271 | * uartConfig->parityMode = kUART_ParityDisabled; |
AnnaBridge | 143:86740a56073b | 272 | * uartConfig->stopBitCount = kUART_OneStopBit; |
AnnaBridge | 143:86740a56073b | 273 | * uartConfig->txFifoWatermark = 0; |
AnnaBridge | 143:86740a56073b | 274 | * uartConfig->rxFifoWatermark = 1; |
AnnaBridge | 143:86740a56073b | 275 | * uartConfig->enableTx = false; |
AnnaBridge | 143:86740a56073b | 276 | * uartConfig->enableRx = false; |
AnnaBridge | 143:86740a56073b | 277 | * |
AnnaBridge | 143:86740a56073b | 278 | * @param config Pointer to configuration structure. |
AnnaBridge | 143:86740a56073b | 279 | */ |
AnnaBridge | 143:86740a56073b | 280 | void UART_GetDefaultConfig(uart_config_t *config); |
AnnaBridge | 143:86740a56073b | 281 | |
AnnaBridge | 143:86740a56073b | 282 | /*! |
AnnaBridge | 143:86740a56073b | 283 | * @brief Sets the UART instance baud rate. |
AnnaBridge | 143:86740a56073b | 284 | * |
AnnaBridge | 143:86740a56073b | 285 | * This function configures the UART module baud rate. This function is used to update |
AnnaBridge | 143:86740a56073b | 286 | * the UART module baud rate after the UART module is initialized by the UART_Init. |
AnnaBridge | 143:86740a56073b | 287 | * @code |
AnnaBridge | 143:86740a56073b | 288 | * UART_SetBaudRate(UART1, 115200U, 20000000U); |
AnnaBridge | 143:86740a56073b | 289 | * @endcode |
AnnaBridge | 143:86740a56073b | 290 | * |
AnnaBridge | 143:86740a56073b | 291 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 292 | * @param baudRate_Bps UART baudrate to be set. |
AnnaBridge | 143:86740a56073b | 293 | * @param srcClock_Hz UART clock source freqency in Hz. |
AnnaBridge | 143:86740a56073b | 294 | * @retval kStatus_UART_BaudrateNotSupport Baudrate is not support in the current clock source. |
AnnaBridge | 143:86740a56073b | 295 | * @retval kStatus_Success Set baudrate succeeded. |
AnnaBridge | 143:86740a56073b | 296 | */ |
AnnaBridge | 143:86740a56073b | 297 | status_t UART_SetBaudRate(UART_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz); |
AnnaBridge | 143:86740a56073b | 298 | |
AnnaBridge | 143:86740a56073b | 299 | /* @} */ |
AnnaBridge | 143:86740a56073b | 300 | |
AnnaBridge | 143:86740a56073b | 301 | /*! |
AnnaBridge | 143:86740a56073b | 302 | * @name Status |
AnnaBridge | 143:86740a56073b | 303 | * @{ |
AnnaBridge | 143:86740a56073b | 304 | */ |
AnnaBridge | 143:86740a56073b | 305 | |
AnnaBridge | 143:86740a56073b | 306 | /*! |
AnnaBridge | 143:86740a56073b | 307 | * @brief Gets UART status flags. |
AnnaBridge | 143:86740a56073b | 308 | * |
AnnaBridge | 143:86740a56073b | 309 | * This function gets all UART status flags. The flags are returned as the logical |
AnnaBridge | 143:86740a56073b | 310 | * OR value of the enumerators @ref _uart_flags. To check a specific status, |
AnnaBridge | 143:86740a56073b | 311 | * compare the return value with enumerators in @ref _uart_flags. |
AnnaBridge | 143:86740a56073b | 312 | * For example, to check whether the TX is empty, do the following. |
AnnaBridge | 143:86740a56073b | 313 | * @code |
AnnaBridge | 143:86740a56073b | 314 | * if (kUART_TxDataRegEmptyFlag & UART_GetStatusFlags(UART1)) |
AnnaBridge | 143:86740a56073b | 315 | * { |
AnnaBridge | 143:86740a56073b | 316 | * ... |
AnnaBridge | 143:86740a56073b | 317 | * } |
AnnaBridge | 143:86740a56073b | 318 | * @endcode |
AnnaBridge | 143:86740a56073b | 319 | * |
AnnaBridge | 143:86740a56073b | 320 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 321 | * @return UART status flags which are ORed by the enumerators in the _uart_flags. |
AnnaBridge | 143:86740a56073b | 322 | */ |
AnnaBridge | 143:86740a56073b | 323 | uint32_t UART_GetStatusFlags(UART_Type *base); |
AnnaBridge | 143:86740a56073b | 324 | |
AnnaBridge | 143:86740a56073b | 325 | /*! |
AnnaBridge | 143:86740a56073b | 326 | * @brief Clears status flags with the provided mask. |
AnnaBridge | 143:86740a56073b | 327 | * |
AnnaBridge | 143:86740a56073b | 328 | * This function clears UART status flags with a provided mask. An automatically cleared flag |
AnnaBridge | 143:86740a56073b | 329 | * can't be cleared by this function. |
AnnaBridge | 143:86740a56073b | 330 | * These flags can only be cleared or set by hardware. |
AnnaBridge | 143:86740a56073b | 331 | * kUART_TxDataRegEmptyFlag, kUART_TransmissionCompleteFlag, kUART_RxDataRegFullFlag, |
AnnaBridge | 143:86740a56073b | 332 | * kUART_RxActiveFlag, kUART_NoiseErrorInRxDataRegFlag, kUART_ParityErrorInRxDataRegFlag, |
AnnaBridge | 143:86740a56073b | 333 | * kUART_TxFifoEmptyFlag,kUART_RxFifoEmptyFlag |
AnnaBridge | 143:86740a56073b | 334 | * Note that this API should be called when the Tx/Rx is idle. Otherwise it has no effect. |
AnnaBridge | 143:86740a56073b | 335 | * |
AnnaBridge | 143:86740a56073b | 336 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 337 | * @param mask The status flags to be cleared; it is logical OR value of @ref _uart_flags. |
AnnaBridge | 143:86740a56073b | 338 | * @retval kStatus_UART_FlagCannotClearManually The flag can't be cleared by this function but |
AnnaBridge | 143:86740a56073b | 339 | * it is cleared automatically by hardware. |
AnnaBridge | 143:86740a56073b | 340 | * @retval kStatus_Success Status in the mask is cleared. |
AnnaBridge | 143:86740a56073b | 341 | */ |
AnnaBridge | 143:86740a56073b | 342 | status_t UART_ClearStatusFlags(UART_Type *base, uint32_t mask); |
AnnaBridge | 143:86740a56073b | 343 | |
AnnaBridge | 143:86740a56073b | 344 | /* @} */ |
AnnaBridge | 143:86740a56073b | 345 | |
AnnaBridge | 143:86740a56073b | 346 | /*! |
AnnaBridge | 143:86740a56073b | 347 | * @name Interrupts |
AnnaBridge | 143:86740a56073b | 348 | * @{ |
AnnaBridge | 143:86740a56073b | 349 | */ |
AnnaBridge | 143:86740a56073b | 350 | |
AnnaBridge | 143:86740a56073b | 351 | /*! |
AnnaBridge | 143:86740a56073b | 352 | * @brief Enables UART interrupts according to the provided mask. |
AnnaBridge | 143:86740a56073b | 353 | * |
AnnaBridge | 143:86740a56073b | 354 | * This function enables the UART interrupts according to the provided mask. The mask |
AnnaBridge | 143:86740a56073b | 355 | * is a logical OR of enumeration members. See @ref _uart_interrupt_enable. |
AnnaBridge | 143:86740a56073b | 356 | * For example, to enable TX empty interrupt and RX full interrupt, do the following. |
AnnaBridge | 143:86740a56073b | 357 | * @code |
AnnaBridge | 143:86740a56073b | 358 | * UART_EnableInterrupts(UART1,kUART_TxDataRegEmptyInterruptEnable | kUART_RxDataRegFullInterruptEnable); |
AnnaBridge | 143:86740a56073b | 359 | * @endcode |
AnnaBridge | 143:86740a56073b | 360 | * |
AnnaBridge | 143:86740a56073b | 361 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 362 | * @param mask The interrupts to enable. Logical OR of @ref _uart_interrupt_enable. |
AnnaBridge | 143:86740a56073b | 363 | */ |
AnnaBridge | 143:86740a56073b | 364 | void UART_EnableInterrupts(UART_Type *base, uint32_t mask); |
AnnaBridge | 143:86740a56073b | 365 | |
AnnaBridge | 143:86740a56073b | 366 | /*! |
AnnaBridge | 143:86740a56073b | 367 | * @brief Disables the UART interrupts according to the provided mask. |
AnnaBridge | 143:86740a56073b | 368 | * |
AnnaBridge | 143:86740a56073b | 369 | * This function disables the UART interrupts according to the provided mask. The mask |
AnnaBridge | 143:86740a56073b | 370 | * is a logical OR of enumeration members. See @ref _uart_interrupt_enable. |
AnnaBridge | 143:86740a56073b | 371 | * For example, to disable TX empty interrupt and RX full interrupt do the following. |
AnnaBridge | 143:86740a56073b | 372 | * @code |
AnnaBridge | 143:86740a56073b | 373 | * UART_DisableInterrupts(UART1,kUART_TxDataRegEmptyInterruptEnable | kUART_RxDataRegFullInterruptEnable); |
AnnaBridge | 143:86740a56073b | 374 | * @endcode |
AnnaBridge | 143:86740a56073b | 375 | * |
AnnaBridge | 143:86740a56073b | 376 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 377 | * @param mask The interrupts to disable. Logical OR of @ref _uart_interrupt_enable. |
AnnaBridge | 143:86740a56073b | 378 | */ |
AnnaBridge | 143:86740a56073b | 379 | void UART_DisableInterrupts(UART_Type *base, uint32_t mask); |
AnnaBridge | 143:86740a56073b | 380 | |
AnnaBridge | 143:86740a56073b | 381 | /*! |
AnnaBridge | 143:86740a56073b | 382 | * @brief Gets the enabled UART interrupts. |
AnnaBridge | 143:86740a56073b | 383 | * |
AnnaBridge | 143:86740a56073b | 384 | * This function gets the enabled UART interrupts. The enabled interrupts are returned |
AnnaBridge | 143:86740a56073b | 385 | * as the logical OR value of the enumerators @ref _uart_interrupt_enable. To check |
AnnaBridge | 143:86740a56073b | 386 | * a specific interrupts enable status, compare the return value with enumerators |
AnnaBridge | 143:86740a56073b | 387 | * in @ref _uart_interrupt_enable. |
AnnaBridge | 143:86740a56073b | 388 | * For example, to check whether TX empty interrupt is enabled, do the following. |
AnnaBridge | 143:86740a56073b | 389 | * @code |
AnnaBridge | 143:86740a56073b | 390 | * uint32_t enabledInterrupts = UART_GetEnabledInterrupts(UART1); |
AnnaBridge | 143:86740a56073b | 391 | * |
AnnaBridge | 143:86740a56073b | 392 | * if (kUART_TxDataRegEmptyInterruptEnable & enabledInterrupts) |
AnnaBridge | 143:86740a56073b | 393 | * { |
AnnaBridge | 143:86740a56073b | 394 | * ... |
AnnaBridge | 143:86740a56073b | 395 | * } |
AnnaBridge | 143:86740a56073b | 396 | * @endcode |
AnnaBridge | 143:86740a56073b | 397 | * |
AnnaBridge | 143:86740a56073b | 398 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 399 | * @return UART interrupt flags which are logical OR of the enumerators in @ref _uart_interrupt_enable. |
AnnaBridge | 143:86740a56073b | 400 | */ |
AnnaBridge | 143:86740a56073b | 401 | uint32_t UART_GetEnabledInterrupts(UART_Type *base); |
AnnaBridge | 143:86740a56073b | 402 | |
AnnaBridge | 143:86740a56073b | 403 | /* @} */ |
AnnaBridge | 143:86740a56073b | 404 | |
AnnaBridge | 143:86740a56073b | 405 | #if defined(FSL_FEATURE_UART_HAS_DMA_SELECT) && FSL_FEATURE_UART_HAS_DMA_SELECT |
AnnaBridge | 143:86740a56073b | 406 | /*! |
AnnaBridge | 143:86740a56073b | 407 | * @name DMA Control |
AnnaBridge | 143:86740a56073b | 408 | * @{ |
AnnaBridge | 143:86740a56073b | 409 | */ |
AnnaBridge | 143:86740a56073b | 410 | |
AnnaBridge | 143:86740a56073b | 411 | /*! |
AnnaBridge | 143:86740a56073b | 412 | * @brief Gets the UART data register address. |
AnnaBridge | 143:86740a56073b | 413 | * |
AnnaBridge | 143:86740a56073b | 414 | * This function returns the UART data register address, which is mainly used by DMA/eDMA. |
AnnaBridge | 143:86740a56073b | 415 | * |
AnnaBridge | 143:86740a56073b | 416 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 417 | * @return UART data register addresses which are used both by the transmitter and the receiver. |
AnnaBridge | 143:86740a56073b | 418 | */ |
AnnaBridge | 143:86740a56073b | 419 | static inline uint32_t UART_GetDataRegisterAddress(UART_Type *base) |
AnnaBridge | 143:86740a56073b | 420 | { |
AnnaBridge | 143:86740a56073b | 421 | return (uint32_t) & (base->D); |
AnnaBridge | 143:86740a56073b | 422 | } |
AnnaBridge | 143:86740a56073b | 423 | |
AnnaBridge | 143:86740a56073b | 424 | /*! |
AnnaBridge | 143:86740a56073b | 425 | * @brief Enables or disables the UART transmitter DMA request. |
AnnaBridge | 143:86740a56073b | 426 | * |
AnnaBridge | 143:86740a56073b | 427 | * This function enables or disables the transmit data register empty flag, S1[TDRE], to generate the DMA requests. |
AnnaBridge | 143:86740a56073b | 428 | * |
AnnaBridge | 143:86740a56073b | 429 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 430 | * @param enable True to enable, false to disable. |
AnnaBridge | 143:86740a56073b | 431 | */ |
AnnaBridge | 143:86740a56073b | 432 | static inline void UART_EnableTxDMA(UART_Type *base, bool enable) |
AnnaBridge | 143:86740a56073b | 433 | { |
AnnaBridge | 143:86740a56073b | 434 | if (enable) |
AnnaBridge | 143:86740a56073b | 435 | { |
AnnaBridge | 143:86740a56073b | 436 | #if (defined(FSL_FEATURE_UART_IS_SCI) && FSL_FEATURE_UART_IS_SCI) |
AnnaBridge | 143:86740a56073b | 437 | base->C4 |= UART_C4_TDMAS_MASK; |
AnnaBridge | 143:86740a56073b | 438 | #else |
AnnaBridge | 143:86740a56073b | 439 | base->C5 |= UART_C5_TDMAS_MASK; |
AnnaBridge | 143:86740a56073b | 440 | #endif |
AnnaBridge | 143:86740a56073b | 441 | base->C2 |= UART_C2_TIE_MASK; |
AnnaBridge | 143:86740a56073b | 442 | } |
AnnaBridge | 143:86740a56073b | 443 | else |
AnnaBridge | 143:86740a56073b | 444 | { |
AnnaBridge | 143:86740a56073b | 445 | #if (defined(FSL_FEATURE_UART_IS_SCI) && FSL_FEATURE_UART_IS_SCI) |
AnnaBridge | 143:86740a56073b | 446 | base->C4 &= ~UART_C4_TDMAS_MASK; |
AnnaBridge | 143:86740a56073b | 447 | #else |
AnnaBridge | 143:86740a56073b | 448 | base->C5 &= ~UART_C5_TDMAS_MASK; |
AnnaBridge | 143:86740a56073b | 449 | #endif |
AnnaBridge | 143:86740a56073b | 450 | base->C2 &= ~UART_C2_TIE_MASK; |
AnnaBridge | 143:86740a56073b | 451 | } |
AnnaBridge | 143:86740a56073b | 452 | } |
AnnaBridge | 143:86740a56073b | 453 | |
AnnaBridge | 143:86740a56073b | 454 | /*! |
AnnaBridge | 143:86740a56073b | 455 | * @brief Enables or disables the UART receiver DMA. |
AnnaBridge | 143:86740a56073b | 456 | * |
AnnaBridge | 143:86740a56073b | 457 | * This function enables or disables the receiver data register full flag, S1[RDRF], to generate DMA requests. |
AnnaBridge | 143:86740a56073b | 458 | * |
AnnaBridge | 143:86740a56073b | 459 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 460 | * @param enable True to enable, false to disable. |
AnnaBridge | 143:86740a56073b | 461 | */ |
AnnaBridge | 143:86740a56073b | 462 | static inline void UART_EnableRxDMA(UART_Type *base, bool enable) |
AnnaBridge | 143:86740a56073b | 463 | { |
AnnaBridge | 143:86740a56073b | 464 | if (enable) |
AnnaBridge | 143:86740a56073b | 465 | { |
AnnaBridge | 143:86740a56073b | 466 | #if (defined(FSL_FEATURE_UART_IS_SCI) && FSL_FEATURE_UART_IS_SCI) |
AnnaBridge | 143:86740a56073b | 467 | base->C4 |= UART_C4_RDMAS_MASK; |
AnnaBridge | 143:86740a56073b | 468 | #else |
AnnaBridge | 143:86740a56073b | 469 | base->C5 |= UART_C5_RDMAS_MASK; |
AnnaBridge | 143:86740a56073b | 470 | #endif |
AnnaBridge | 143:86740a56073b | 471 | base->C2 |= UART_C2_RIE_MASK; |
AnnaBridge | 143:86740a56073b | 472 | } |
AnnaBridge | 143:86740a56073b | 473 | else |
AnnaBridge | 143:86740a56073b | 474 | { |
AnnaBridge | 143:86740a56073b | 475 | #if (defined(FSL_FEATURE_UART_IS_SCI) && FSL_FEATURE_UART_IS_SCI) |
AnnaBridge | 143:86740a56073b | 476 | base->C4 &= ~UART_C4_RDMAS_MASK; |
AnnaBridge | 143:86740a56073b | 477 | #else |
AnnaBridge | 143:86740a56073b | 478 | base->C5 &= ~UART_C5_RDMAS_MASK; |
AnnaBridge | 143:86740a56073b | 479 | #endif |
AnnaBridge | 143:86740a56073b | 480 | base->C2 &= ~UART_C2_RIE_MASK; |
AnnaBridge | 143:86740a56073b | 481 | } |
AnnaBridge | 143:86740a56073b | 482 | } |
AnnaBridge | 143:86740a56073b | 483 | |
AnnaBridge | 143:86740a56073b | 484 | /* @} */ |
AnnaBridge | 143:86740a56073b | 485 | #endif /* FSL_FEATURE_UART_HAS_DMA_SELECT */ |
AnnaBridge | 143:86740a56073b | 486 | |
AnnaBridge | 143:86740a56073b | 487 | /*! |
AnnaBridge | 143:86740a56073b | 488 | * @name Bus Operations |
AnnaBridge | 143:86740a56073b | 489 | * @{ |
AnnaBridge | 143:86740a56073b | 490 | */ |
AnnaBridge | 143:86740a56073b | 491 | |
AnnaBridge | 143:86740a56073b | 492 | /*! |
AnnaBridge | 143:86740a56073b | 493 | * @brief Enables or disables the UART transmitter. |
AnnaBridge | 143:86740a56073b | 494 | * |
AnnaBridge | 143:86740a56073b | 495 | * This function enables or disables the UART transmitter. |
AnnaBridge | 143:86740a56073b | 496 | * |
AnnaBridge | 143:86740a56073b | 497 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 498 | * @param enable True to enable, false to disable. |
AnnaBridge | 143:86740a56073b | 499 | */ |
AnnaBridge | 143:86740a56073b | 500 | static inline void UART_EnableTx(UART_Type *base, bool enable) |
AnnaBridge | 143:86740a56073b | 501 | { |
AnnaBridge | 143:86740a56073b | 502 | if (enable) |
AnnaBridge | 143:86740a56073b | 503 | { |
AnnaBridge | 143:86740a56073b | 504 | base->C2 |= UART_C2_TE_MASK; |
AnnaBridge | 143:86740a56073b | 505 | } |
AnnaBridge | 143:86740a56073b | 506 | else |
AnnaBridge | 143:86740a56073b | 507 | { |
AnnaBridge | 143:86740a56073b | 508 | base->C2 &= ~UART_C2_TE_MASK; |
AnnaBridge | 143:86740a56073b | 509 | } |
AnnaBridge | 143:86740a56073b | 510 | } |
AnnaBridge | 143:86740a56073b | 511 | |
AnnaBridge | 143:86740a56073b | 512 | /*! |
AnnaBridge | 143:86740a56073b | 513 | * @brief Enables or disables the UART receiver. |
AnnaBridge | 143:86740a56073b | 514 | * |
AnnaBridge | 143:86740a56073b | 515 | * This function enables or disables the UART receiver. |
AnnaBridge | 143:86740a56073b | 516 | * |
AnnaBridge | 143:86740a56073b | 517 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 518 | * @param enable True to enable, false to disable. |
AnnaBridge | 143:86740a56073b | 519 | */ |
AnnaBridge | 143:86740a56073b | 520 | static inline void UART_EnableRx(UART_Type *base, bool enable) |
AnnaBridge | 143:86740a56073b | 521 | { |
AnnaBridge | 143:86740a56073b | 522 | if (enable) |
AnnaBridge | 143:86740a56073b | 523 | { |
AnnaBridge | 143:86740a56073b | 524 | base->C2 |= UART_C2_RE_MASK; |
AnnaBridge | 143:86740a56073b | 525 | } |
AnnaBridge | 143:86740a56073b | 526 | else |
AnnaBridge | 143:86740a56073b | 527 | { |
AnnaBridge | 143:86740a56073b | 528 | base->C2 &= ~UART_C2_RE_MASK; |
AnnaBridge | 143:86740a56073b | 529 | } |
AnnaBridge | 143:86740a56073b | 530 | } |
AnnaBridge | 143:86740a56073b | 531 | |
AnnaBridge | 143:86740a56073b | 532 | /*! |
AnnaBridge | 143:86740a56073b | 533 | * @brief Writes to the TX register. |
AnnaBridge | 143:86740a56073b | 534 | * |
AnnaBridge | 143:86740a56073b | 535 | * This function writes data to the TX register directly. The upper layer must ensure |
AnnaBridge | 143:86740a56073b | 536 | * that the TX register is empty or TX FIFO has empty room before calling this function. |
AnnaBridge | 143:86740a56073b | 537 | * |
AnnaBridge | 143:86740a56073b | 538 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 539 | * @param data The byte to write. |
AnnaBridge | 143:86740a56073b | 540 | */ |
AnnaBridge | 143:86740a56073b | 541 | static inline void UART_WriteByte(UART_Type *base, uint8_t data) |
AnnaBridge | 143:86740a56073b | 542 | { |
AnnaBridge | 143:86740a56073b | 543 | base->D = data; |
AnnaBridge | 143:86740a56073b | 544 | } |
AnnaBridge | 143:86740a56073b | 545 | |
AnnaBridge | 143:86740a56073b | 546 | /*! |
AnnaBridge | 143:86740a56073b | 547 | * @brief Reads the RX register directly. |
AnnaBridge | 143:86740a56073b | 548 | * |
AnnaBridge | 143:86740a56073b | 549 | * This function reads data from the RX register directly. The upper layer must |
AnnaBridge | 143:86740a56073b | 550 | * ensure that the RX register is full or that the TX FIFO has data before calling this function. |
AnnaBridge | 143:86740a56073b | 551 | * |
AnnaBridge | 143:86740a56073b | 552 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 553 | * @return The byte read from UART data register. |
AnnaBridge | 143:86740a56073b | 554 | */ |
AnnaBridge | 143:86740a56073b | 555 | static inline uint8_t UART_ReadByte(UART_Type *base) |
AnnaBridge | 143:86740a56073b | 556 | { |
AnnaBridge | 143:86740a56073b | 557 | return base->D; |
AnnaBridge | 143:86740a56073b | 558 | } |
AnnaBridge | 143:86740a56073b | 559 | |
AnnaBridge | 143:86740a56073b | 560 | /*! |
AnnaBridge | 143:86740a56073b | 561 | * @brief Writes to the TX register using a blocking method. |
AnnaBridge | 143:86740a56073b | 562 | * |
AnnaBridge | 143:86740a56073b | 563 | * This function polls the TX register, waits for the TX register to be empty or for the TX FIFO |
AnnaBridge | 143:86740a56073b | 564 | * to have room and writes data to the TX buffer. |
AnnaBridge | 143:86740a56073b | 565 | * |
AnnaBridge | 143:86740a56073b | 566 | * @note This function does not check whether all data is sent out to the bus. |
AnnaBridge | 143:86740a56073b | 567 | * Before disabling the TX, check kUART_TransmissionCompleteFlag to ensure that the TX is |
AnnaBridge | 143:86740a56073b | 568 | * finished. |
AnnaBridge | 143:86740a56073b | 569 | * |
AnnaBridge | 143:86740a56073b | 570 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 571 | * @param data Start address of the data to write. |
AnnaBridge | 143:86740a56073b | 572 | * @param length Size of the data to write. |
AnnaBridge | 143:86740a56073b | 573 | */ |
AnnaBridge | 143:86740a56073b | 574 | void UART_WriteBlocking(UART_Type *base, const uint8_t *data, size_t length); |
AnnaBridge | 143:86740a56073b | 575 | |
AnnaBridge | 143:86740a56073b | 576 | /*! |
AnnaBridge | 143:86740a56073b | 577 | * @brief Read RX data register using a blocking method. |
AnnaBridge | 143:86740a56073b | 578 | * |
AnnaBridge | 143:86740a56073b | 579 | * This function polls the RX register, waits for the RX register to be full or for RX FIFO to |
AnnaBridge | 143:86740a56073b | 580 | * have data, and reads data from the TX register. |
AnnaBridge | 143:86740a56073b | 581 | * |
AnnaBridge | 143:86740a56073b | 582 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 583 | * @param data Start address of the buffer to store the received data. |
AnnaBridge | 143:86740a56073b | 584 | * @param length Size of the buffer. |
AnnaBridge | 143:86740a56073b | 585 | * @retval kStatus_UART_RxHardwareOverrun Receiver overrun occurred while receiving data. |
AnnaBridge | 143:86740a56073b | 586 | * @retval kStatus_UART_NoiseError A noise error occurred while receiving data. |
AnnaBridge | 143:86740a56073b | 587 | * @retval kStatus_UART_FramingError A framing error occurred while receiving data. |
AnnaBridge | 143:86740a56073b | 588 | * @retval kStatus_UART_ParityError A parity error occurred while receiving data. |
AnnaBridge | 143:86740a56073b | 589 | * @retval kStatus_Success Successfully received all data. |
AnnaBridge | 143:86740a56073b | 590 | */ |
AnnaBridge | 143:86740a56073b | 591 | status_t UART_ReadBlocking(UART_Type *base, uint8_t *data, size_t length); |
AnnaBridge | 143:86740a56073b | 592 | |
AnnaBridge | 143:86740a56073b | 593 | /* @} */ |
AnnaBridge | 143:86740a56073b | 594 | |
AnnaBridge | 143:86740a56073b | 595 | /*! |
AnnaBridge | 143:86740a56073b | 596 | * @name Transactional |
AnnaBridge | 143:86740a56073b | 597 | * @{ |
AnnaBridge | 143:86740a56073b | 598 | */ |
AnnaBridge | 143:86740a56073b | 599 | |
AnnaBridge | 143:86740a56073b | 600 | /*! |
AnnaBridge | 143:86740a56073b | 601 | * @brief Initializes the UART handle. |
AnnaBridge | 143:86740a56073b | 602 | * |
AnnaBridge | 143:86740a56073b | 603 | * This function initializes the UART handle which can be used for other UART |
AnnaBridge | 143:86740a56073b | 604 | * transactional APIs. Usually, for a specified UART instance, |
AnnaBridge | 143:86740a56073b | 605 | * call this API once to get the initialized handle. |
AnnaBridge | 143:86740a56073b | 606 | * |
AnnaBridge | 143:86740a56073b | 607 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 608 | * @param handle UART handle pointer. |
AnnaBridge | 143:86740a56073b | 609 | * @param callback The callback function. |
AnnaBridge | 143:86740a56073b | 610 | * @param userData The parameter of the callback function. |
AnnaBridge | 143:86740a56073b | 611 | */ |
AnnaBridge | 143:86740a56073b | 612 | void UART_TransferCreateHandle(UART_Type *base, |
AnnaBridge | 143:86740a56073b | 613 | uart_handle_t *handle, |
AnnaBridge | 143:86740a56073b | 614 | uart_transfer_callback_t callback, |
AnnaBridge | 143:86740a56073b | 615 | void *userData); |
AnnaBridge | 143:86740a56073b | 616 | |
AnnaBridge | 143:86740a56073b | 617 | /*! |
AnnaBridge | 143:86740a56073b | 618 | * @brief Sets up the RX ring buffer. |
AnnaBridge | 143:86740a56073b | 619 | * |
AnnaBridge | 143:86740a56073b | 620 | * This function sets up the RX ring buffer to a specific UART handle. |
AnnaBridge | 143:86740a56073b | 621 | * |
AnnaBridge | 143:86740a56073b | 622 | * When the RX ring buffer is used, data received are stored into the ring buffer even when the |
AnnaBridge | 143:86740a56073b | 623 | * user doesn't call the UART_TransferReceiveNonBlocking() API. If data is already received |
AnnaBridge | 143:86740a56073b | 624 | * in the ring buffer, the user can get the received data from the ring buffer directly. |
AnnaBridge | 143:86740a56073b | 625 | * |
AnnaBridge | 143:86740a56073b | 626 | * @note When using the RX ring buffer, one byte is reserved for internal use. In other |
AnnaBridge | 143:86740a56073b | 627 | * words, if @p ringBufferSize is 32, only 31 bytes are used for saving data. |
AnnaBridge | 143:86740a56073b | 628 | * |
AnnaBridge | 143:86740a56073b | 629 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 630 | * @param handle UART handle pointer. |
AnnaBridge | 143:86740a56073b | 631 | * @param ringBuffer Start address of the ring buffer for background receiving. Pass NULL to disable the ring buffer. |
AnnaBridge | 143:86740a56073b | 632 | * @param ringBufferSize Size of the ring buffer. |
AnnaBridge | 143:86740a56073b | 633 | */ |
AnnaBridge | 143:86740a56073b | 634 | void UART_TransferStartRingBuffer(UART_Type *base, uart_handle_t *handle, uint8_t *ringBuffer, size_t ringBufferSize); |
AnnaBridge | 143:86740a56073b | 635 | |
AnnaBridge | 143:86740a56073b | 636 | /*! |
AnnaBridge | 143:86740a56073b | 637 | * @brief Aborts the background transfer and uninstalls the ring buffer. |
AnnaBridge | 143:86740a56073b | 638 | * |
AnnaBridge | 143:86740a56073b | 639 | * This function aborts the background transfer and uninstalls the ring buffer. |
AnnaBridge | 143:86740a56073b | 640 | * |
AnnaBridge | 143:86740a56073b | 641 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 642 | * @param handle UART handle pointer. |
AnnaBridge | 143:86740a56073b | 643 | */ |
AnnaBridge | 143:86740a56073b | 644 | void UART_TransferStopRingBuffer(UART_Type *base, uart_handle_t *handle); |
AnnaBridge | 143:86740a56073b | 645 | |
AnnaBridge | 143:86740a56073b | 646 | /*! |
AnnaBridge | 143:86740a56073b | 647 | * @brief Transmits a buffer of data using the interrupt method. |
AnnaBridge | 143:86740a56073b | 648 | * |
AnnaBridge | 143:86740a56073b | 649 | * This function sends data using an interrupt method. This is a non-blocking function, which |
AnnaBridge | 143:86740a56073b | 650 | * returns directly without waiting for all data to be written to the TX register. When |
AnnaBridge | 143:86740a56073b | 651 | * all data is written to the TX register in the ISR, the UART driver calls the callback |
AnnaBridge | 143:86740a56073b | 652 | * function and passes the @ref kStatus_UART_TxIdle as status parameter. |
AnnaBridge | 143:86740a56073b | 653 | * |
AnnaBridge | 143:86740a56073b | 654 | * @note The kStatus_UART_TxIdle is passed to the upper layer when all data is written |
AnnaBridge | 143:86740a56073b | 655 | * to the TX register. However, it does not ensure that all data is sent out. Before disabling the TX, |
AnnaBridge | 143:86740a56073b | 656 | * check the kUART_TransmissionCompleteFlag to ensure that the TX is finished. |
AnnaBridge | 143:86740a56073b | 657 | * |
AnnaBridge | 143:86740a56073b | 658 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 659 | * @param handle UART handle pointer. |
AnnaBridge | 143:86740a56073b | 660 | * @param xfer UART transfer structure. See #uart_transfer_t. |
AnnaBridge | 143:86740a56073b | 661 | * @retval kStatus_Success Successfully start the data transmission. |
AnnaBridge | 143:86740a56073b | 662 | * @retval kStatus_UART_TxBusy Previous transmission still not finished; data not all written to TX register yet. |
AnnaBridge | 143:86740a56073b | 663 | * @retval kStatus_InvalidArgument Invalid argument. |
AnnaBridge | 143:86740a56073b | 664 | */ |
AnnaBridge | 143:86740a56073b | 665 | status_t UART_TransferSendNonBlocking(UART_Type *base, uart_handle_t *handle, uart_transfer_t *xfer); |
AnnaBridge | 143:86740a56073b | 666 | |
AnnaBridge | 143:86740a56073b | 667 | /*! |
AnnaBridge | 143:86740a56073b | 668 | * @brief Aborts the interrupt-driven data transmit. |
AnnaBridge | 143:86740a56073b | 669 | * |
AnnaBridge | 143:86740a56073b | 670 | * This function aborts the interrupt-driven data sending. The user can get the remainBytes to find out |
AnnaBridge | 143:86740a56073b | 671 | * how many bytes are not sent out. |
AnnaBridge | 143:86740a56073b | 672 | * |
AnnaBridge | 143:86740a56073b | 673 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 674 | * @param handle UART handle pointer. |
AnnaBridge | 143:86740a56073b | 675 | */ |
AnnaBridge | 143:86740a56073b | 676 | void UART_TransferAbortSend(UART_Type *base, uart_handle_t *handle); |
AnnaBridge | 143:86740a56073b | 677 | |
AnnaBridge | 143:86740a56073b | 678 | /*! |
AnnaBridge | 143:86740a56073b | 679 | * @brief Gets the number of bytes written to the UART TX register. |
AnnaBridge | 143:86740a56073b | 680 | * |
AnnaBridge | 143:86740a56073b | 681 | * This function gets the number of bytes written to the UART TX |
AnnaBridge | 143:86740a56073b | 682 | * register by using the interrupt method. |
AnnaBridge | 143:86740a56073b | 683 | * |
AnnaBridge | 143:86740a56073b | 684 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 685 | * @param handle UART handle pointer. |
AnnaBridge | 143:86740a56073b | 686 | * @param count Send bytes count. |
AnnaBridge | 143:86740a56073b | 687 | * @retval kStatus_NoTransferInProgress No send in progress. |
AnnaBridge | 143:86740a56073b | 688 | * @retval kStatus_InvalidArgument The parameter is invalid. |
AnnaBridge | 143:86740a56073b | 689 | * @retval kStatus_Success Get successfully through the parameter \p count; |
AnnaBridge | 143:86740a56073b | 690 | */ |
AnnaBridge | 143:86740a56073b | 691 | status_t UART_TransferGetSendCount(UART_Type *base, uart_handle_t *handle, uint32_t *count); |
AnnaBridge | 143:86740a56073b | 692 | |
AnnaBridge | 143:86740a56073b | 693 | /*! |
AnnaBridge | 143:86740a56073b | 694 | * @brief Receives a buffer of data using an interrupt method. |
AnnaBridge | 143:86740a56073b | 695 | * |
AnnaBridge | 143:86740a56073b | 696 | * This function receives data using an interrupt method. This is a non-blocking function, which |
AnnaBridge | 143:86740a56073b | 697 | * returns without waiting for all data to be received. |
AnnaBridge | 143:86740a56073b | 698 | * If the RX ring buffer is used and not empty, the data in the ring buffer is copied and |
AnnaBridge | 143:86740a56073b | 699 | * the parameter @p receivedBytes shows how many bytes are copied from the ring buffer. |
AnnaBridge | 143:86740a56073b | 700 | * After copying, if the data in the ring buffer is not enough to read, the receive |
AnnaBridge | 143:86740a56073b | 701 | * request is saved by the UART driver. When the new data arrives, the receive request |
AnnaBridge | 143:86740a56073b | 702 | * is serviced first. When all data is received, the UART driver notifies the upper layer |
AnnaBridge | 143:86740a56073b | 703 | * through a callback function and passes the status parameter @ref kStatus_UART_RxIdle. |
AnnaBridge | 143:86740a56073b | 704 | * For example, the upper layer needs 10 bytes but there are only 5 bytes in the ring buffer. |
AnnaBridge | 143:86740a56073b | 705 | * The 5 bytes are copied to the xfer->data and this function returns with the |
AnnaBridge | 143:86740a56073b | 706 | * parameter @p receivedBytes set to 5. For the left 5 bytes, newly arrived data is |
AnnaBridge | 143:86740a56073b | 707 | * saved from the xfer->data[5]. When 5 bytes are received, the UART driver notifies the upper layer. |
AnnaBridge | 143:86740a56073b | 708 | * If the RX ring buffer is not enabled, this function enables the RX and RX interrupt |
AnnaBridge | 143:86740a56073b | 709 | * to receive data to the xfer->data. When all data is received, the upper layer is notified. |
AnnaBridge | 143:86740a56073b | 710 | * |
AnnaBridge | 143:86740a56073b | 711 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 712 | * @param handle UART handle pointer. |
AnnaBridge | 143:86740a56073b | 713 | * @param xfer UART transfer structure, see #uart_transfer_t. |
AnnaBridge | 143:86740a56073b | 714 | * @param receivedBytes Bytes received from the ring buffer directly. |
AnnaBridge | 143:86740a56073b | 715 | * @retval kStatus_Success Successfully queue the transfer into transmit queue. |
AnnaBridge | 143:86740a56073b | 716 | * @retval kStatus_UART_RxBusy Previous receive request is not finished. |
AnnaBridge | 143:86740a56073b | 717 | * @retval kStatus_InvalidArgument Invalid argument. |
AnnaBridge | 143:86740a56073b | 718 | */ |
AnnaBridge | 143:86740a56073b | 719 | status_t UART_TransferReceiveNonBlocking(UART_Type *base, |
AnnaBridge | 143:86740a56073b | 720 | uart_handle_t *handle, |
AnnaBridge | 143:86740a56073b | 721 | uart_transfer_t *xfer, |
AnnaBridge | 143:86740a56073b | 722 | size_t *receivedBytes); |
AnnaBridge | 143:86740a56073b | 723 | |
AnnaBridge | 143:86740a56073b | 724 | /*! |
AnnaBridge | 143:86740a56073b | 725 | * @brief Aborts the interrupt-driven data receiving. |
AnnaBridge | 143:86740a56073b | 726 | * |
AnnaBridge | 143:86740a56073b | 727 | * This function aborts the interrupt-driven data receiving. The user can get the remainBytes to know |
AnnaBridge | 143:86740a56073b | 728 | * how many bytes are not received yet. |
AnnaBridge | 143:86740a56073b | 729 | * |
AnnaBridge | 143:86740a56073b | 730 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 731 | * @param handle UART handle pointer. |
AnnaBridge | 143:86740a56073b | 732 | */ |
AnnaBridge | 143:86740a56073b | 733 | void UART_TransferAbortReceive(UART_Type *base, uart_handle_t *handle); |
AnnaBridge | 143:86740a56073b | 734 | |
AnnaBridge | 143:86740a56073b | 735 | /*! |
AnnaBridge | 143:86740a56073b | 736 | * @brief Gets the number of bytes that have been received. |
AnnaBridge | 143:86740a56073b | 737 | * |
AnnaBridge | 143:86740a56073b | 738 | * This function gets the number of bytes that have been received. |
AnnaBridge | 143:86740a56073b | 739 | * |
AnnaBridge | 143:86740a56073b | 740 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 741 | * @param handle UART handle pointer. |
AnnaBridge | 143:86740a56073b | 742 | * @param count Receive bytes count. |
AnnaBridge | 143:86740a56073b | 743 | * @retval kStatus_NoTransferInProgress No receive in progress. |
AnnaBridge | 143:86740a56073b | 744 | * @retval kStatus_InvalidArgument Parameter is invalid. |
AnnaBridge | 143:86740a56073b | 745 | * @retval kStatus_Success Get successfully through the parameter \p count; |
AnnaBridge | 143:86740a56073b | 746 | */ |
AnnaBridge | 143:86740a56073b | 747 | status_t UART_TransferGetReceiveCount(UART_Type *base, uart_handle_t *handle, uint32_t *count); |
AnnaBridge | 143:86740a56073b | 748 | |
AnnaBridge | 143:86740a56073b | 749 | /*! |
AnnaBridge | 143:86740a56073b | 750 | * @brief UART IRQ handle function. |
AnnaBridge | 143:86740a56073b | 751 | * |
AnnaBridge | 143:86740a56073b | 752 | * This function handles the UART transmit and receive IRQ request. |
AnnaBridge | 143:86740a56073b | 753 | * |
AnnaBridge | 143:86740a56073b | 754 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 755 | * @param handle UART handle pointer. |
AnnaBridge | 143:86740a56073b | 756 | */ |
AnnaBridge | 143:86740a56073b | 757 | void UART_TransferHandleIRQ(UART_Type *base, uart_handle_t *handle); |
AnnaBridge | 143:86740a56073b | 758 | |
AnnaBridge | 143:86740a56073b | 759 | /*! |
AnnaBridge | 143:86740a56073b | 760 | * @brief UART Error IRQ handle function. |
AnnaBridge | 143:86740a56073b | 761 | * |
AnnaBridge | 143:86740a56073b | 762 | * This function handles the UART error IRQ request. |
AnnaBridge | 143:86740a56073b | 763 | * |
AnnaBridge | 143:86740a56073b | 764 | * @param base UART peripheral base address. |
AnnaBridge | 143:86740a56073b | 765 | * @param handle UART handle pointer. |
AnnaBridge | 143:86740a56073b | 766 | */ |
AnnaBridge | 143:86740a56073b | 767 | void UART_TransferHandleErrorIRQ(UART_Type *base, uart_handle_t *handle); |
AnnaBridge | 143:86740a56073b | 768 | |
AnnaBridge | 143:86740a56073b | 769 | /* @} */ |
AnnaBridge | 143:86740a56073b | 770 | |
AnnaBridge | 143:86740a56073b | 771 | #if defined(__cplusplus) |
AnnaBridge | 143:86740a56073b | 772 | } |
AnnaBridge | 143:86740a56073b | 773 | #endif |
AnnaBridge | 143:86740a56073b | 774 | |
AnnaBridge | 143:86740a56073b | 775 | /*! @}*/ |
AnnaBridge | 143:86740a56073b | 776 | |
AnnaBridge | 143:86740a56073b | 777 | #endif /* _FSL_UART_H_ */ |