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_KL82Z/TOOLCHAIN_IAR/fsl_lpuart.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
- Parent:
- TARGET_USENSE/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/drivers/fsl_lpuart.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, 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 | #ifndef _FSL_LPUART_H_ |
AnnaBridge | 145:64910690c574 | 31 | #define _FSL_LPUART_H_ |
AnnaBridge | 145:64910690c574 | 32 | |
AnnaBridge | 145:64910690c574 | 33 | #include "fsl_common.h" |
AnnaBridge | 145:64910690c574 | 34 | |
AnnaBridge | 145:64910690c574 | 35 | /*! |
AnnaBridge | 145:64910690c574 | 36 | * @addtogroup lpuart_driver |
AnnaBridge | 145:64910690c574 | 37 | * @{ |
AnnaBridge | 145:64910690c574 | 38 | */ |
AnnaBridge | 145:64910690c574 | 39 | |
AnnaBridge | 145:64910690c574 | 40 | |
AnnaBridge | 145:64910690c574 | 41 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 42 | * Definitions |
AnnaBridge | 145:64910690c574 | 43 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 44 | |
AnnaBridge | 145:64910690c574 | 45 | /*! @name Driver version */ |
AnnaBridge | 145:64910690c574 | 46 | /*@{*/ |
AnnaBridge | 145:64910690c574 | 47 | /*! @brief LPUART driver version 2.2.1. */ |
AnnaBridge | 145:64910690c574 | 48 | #define FSL_LPUART_DRIVER_VERSION (MAKE_VERSION(2, 2, 1)) |
AnnaBridge | 145:64910690c574 | 49 | /*@}*/ |
AnnaBridge | 145:64910690c574 | 50 | |
AnnaBridge | 145:64910690c574 | 51 | /*! @brief Error codes for the LPUART driver. */ |
AnnaBridge | 145:64910690c574 | 52 | enum _lpuart_status |
AnnaBridge | 145:64910690c574 | 53 | { |
AnnaBridge | 145:64910690c574 | 54 | kStatus_LPUART_TxBusy = MAKE_STATUS(kStatusGroup_LPUART, 0), /*!< TX busy */ |
AnnaBridge | 145:64910690c574 | 55 | kStatus_LPUART_RxBusy = MAKE_STATUS(kStatusGroup_LPUART, 1), /*!< RX busy */ |
AnnaBridge | 145:64910690c574 | 56 | kStatus_LPUART_TxIdle = MAKE_STATUS(kStatusGroup_LPUART, 2), /*!< LPUART transmitter is idle. */ |
AnnaBridge | 145:64910690c574 | 57 | kStatus_LPUART_RxIdle = MAKE_STATUS(kStatusGroup_LPUART, 3), /*!< LPUART receiver is idle. */ |
AnnaBridge | 145:64910690c574 | 58 | kStatus_LPUART_TxWatermarkTooLarge = MAKE_STATUS(kStatusGroup_LPUART, 4), /*!< TX FIFO watermark too large */ |
AnnaBridge | 145:64910690c574 | 59 | kStatus_LPUART_RxWatermarkTooLarge = MAKE_STATUS(kStatusGroup_LPUART, 5), /*!< RX FIFO watermark too large */ |
AnnaBridge | 145:64910690c574 | 60 | kStatus_LPUART_FlagCannotClearManually = |
AnnaBridge | 145:64910690c574 | 61 | MAKE_STATUS(kStatusGroup_LPUART, 6), /*!< Some flag can't manually clear */ |
AnnaBridge | 145:64910690c574 | 62 | kStatus_LPUART_Error = MAKE_STATUS(kStatusGroup_LPUART, 7), /*!< Error happens on LPUART. */ |
AnnaBridge | 145:64910690c574 | 63 | kStatus_LPUART_RxRingBufferOverrun = |
AnnaBridge | 145:64910690c574 | 64 | MAKE_STATUS(kStatusGroup_LPUART, 8), /*!< LPUART RX software ring buffer overrun. */ |
AnnaBridge | 145:64910690c574 | 65 | kStatus_LPUART_RxHardwareOverrun = MAKE_STATUS(kStatusGroup_LPUART, 9), /*!< LPUART RX receiver overrun. */ |
AnnaBridge | 145:64910690c574 | 66 | kStatus_LPUART_NoiseError = MAKE_STATUS(kStatusGroup_LPUART, 10), /*!< LPUART noise error. */ |
AnnaBridge | 145:64910690c574 | 67 | kStatus_LPUART_FramingError = MAKE_STATUS(kStatusGroup_LPUART, 11), /*!< LPUART framing error. */ |
AnnaBridge | 145:64910690c574 | 68 | kStatus_LPUART_ParityError = MAKE_STATUS(kStatusGroup_LPUART, 12), /*!< LPUART parity error. */ |
AnnaBridge | 145:64910690c574 | 69 | kStatus_LPUART_BaudrateNotSupport = |
AnnaBridge | 145:64910690c574 | 70 | MAKE_STATUS(kStatusGroup_LPUART, 13), /*!< Baudrate is not support in current clock source */ |
AnnaBridge | 145:64910690c574 | 71 | }; |
AnnaBridge | 145:64910690c574 | 72 | |
AnnaBridge | 145:64910690c574 | 73 | /*! @brief LPUART parity mode. */ |
AnnaBridge | 145:64910690c574 | 74 | typedef enum _lpuart_parity_mode |
AnnaBridge | 145:64910690c574 | 75 | { |
AnnaBridge | 145:64910690c574 | 76 | kLPUART_ParityDisabled = 0x0U, /*!< Parity disabled */ |
AnnaBridge | 145:64910690c574 | 77 | kLPUART_ParityEven = 0x2U, /*!< Parity enabled, type even, bit setting: PE|PT = 10 */ |
AnnaBridge | 145:64910690c574 | 78 | kLPUART_ParityOdd = 0x3U, /*!< Parity enabled, type odd, bit setting: PE|PT = 11 */ |
AnnaBridge | 145:64910690c574 | 79 | } lpuart_parity_mode_t; |
AnnaBridge | 145:64910690c574 | 80 | |
AnnaBridge | 145:64910690c574 | 81 | /*! @brief LPUART data bits count. */ |
AnnaBridge | 145:64910690c574 | 82 | typedef enum _lpuart_data_bits |
AnnaBridge | 145:64910690c574 | 83 | { |
AnnaBridge | 145:64910690c574 | 84 | kLPUART_EightDataBits = 0x0U, /*!< Eight data bit */ |
AnnaBridge | 145:64910690c574 | 85 | #if defined(FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT) && FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT |
AnnaBridge | 145:64910690c574 | 86 | kLPUART_SevenDataBits = 0x1U, /*!< Seven data bit */ |
AnnaBridge | 145:64910690c574 | 87 | #endif |
AnnaBridge | 145:64910690c574 | 88 | } lpuart_data_bits_t; |
AnnaBridge | 145:64910690c574 | 89 | |
AnnaBridge | 145:64910690c574 | 90 | /*! @brief LPUART stop bit count. */ |
AnnaBridge | 145:64910690c574 | 91 | typedef enum _lpuart_stop_bit_count |
AnnaBridge | 145:64910690c574 | 92 | { |
AnnaBridge | 145:64910690c574 | 93 | kLPUART_OneStopBit = 0U, /*!< One stop bit */ |
AnnaBridge | 145:64910690c574 | 94 | kLPUART_TwoStopBit = 1U, /*!< Two stop bits */ |
AnnaBridge | 145:64910690c574 | 95 | } lpuart_stop_bit_count_t; |
AnnaBridge | 145:64910690c574 | 96 | |
AnnaBridge | 145:64910690c574 | 97 | /*! |
AnnaBridge | 145:64910690c574 | 98 | * @brief LPUART interrupt configuration structure, default settings all disabled. |
AnnaBridge | 145:64910690c574 | 99 | * |
AnnaBridge | 145:64910690c574 | 100 | * This structure contains the settings for all LPUART interrupt configurations. |
AnnaBridge | 145:64910690c574 | 101 | */ |
AnnaBridge | 145:64910690c574 | 102 | enum _lpuart_interrupt_enable |
AnnaBridge | 145:64910690c574 | 103 | { |
AnnaBridge | 145:64910690c574 | 104 | #if defined(FSL_FEATURE_LPUART_HAS_LIN_BREAK_DETECT) && FSL_FEATURE_LPUART_HAS_LIN_BREAK_DETECT |
AnnaBridge | 145:64910690c574 | 105 | kLPUART_LinBreakInterruptEnable = (LPUART_BAUD_LBKDIE_MASK >> 8), /*!< LIN break detect. */ |
AnnaBridge | 145:64910690c574 | 106 | #endif |
AnnaBridge | 145:64910690c574 | 107 | kLPUART_RxActiveEdgeInterruptEnable = (LPUART_BAUD_RXEDGIE_MASK >> 8), /*!< Receive Active Edge. */ |
AnnaBridge | 145:64910690c574 | 108 | kLPUART_TxDataRegEmptyInterruptEnable = (LPUART_CTRL_TIE_MASK), /*!< Transmit data register empty. */ |
AnnaBridge | 145:64910690c574 | 109 | kLPUART_TransmissionCompleteInterruptEnable = (LPUART_CTRL_TCIE_MASK), /*!< Transmission complete. */ |
AnnaBridge | 145:64910690c574 | 110 | kLPUART_RxDataRegFullInterruptEnable = (LPUART_CTRL_RIE_MASK), /*!< Receiver data register full. */ |
AnnaBridge | 145:64910690c574 | 111 | kLPUART_IdleLineInterruptEnable = (LPUART_CTRL_ILIE_MASK), /*!< Idle line. */ |
AnnaBridge | 145:64910690c574 | 112 | kLPUART_RxOverrunInterruptEnable = (LPUART_CTRL_ORIE_MASK), /*!< Receiver Overrun. */ |
AnnaBridge | 145:64910690c574 | 113 | kLPUART_NoiseErrorInterruptEnable = (LPUART_CTRL_NEIE_MASK), /*!< Noise error flag. */ |
AnnaBridge | 145:64910690c574 | 114 | kLPUART_FramingErrorInterruptEnable = (LPUART_CTRL_FEIE_MASK), /*!< Framing error flag. */ |
AnnaBridge | 145:64910690c574 | 115 | kLPUART_ParityErrorInterruptEnable = (LPUART_CTRL_PEIE_MASK), /*!< Parity error flag. */ |
AnnaBridge | 145:64910690c574 | 116 | #if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO |
AnnaBridge | 145:64910690c574 | 117 | kLPUART_TxFifoOverflowInterruptEnable = (LPUART_FIFO_TXOFE_MASK >> 8), /*!< Transmit FIFO Overflow. */ |
AnnaBridge | 145:64910690c574 | 118 | kLPUART_RxFifoUnderflowInterruptEnable = (LPUART_FIFO_RXUFE_MASK >> 8), /*!< Receive FIFO Underflow. */ |
AnnaBridge | 145:64910690c574 | 119 | #endif |
AnnaBridge | 145:64910690c574 | 120 | }; |
AnnaBridge | 145:64910690c574 | 121 | |
AnnaBridge | 145:64910690c574 | 122 | /*! |
AnnaBridge | 145:64910690c574 | 123 | * @brief LPUART status flags. |
AnnaBridge | 145:64910690c574 | 124 | * |
AnnaBridge | 145:64910690c574 | 125 | * This provides constants for the LPUART status flags for use in the LPUART functions. |
AnnaBridge | 145:64910690c574 | 126 | */ |
AnnaBridge | 145:64910690c574 | 127 | enum _lpuart_flags |
AnnaBridge | 145:64910690c574 | 128 | { |
AnnaBridge | 145:64910690c574 | 129 | kLPUART_TxDataRegEmptyFlag = |
AnnaBridge | 145:64910690c574 | 130 | (LPUART_STAT_TDRE_MASK), /*!< Transmit data register empty flag, sets when transmit buffer is empty */ |
AnnaBridge | 145:64910690c574 | 131 | kLPUART_TransmissionCompleteFlag = |
AnnaBridge | 145:64910690c574 | 132 | (LPUART_STAT_TC_MASK), /*!< Transmission complete flag, sets when transmission activity complete */ |
AnnaBridge | 145:64910690c574 | 133 | kLPUART_RxDataRegFullFlag = |
AnnaBridge | 145:64910690c574 | 134 | (LPUART_STAT_RDRF_MASK), /*!< Receive data register full flag, sets when the receive data buffer is full */ |
AnnaBridge | 145:64910690c574 | 135 | kLPUART_IdleLineFlag = (LPUART_STAT_IDLE_MASK), /*!< Idle line detect flag, sets when idle line detected */ |
AnnaBridge | 145:64910690c574 | 136 | kLPUART_RxOverrunFlag = (LPUART_STAT_OR_MASK), /*!< Receive Overrun, sets when new data is received before data is |
AnnaBridge | 145:64910690c574 | 137 | read from receive register */ |
AnnaBridge | 145:64910690c574 | 138 | kLPUART_NoiseErrorFlag = (LPUART_STAT_NF_MASK), /*!< Receive takes 3 samples of each received bit. If any of these |
AnnaBridge | 145:64910690c574 | 139 | samples differ, noise flag sets */ |
AnnaBridge | 145:64910690c574 | 140 | kLPUART_FramingErrorFlag = |
AnnaBridge | 145:64910690c574 | 141 | (LPUART_STAT_FE_MASK), /*!< Frame error flag, sets if logic 0 was detected where stop bit expected */ |
AnnaBridge | 145:64910690c574 | 142 | kLPUART_ParityErrorFlag = (LPUART_STAT_PF_MASK), /*!< If parity enabled, sets upon parity error detection */ |
AnnaBridge | 145:64910690c574 | 143 | #if defined(FSL_FEATURE_LPUART_HAS_LIN_BREAK_DETECT) && FSL_FEATURE_LPUART_HAS_LIN_BREAK_DETECT |
AnnaBridge | 145:64910690c574 | 144 | kLPUART_LinBreakFlag = (LPUART_STAT_LBKDIF_MASK), /*!< LIN break detect interrupt flag, sets when LIN break char |
AnnaBridge | 145:64910690c574 | 145 | detected and LIN circuit enabled */ |
AnnaBridge | 145:64910690c574 | 146 | #endif |
AnnaBridge | 145:64910690c574 | 147 | kLPUART_RxActiveEdgeFlag = |
AnnaBridge | 145:64910690c574 | 148 | (LPUART_STAT_RXEDGIF_MASK), /*!< Receive pin active edge interrupt flag, sets when active edge detected */ |
AnnaBridge | 145:64910690c574 | 149 | kLPUART_RxActiveFlag = |
AnnaBridge | 145:64910690c574 | 150 | (LPUART_STAT_RAF_MASK), /*!< Receiver Active Flag (RAF), sets at beginning of valid start bit */ |
AnnaBridge | 145:64910690c574 | 151 | #if defined(FSL_FEATURE_LPUART_HAS_ADDRESS_MATCHING) && FSL_FEATURE_LPUART_HAS_ADDRESS_MATCHING |
AnnaBridge | 145:64910690c574 | 152 | kLPUART_DataMatch1Flag = LPUART_STAT_MA1F_MASK, /*!< The next character to be read from LPUART_DATA matches MA1*/ |
AnnaBridge | 145:64910690c574 | 153 | kLPUART_DataMatch2Flag = LPUART_STAT_MA2F_MASK, /*!< The next character to be read from LPUART_DATA matches MA2*/ |
AnnaBridge | 145:64910690c574 | 154 | #endif |
AnnaBridge | 145:64910690c574 | 155 | #if defined(FSL_FEATURE_LPUART_HAS_EXTENDED_DATA_REGISTER_FLAGS) && FSL_FEATURE_LPUART_HAS_EXTENDED_DATA_REGISTER_FLAGS |
AnnaBridge | 145:64910690c574 | 156 | kLPUART_NoiseErrorInRxDataRegFlag = |
AnnaBridge | 145:64910690c574 | 157 | (LPUART_DATA_NOISY_MASK >> 10), /*!< NOISY bit, sets if noise detected in current data word */ |
AnnaBridge | 145:64910690c574 | 158 | kLPUART_ParityErrorInRxDataRegFlag = |
AnnaBridge | 145:64910690c574 | 159 | (LPUART_DATA_PARITYE_MASK >> 10), /*!< PARITYE bit, sets if noise detected in current data word */ |
AnnaBridge | 145:64910690c574 | 160 | #endif |
AnnaBridge | 145:64910690c574 | 161 | #if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO |
AnnaBridge | 145:64910690c574 | 162 | kLPUART_TxFifoEmptyFlag = (LPUART_FIFO_TXEMPT_MASK >> 16), /*!< TXEMPT bit, sets if transmit buffer is empty */ |
AnnaBridge | 145:64910690c574 | 163 | kLPUART_RxFifoEmptyFlag = (LPUART_FIFO_RXEMPT_MASK >> 16), /*!< RXEMPT bit, sets if receive buffer is empty */ |
AnnaBridge | 145:64910690c574 | 164 | kLPUART_TxFifoOverflowFlag = |
AnnaBridge | 145:64910690c574 | 165 | (LPUART_FIFO_TXOF_MASK >> 16), /*!< TXOF bit, sets if transmit buffer overflow occurred */ |
AnnaBridge | 145:64910690c574 | 166 | kLPUART_RxFifoUnderflowFlag = |
AnnaBridge | 145:64910690c574 | 167 | (LPUART_FIFO_RXUF_MASK >> 16), /*!< RXUF bit, sets if receive buffer underflow occurred */ |
AnnaBridge | 145:64910690c574 | 168 | #endif |
AnnaBridge | 145:64910690c574 | 169 | }; |
AnnaBridge | 145:64910690c574 | 170 | |
AnnaBridge | 145:64910690c574 | 171 | /*! @brief LPUART configure structure. */ |
AnnaBridge | 145:64910690c574 | 172 | typedef struct _lpuart_config |
AnnaBridge | 145:64910690c574 | 173 | { |
AnnaBridge | 145:64910690c574 | 174 | uint32_t baudRate_Bps; /*!< LPUART baud rate */ |
AnnaBridge | 145:64910690c574 | 175 | lpuart_parity_mode_t parityMode; /*!< Parity mode, disabled (default), even, odd */ |
AnnaBridge | 145:64910690c574 | 176 | lpuart_data_bits_t dataBitsCount; /*!< Data bits count, eight (default), seven */ |
AnnaBridge | 145:64910690c574 | 177 | bool isMsb; /*!< Data bits order, LSB (default), MSB */ |
AnnaBridge | 145:64910690c574 | 178 | #if defined(FSL_FEATURE_LPUART_HAS_STOP_BIT_CONFIG_SUPPORT) && FSL_FEATURE_LPUART_HAS_STOP_BIT_CONFIG_SUPPORT |
AnnaBridge | 145:64910690c574 | 179 | lpuart_stop_bit_count_t stopBitCount; /*!< Number of stop bits, 1 stop bit (default) or 2 stop bits */ |
AnnaBridge | 145:64910690c574 | 180 | #endif |
AnnaBridge | 145:64910690c574 | 181 | #if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO |
AnnaBridge | 145:64910690c574 | 182 | uint8_t txFifoWatermark; /*!< TX FIFO watermark */ |
AnnaBridge | 145:64910690c574 | 183 | uint8_t rxFifoWatermark; /*!< RX FIFO watermark */ |
AnnaBridge | 145:64910690c574 | 184 | #endif |
AnnaBridge | 145:64910690c574 | 185 | bool enableTx; /*!< Enable TX */ |
AnnaBridge | 145:64910690c574 | 186 | bool enableRx; /*!< Enable RX */ |
AnnaBridge | 145:64910690c574 | 187 | } lpuart_config_t; |
AnnaBridge | 145:64910690c574 | 188 | |
AnnaBridge | 145:64910690c574 | 189 | /*! @brief LPUART transfer structure. */ |
AnnaBridge | 145:64910690c574 | 190 | typedef struct _lpuart_transfer |
AnnaBridge | 145:64910690c574 | 191 | { |
AnnaBridge | 145:64910690c574 | 192 | uint8_t *data; /*!< The buffer of data to be transfer.*/ |
AnnaBridge | 145:64910690c574 | 193 | size_t dataSize; /*!< The byte count to be transfer. */ |
AnnaBridge | 145:64910690c574 | 194 | } lpuart_transfer_t; |
AnnaBridge | 145:64910690c574 | 195 | |
AnnaBridge | 145:64910690c574 | 196 | /* Forward declaration of the handle typedef. */ |
AnnaBridge | 145:64910690c574 | 197 | typedef struct _lpuart_handle lpuart_handle_t; |
AnnaBridge | 145:64910690c574 | 198 | |
AnnaBridge | 145:64910690c574 | 199 | /*! @brief LPUART transfer callback function. */ |
AnnaBridge | 145:64910690c574 | 200 | typedef void (*lpuart_transfer_callback_t)(LPUART_Type *base, lpuart_handle_t *handle, status_t status, void *userData); |
AnnaBridge | 145:64910690c574 | 201 | |
AnnaBridge | 145:64910690c574 | 202 | /*! @brief LPUART handle structure. */ |
AnnaBridge | 145:64910690c574 | 203 | struct _lpuart_handle |
AnnaBridge | 145:64910690c574 | 204 | { |
AnnaBridge | 145:64910690c574 | 205 | uint8_t *volatile txData; /*!< Address of remaining data to send. */ |
AnnaBridge | 145:64910690c574 | 206 | volatile size_t txDataSize; /*!< Size of the remaining data to send. */ |
AnnaBridge | 145:64910690c574 | 207 | size_t txDataSizeAll; /*!< Size of the data to send out. */ |
AnnaBridge | 145:64910690c574 | 208 | uint8_t *volatile rxData; /*!< Address of remaining data to receive. */ |
AnnaBridge | 145:64910690c574 | 209 | volatile size_t rxDataSize; /*!< Size of the remaining data to receive. */ |
AnnaBridge | 145:64910690c574 | 210 | size_t rxDataSizeAll; /*!< Size of the data to receive. */ |
AnnaBridge | 145:64910690c574 | 211 | |
AnnaBridge | 145:64910690c574 | 212 | uint8_t *rxRingBuffer; /*!< Start address of the receiver ring buffer. */ |
AnnaBridge | 145:64910690c574 | 213 | size_t rxRingBufferSize; /*!< Size of the ring buffer. */ |
AnnaBridge | 145:64910690c574 | 214 | volatile uint16_t rxRingBufferHead; /*!< Index for the driver to store received data into ring buffer. */ |
AnnaBridge | 145:64910690c574 | 215 | volatile uint16_t rxRingBufferTail; /*!< Index for the user to get data from the ring buffer. */ |
AnnaBridge | 145:64910690c574 | 216 | |
AnnaBridge | 145:64910690c574 | 217 | lpuart_transfer_callback_t callback; /*!< Callback function. */ |
AnnaBridge | 145:64910690c574 | 218 | void *userData; /*!< LPUART callback function parameter.*/ |
AnnaBridge | 145:64910690c574 | 219 | |
AnnaBridge | 145:64910690c574 | 220 | volatile uint8_t txState; /*!< TX transfer state. */ |
AnnaBridge | 145:64910690c574 | 221 | volatile uint8_t rxState; /*!< RX transfer state. */ |
AnnaBridge | 145:64910690c574 | 222 | |
AnnaBridge | 145:64910690c574 | 223 | #if defined(FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT) && FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT |
AnnaBridge | 145:64910690c574 | 224 | bool isSevenDataBits; /*!< Seven data bits flag. */ |
AnnaBridge | 145:64910690c574 | 225 | #endif |
AnnaBridge | 145:64910690c574 | 226 | }; |
AnnaBridge | 145:64910690c574 | 227 | |
AnnaBridge | 145:64910690c574 | 228 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 229 | * API |
AnnaBridge | 145:64910690c574 | 230 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 231 | |
AnnaBridge | 145:64910690c574 | 232 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 233 | extern "C" { |
AnnaBridge | 145:64910690c574 | 234 | #endif /* _cplusplus */ |
AnnaBridge | 145:64910690c574 | 235 | |
AnnaBridge | 145:64910690c574 | 236 | /*! |
AnnaBridge | 145:64910690c574 | 237 | * @name Initialization and deinitialization |
AnnaBridge | 145:64910690c574 | 238 | * @{ |
AnnaBridge | 145:64910690c574 | 239 | */ |
AnnaBridge | 145:64910690c574 | 240 | |
AnnaBridge | 145:64910690c574 | 241 | /*! |
AnnaBridge | 145:64910690c574 | 242 | * @brief Initializes an LPUART instance with the user configuration structure and the peripheral clock. |
AnnaBridge | 145:64910690c574 | 243 | * |
AnnaBridge | 145:64910690c574 | 244 | * This function configures the LPUART module with user-defined settings. Call the LPUART_GetDefaultConfig() function |
AnnaBridge | 145:64910690c574 | 245 | * to configure the configuration structure and get the default configuration. |
AnnaBridge | 145:64910690c574 | 246 | * The example below shows how to use this API to configure the LPUART. |
AnnaBridge | 145:64910690c574 | 247 | * @code |
AnnaBridge | 145:64910690c574 | 248 | * lpuart_config_t lpuartConfig; |
AnnaBridge | 145:64910690c574 | 249 | * lpuartConfig.baudRate_Bps = 115200U; |
AnnaBridge | 145:64910690c574 | 250 | * lpuartConfig.parityMode = kLPUART_ParityDisabled; |
AnnaBridge | 145:64910690c574 | 251 | * lpuartConfig.dataBitsCount = kLPUART_EightDataBits; |
AnnaBridge | 145:64910690c574 | 252 | * lpuartConfig.isMsb = false; |
AnnaBridge | 145:64910690c574 | 253 | * lpuartConfig.stopBitCount = kLPUART_OneStopBit; |
AnnaBridge | 145:64910690c574 | 254 | * lpuartConfig.txFifoWatermark = 0; |
AnnaBridge | 145:64910690c574 | 255 | * lpuartConfig.rxFifoWatermark = 1; |
AnnaBridge | 145:64910690c574 | 256 | * LPUART_Init(LPUART1, &lpuartConfig, 20000000U); |
AnnaBridge | 145:64910690c574 | 257 | * @endcode |
AnnaBridge | 145:64910690c574 | 258 | * |
AnnaBridge | 145:64910690c574 | 259 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 260 | * @param config Pointer to a user-defined configuration structure. |
AnnaBridge | 145:64910690c574 | 261 | * @param srcClock_Hz LPUART clock source frequency in HZ. |
AnnaBridge | 145:64910690c574 | 262 | * @retval kStatus_LPUART_BaudrateNotSupport Baudrate is not support in current clock source. |
AnnaBridge | 145:64910690c574 | 263 | * @retval kStatus_Success LPUART initialize succeed |
AnnaBridge | 145:64910690c574 | 264 | */ |
AnnaBridge | 145:64910690c574 | 265 | status_t LPUART_Init(LPUART_Type *base, const lpuart_config_t *config, uint32_t srcClock_Hz); |
AnnaBridge | 145:64910690c574 | 266 | |
AnnaBridge | 145:64910690c574 | 267 | /*! |
AnnaBridge | 145:64910690c574 | 268 | * @brief Deinitializes a LPUART instance. |
AnnaBridge | 145:64910690c574 | 269 | * |
AnnaBridge | 145:64910690c574 | 270 | * This function waits for transmit to complete, disables TX and RX, and disables the LPUART clock. |
AnnaBridge | 145:64910690c574 | 271 | * |
AnnaBridge | 145:64910690c574 | 272 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 273 | */ |
AnnaBridge | 145:64910690c574 | 274 | void LPUART_Deinit(LPUART_Type *base); |
AnnaBridge | 145:64910690c574 | 275 | |
AnnaBridge | 145:64910690c574 | 276 | /*! |
AnnaBridge | 145:64910690c574 | 277 | * @brief Gets the default configuration structure. |
AnnaBridge | 145:64910690c574 | 278 | * |
AnnaBridge | 145:64910690c574 | 279 | * This function initializes the LPUART configuration structure to a default value. The default |
AnnaBridge | 145:64910690c574 | 280 | * values are: |
AnnaBridge | 145:64910690c574 | 281 | * lpuartConfig->baudRate_Bps = 115200U; |
AnnaBridge | 145:64910690c574 | 282 | * lpuartConfig->parityMode = kLPUART_ParityDisabled; |
AnnaBridge | 145:64910690c574 | 283 | * lpuartConfig->dataBitsCount = kLPUART_EightDataBits; |
AnnaBridge | 145:64910690c574 | 284 | * lpuartConfig->isMsb = false; |
AnnaBridge | 145:64910690c574 | 285 | * lpuartConfig->stopBitCount = kLPUART_OneStopBit; |
AnnaBridge | 145:64910690c574 | 286 | * lpuartConfig->txFifoWatermark = 0; |
AnnaBridge | 145:64910690c574 | 287 | * lpuartConfig->rxFifoWatermark = 1; |
AnnaBridge | 145:64910690c574 | 288 | * lpuartConfig->enableTx = false; |
AnnaBridge | 145:64910690c574 | 289 | * lpuartConfig->enableRx = false; |
AnnaBridge | 145:64910690c574 | 290 | * |
AnnaBridge | 145:64910690c574 | 291 | * @param config Pointer to a configuration structure. |
AnnaBridge | 145:64910690c574 | 292 | */ |
AnnaBridge | 145:64910690c574 | 293 | void LPUART_GetDefaultConfig(lpuart_config_t *config); |
AnnaBridge | 145:64910690c574 | 294 | |
AnnaBridge | 145:64910690c574 | 295 | /*! |
AnnaBridge | 145:64910690c574 | 296 | * @brief Sets the LPUART instance baudrate. |
AnnaBridge | 145:64910690c574 | 297 | * |
AnnaBridge | 145:64910690c574 | 298 | * This function configures the LPUART module baudrate. This function is used to update |
AnnaBridge | 145:64910690c574 | 299 | * the LPUART module baudrate after the LPUART module is initialized by the LPUART_Init. |
AnnaBridge | 145:64910690c574 | 300 | * @code |
AnnaBridge | 145:64910690c574 | 301 | * LPUART_SetBaudRate(LPUART1, 115200U, 20000000U); |
AnnaBridge | 145:64910690c574 | 302 | * @endcode |
AnnaBridge | 145:64910690c574 | 303 | * |
AnnaBridge | 145:64910690c574 | 304 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 305 | * @param baudRate_Bps LPUART baudrate to be set. |
AnnaBridge | 145:64910690c574 | 306 | * @param srcClock_Hz LPUART clock source frequency in HZ. |
AnnaBridge | 145:64910690c574 | 307 | * @retval kStatus_LPUART_BaudrateNotSupport Baudrate is not supported in the current clock source. |
AnnaBridge | 145:64910690c574 | 308 | * @retval kStatus_Success Set baudrate succeeded. |
AnnaBridge | 145:64910690c574 | 309 | */ |
AnnaBridge | 145:64910690c574 | 310 | status_t LPUART_SetBaudRate(LPUART_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz); |
AnnaBridge | 145:64910690c574 | 311 | |
AnnaBridge | 145:64910690c574 | 312 | /* @} */ |
AnnaBridge | 145:64910690c574 | 313 | |
AnnaBridge | 145:64910690c574 | 314 | /*! |
AnnaBridge | 145:64910690c574 | 315 | * @name Status |
AnnaBridge | 145:64910690c574 | 316 | * @{ |
AnnaBridge | 145:64910690c574 | 317 | */ |
AnnaBridge | 145:64910690c574 | 318 | |
AnnaBridge | 145:64910690c574 | 319 | /*! |
AnnaBridge | 145:64910690c574 | 320 | * @brief Gets LPUART status flags. |
AnnaBridge | 145:64910690c574 | 321 | * |
AnnaBridge | 145:64910690c574 | 322 | * This function gets all LPUART status flags. The flags are returned as the logical |
AnnaBridge | 145:64910690c574 | 323 | * OR value of the enumerators @ref _lpuart_flags. To check for a specific status, |
AnnaBridge | 145:64910690c574 | 324 | * compare the return value with enumerators in the @ref _lpuart_flags. |
AnnaBridge | 145:64910690c574 | 325 | * For example, to check whether the TX is empty: |
AnnaBridge | 145:64910690c574 | 326 | * @code |
AnnaBridge | 145:64910690c574 | 327 | * if (kLPUART_TxDataRegEmptyFlag & LPUART_GetStatusFlags(LPUART1)) |
AnnaBridge | 145:64910690c574 | 328 | * { |
AnnaBridge | 145:64910690c574 | 329 | * ... |
AnnaBridge | 145:64910690c574 | 330 | * } |
AnnaBridge | 145:64910690c574 | 331 | * @endcode |
AnnaBridge | 145:64910690c574 | 332 | * |
AnnaBridge | 145:64910690c574 | 333 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 334 | * @return LPUART status flags which are ORed by the enumerators in the _lpuart_flags. |
AnnaBridge | 145:64910690c574 | 335 | */ |
AnnaBridge | 145:64910690c574 | 336 | uint32_t LPUART_GetStatusFlags(LPUART_Type *base); |
AnnaBridge | 145:64910690c574 | 337 | |
AnnaBridge | 145:64910690c574 | 338 | /*! |
AnnaBridge | 145:64910690c574 | 339 | * @brief Clears status flags with a provided mask. |
AnnaBridge | 145:64910690c574 | 340 | * |
AnnaBridge | 145:64910690c574 | 341 | * This function clears LPUART status flags with a provided mask. Automatically cleared flags |
AnnaBridge | 145:64910690c574 | 342 | * can't be cleared by this function. |
AnnaBridge | 145:64910690c574 | 343 | * Flags that can only cleared or set by hardware are: |
AnnaBridge | 145:64910690c574 | 344 | * kLPUART_TxDataRegEmptyFlag, kLPUART_TransmissionCompleteFlag, kLPUART_RxDataRegFullFlag, |
AnnaBridge | 145:64910690c574 | 345 | * kLPUART_RxActiveFlag, kLPUART_NoiseErrorInRxDataRegFlag, kLPUART_ParityErrorInRxDataRegFlag, |
AnnaBridge | 145:64910690c574 | 346 | * kLPUART_TxFifoEmptyFlag,kLPUART_RxFifoEmptyFlag |
AnnaBridge | 145:64910690c574 | 347 | * Note: This API should be called when the Tx/Rx is idle, otherwise it takes no effects. |
AnnaBridge | 145:64910690c574 | 348 | * |
AnnaBridge | 145:64910690c574 | 349 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 350 | * @param mask the status flags to be cleared. The user can use the enumerators in the |
AnnaBridge | 145:64910690c574 | 351 | * _lpuart_status_flag_t to do the OR operation and get the mask. |
AnnaBridge | 145:64910690c574 | 352 | * @return 0 succeed, others failed. |
AnnaBridge | 145:64910690c574 | 353 | * @retval kStatus_LPUART_FlagCannotClearManually The flag can't be cleared by this function but |
AnnaBridge | 145:64910690c574 | 354 | * it is cleared automatically by hardware. |
AnnaBridge | 145:64910690c574 | 355 | * @retval kStatus_Success Status in the mask are cleared. |
AnnaBridge | 145:64910690c574 | 356 | */ |
AnnaBridge | 145:64910690c574 | 357 | status_t LPUART_ClearStatusFlags(LPUART_Type *base, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 358 | |
AnnaBridge | 145:64910690c574 | 359 | /* @} */ |
AnnaBridge | 145:64910690c574 | 360 | |
AnnaBridge | 145:64910690c574 | 361 | /*! |
AnnaBridge | 145:64910690c574 | 362 | * @name Interrupts |
AnnaBridge | 145:64910690c574 | 363 | * @{ |
AnnaBridge | 145:64910690c574 | 364 | */ |
AnnaBridge | 145:64910690c574 | 365 | |
AnnaBridge | 145:64910690c574 | 366 | /*! |
AnnaBridge | 145:64910690c574 | 367 | * @brief Enables LPUART interrupts according to a provided mask. |
AnnaBridge | 145:64910690c574 | 368 | * |
AnnaBridge | 145:64910690c574 | 369 | * This function enables the LPUART interrupts according to a provided mask. The mask |
AnnaBridge | 145:64910690c574 | 370 | * is a logical OR of enumeration members. See the @ref _lpuart_interrupt_enable. |
AnnaBridge | 145:64910690c574 | 371 | * This examples shows how to enable TX empty interrupt and RX full interrupt: |
AnnaBridge | 145:64910690c574 | 372 | * @code |
AnnaBridge | 145:64910690c574 | 373 | * LPUART_EnableInterrupts(LPUART1,kLPUART_TxDataRegEmptyInterruptEnable | kLPUART_RxDataRegFullInterruptEnable); |
AnnaBridge | 145:64910690c574 | 374 | * @endcode |
AnnaBridge | 145:64910690c574 | 375 | * |
AnnaBridge | 145:64910690c574 | 376 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 377 | * @param mask The interrupts to enable. Logical OR of @ref _uart_interrupt_enable. |
AnnaBridge | 145:64910690c574 | 378 | */ |
AnnaBridge | 145:64910690c574 | 379 | void LPUART_EnableInterrupts(LPUART_Type *base, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 380 | |
AnnaBridge | 145:64910690c574 | 381 | /*! |
AnnaBridge | 145:64910690c574 | 382 | * @brief Disables LPUART interrupts according to a provided mask. |
AnnaBridge | 145:64910690c574 | 383 | * |
AnnaBridge | 145:64910690c574 | 384 | * This function disables the LPUART interrupts according to a provided mask. The mask |
AnnaBridge | 145:64910690c574 | 385 | * is a logical OR of enumeration members. See @ref _lpuart_interrupt_enable. |
AnnaBridge | 145:64910690c574 | 386 | * This example shows how to disable the TX empty interrupt and RX full interrupt: |
AnnaBridge | 145:64910690c574 | 387 | * @code |
AnnaBridge | 145:64910690c574 | 388 | * LPUART_DisableInterrupts(LPUART1,kLPUART_TxDataRegEmptyInterruptEnable | kLPUART_RxDataRegFullInterruptEnable); |
AnnaBridge | 145:64910690c574 | 389 | * @endcode |
AnnaBridge | 145:64910690c574 | 390 | * |
AnnaBridge | 145:64910690c574 | 391 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 392 | * @param mask The interrupts to disable. Logical OR of @ref _lpuart_interrupt_enable. |
AnnaBridge | 145:64910690c574 | 393 | */ |
AnnaBridge | 145:64910690c574 | 394 | void LPUART_DisableInterrupts(LPUART_Type *base, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 395 | |
AnnaBridge | 145:64910690c574 | 396 | /*! |
AnnaBridge | 145:64910690c574 | 397 | * @brief Gets enabled LPUART interrupts. |
AnnaBridge | 145:64910690c574 | 398 | * |
AnnaBridge | 145:64910690c574 | 399 | * This function gets the enabled LPUART interrupts. The enabled interrupts are returned |
AnnaBridge | 145:64910690c574 | 400 | * as the logical OR value of the enumerators @ref _lpuart_interrupt_enable. To check |
AnnaBridge | 145:64910690c574 | 401 | * a specific interrupt enable status, compare the return value with enumerators |
AnnaBridge | 145:64910690c574 | 402 | * in @ref _lpuart_interrupt_enable. |
AnnaBridge | 145:64910690c574 | 403 | * For example, to check whether the TX empty interrupt is enabled: |
AnnaBridge | 145:64910690c574 | 404 | * @code |
AnnaBridge | 145:64910690c574 | 405 | * uint32_t enabledInterrupts = LPUART_GetEnabledInterrupts(LPUART1); |
AnnaBridge | 145:64910690c574 | 406 | * |
AnnaBridge | 145:64910690c574 | 407 | * if (kLPUART_TxDataRegEmptyInterruptEnable & enabledInterrupts) |
AnnaBridge | 145:64910690c574 | 408 | * { |
AnnaBridge | 145:64910690c574 | 409 | * ... |
AnnaBridge | 145:64910690c574 | 410 | * } |
AnnaBridge | 145:64910690c574 | 411 | * @endcode |
AnnaBridge | 145:64910690c574 | 412 | * |
AnnaBridge | 145:64910690c574 | 413 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 414 | * @return LPUART interrupt flags which are logical OR of the enumerators in @ref _lpuart_interrupt_enable. |
AnnaBridge | 145:64910690c574 | 415 | */ |
AnnaBridge | 145:64910690c574 | 416 | uint32_t LPUART_GetEnabledInterrupts(LPUART_Type *base); |
AnnaBridge | 145:64910690c574 | 417 | |
AnnaBridge | 145:64910690c574 | 418 | #if defined(FSL_FEATURE_LPUART_HAS_DMA_ENABLE) && FSL_FEATURE_LPUART_HAS_DMA_ENABLE |
AnnaBridge | 145:64910690c574 | 419 | /*! |
AnnaBridge | 145:64910690c574 | 420 | * @brief Gets the LPUART data register address. |
AnnaBridge | 145:64910690c574 | 421 | * |
AnnaBridge | 145:64910690c574 | 422 | * This function returns the LPUART data register address, which is mainly used by the DMA/eDMA. |
AnnaBridge | 145:64910690c574 | 423 | * |
AnnaBridge | 145:64910690c574 | 424 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 425 | * @return LPUART data register addresses which are used both by the transmitter and receiver. |
AnnaBridge | 145:64910690c574 | 426 | */ |
AnnaBridge | 145:64910690c574 | 427 | static inline uint32_t LPUART_GetDataRegisterAddress(LPUART_Type *base) |
AnnaBridge | 145:64910690c574 | 428 | { |
AnnaBridge | 145:64910690c574 | 429 | return (uint32_t) & (base->DATA); |
AnnaBridge | 145:64910690c574 | 430 | } |
AnnaBridge | 145:64910690c574 | 431 | |
AnnaBridge | 145:64910690c574 | 432 | /*! |
AnnaBridge | 145:64910690c574 | 433 | * @brief Enables or disables the LPUART transmitter DMA request. |
AnnaBridge | 145:64910690c574 | 434 | * |
AnnaBridge | 145:64910690c574 | 435 | * This function enables or disables the transmit data register empty flag, STAT[TDRE], to generate DMA requests. |
AnnaBridge | 145:64910690c574 | 436 | * |
AnnaBridge | 145:64910690c574 | 437 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 438 | * @param enable True to enable, false to disable. |
AnnaBridge | 145:64910690c574 | 439 | */ |
AnnaBridge | 145:64910690c574 | 440 | static inline void LPUART_EnableTxDMA(LPUART_Type *base, bool enable) |
AnnaBridge | 145:64910690c574 | 441 | { |
AnnaBridge | 145:64910690c574 | 442 | if (enable) |
AnnaBridge | 145:64910690c574 | 443 | { |
AnnaBridge | 145:64910690c574 | 444 | base->BAUD |= LPUART_BAUD_TDMAE_MASK; |
AnnaBridge | 145:64910690c574 | 445 | base->CTRL |= LPUART_CTRL_TIE_MASK; |
AnnaBridge | 145:64910690c574 | 446 | } |
AnnaBridge | 145:64910690c574 | 447 | else |
AnnaBridge | 145:64910690c574 | 448 | { |
AnnaBridge | 145:64910690c574 | 449 | base->BAUD &= ~LPUART_BAUD_TDMAE_MASK; |
AnnaBridge | 145:64910690c574 | 450 | base->CTRL &= ~LPUART_CTRL_TIE_MASK; |
AnnaBridge | 145:64910690c574 | 451 | } |
AnnaBridge | 145:64910690c574 | 452 | } |
AnnaBridge | 145:64910690c574 | 453 | |
AnnaBridge | 145:64910690c574 | 454 | /*! |
AnnaBridge | 145:64910690c574 | 455 | * @brief Enables or disables the LPUART receiver DMA. |
AnnaBridge | 145:64910690c574 | 456 | * |
AnnaBridge | 145:64910690c574 | 457 | * This function enables or disables the receiver data register full flag, STAT[RDRF], to generate DMA requests. |
AnnaBridge | 145:64910690c574 | 458 | * |
AnnaBridge | 145:64910690c574 | 459 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 460 | * @param enable True to enable, false to disable. |
AnnaBridge | 145:64910690c574 | 461 | */ |
AnnaBridge | 145:64910690c574 | 462 | static inline void LPUART_EnableRxDMA(LPUART_Type *base, bool enable) |
AnnaBridge | 145:64910690c574 | 463 | { |
AnnaBridge | 145:64910690c574 | 464 | if (enable) |
AnnaBridge | 145:64910690c574 | 465 | { |
AnnaBridge | 145:64910690c574 | 466 | base->BAUD |= LPUART_BAUD_RDMAE_MASK; |
AnnaBridge | 145:64910690c574 | 467 | base->CTRL |= LPUART_CTRL_RIE_MASK; |
AnnaBridge | 145:64910690c574 | 468 | } |
AnnaBridge | 145:64910690c574 | 469 | else |
AnnaBridge | 145:64910690c574 | 470 | { |
AnnaBridge | 145:64910690c574 | 471 | base->BAUD &= ~LPUART_BAUD_RDMAE_MASK; |
AnnaBridge | 145:64910690c574 | 472 | base->CTRL &= ~LPUART_CTRL_RIE_MASK; |
AnnaBridge | 145:64910690c574 | 473 | } |
AnnaBridge | 145:64910690c574 | 474 | } |
AnnaBridge | 145:64910690c574 | 475 | |
AnnaBridge | 145:64910690c574 | 476 | /* @} */ |
AnnaBridge | 145:64910690c574 | 477 | #endif /* FSL_FEATURE_LPUART_HAS_DMA_ENABLE */ |
AnnaBridge | 145:64910690c574 | 478 | |
AnnaBridge | 145:64910690c574 | 479 | /*! |
AnnaBridge | 145:64910690c574 | 480 | * @name Bus Operations |
AnnaBridge | 145:64910690c574 | 481 | * @{ |
AnnaBridge | 145:64910690c574 | 482 | */ |
AnnaBridge | 145:64910690c574 | 483 | |
AnnaBridge | 145:64910690c574 | 484 | /*! |
AnnaBridge | 145:64910690c574 | 485 | * @brief Enables or disables the LPUART transmitter. |
AnnaBridge | 145:64910690c574 | 486 | * |
AnnaBridge | 145:64910690c574 | 487 | * This function enables or disables the LPUART transmitter. |
AnnaBridge | 145:64910690c574 | 488 | * |
AnnaBridge | 145:64910690c574 | 489 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 490 | * @param enable True to enable, false to disable. |
AnnaBridge | 145:64910690c574 | 491 | */ |
AnnaBridge | 145:64910690c574 | 492 | static inline void LPUART_EnableTx(LPUART_Type *base, bool enable) |
AnnaBridge | 145:64910690c574 | 493 | { |
AnnaBridge | 145:64910690c574 | 494 | if (enable) |
AnnaBridge | 145:64910690c574 | 495 | { |
AnnaBridge | 145:64910690c574 | 496 | base->CTRL |= LPUART_CTRL_TE_MASK; |
AnnaBridge | 145:64910690c574 | 497 | } |
AnnaBridge | 145:64910690c574 | 498 | else |
AnnaBridge | 145:64910690c574 | 499 | { |
AnnaBridge | 145:64910690c574 | 500 | base->CTRL &= ~LPUART_CTRL_TE_MASK; |
AnnaBridge | 145:64910690c574 | 501 | } |
AnnaBridge | 145:64910690c574 | 502 | } |
AnnaBridge | 145:64910690c574 | 503 | |
AnnaBridge | 145:64910690c574 | 504 | /*! |
AnnaBridge | 145:64910690c574 | 505 | * @brief Enables or disables the LPUART receiver. |
AnnaBridge | 145:64910690c574 | 506 | * |
AnnaBridge | 145:64910690c574 | 507 | * This function enables or disables the LPUART receiver. |
AnnaBridge | 145:64910690c574 | 508 | * |
AnnaBridge | 145:64910690c574 | 509 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 510 | * @param enable True to enable, false to disable. |
AnnaBridge | 145:64910690c574 | 511 | */ |
AnnaBridge | 145:64910690c574 | 512 | static inline void LPUART_EnableRx(LPUART_Type *base, bool enable) |
AnnaBridge | 145:64910690c574 | 513 | { |
AnnaBridge | 145:64910690c574 | 514 | if (enable) |
AnnaBridge | 145:64910690c574 | 515 | { |
AnnaBridge | 145:64910690c574 | 516 | base->CTRL |= LPUART_CTRL_RE_MASK; |
AnnaBridge | 145:64910690c574 | 517 | } |
AnnaBridge | 145:64910690c574 | 518 | else |
AnnaBridge | 145:64910690c574 | 519 | { |
AnnaBridge | 145:64910690c574 | 520 | base->CTRL &= ~LPUART_CTRL_RE_MASK; |
AnnaBridge | 145:64910690c574 | 521 | } |
AnnaBridge | 145:64910690c574 | 522 | } |
AnnaBridge | 145:64910690c574 | 523 | |
AnnaBridge | 145:64910690c574 | 524 | /*! |
AnnaBridge | 145:64910690c574 | 525 | * @brief Writes to the transmitter register. |
AnnaBridge | 145:64910690c574 | 526 | * |
AnnaBridge | 145:64910690c574 | 527 | * This function writes data to the transmitter register directly. The upper layer must |
AnnaBridge | 145:64910690c574 | 528 | * ensure that the TX register is empty or that the TX FIFO has room before calling this function. |
AnnaBridge | 145:64910690c574 | 529 | * |
AnnaBridge | 145:64910690c574 | 530 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 531 | * @param data Data write to the TX register. |
AnnaBridge | 145:64910690c574 | 532 | */ |
AnnaBridge | 145:64910690c574 | 533 | static inline void LPUART_WriteByte(LPUART_Type *base, uint8_t data) |
AnnaBridge | 145:64910690c574 | 534 | { |
AnnaBridge | 145:64910690c574 | 535 | base->DATA = data; |
AnnaBridge | 145:64910690c574 | 536 | } |
AnnaBridge | 145:64910690c574 | 537 | |
AnnaBridge | 145:64910690c574 | 538 | /*! |
AnnaBridge | 145:64910690c574 | 539 | * @brief Reads the RX register. |
AnnaBridge | 145:64910690c574 | 540 | * |
AnnaBridge | 145:64910690c574 | 541 | * This function reads data from the receiver register directly. The upper layer must |
AnnaBridge | 145:64910690c574 | 542 | * ensure that the RX register is full or that the RX FIFO has data before calling this function. |
AnnaBridge | 145:64910690c574 | 543 | * |
AnnaBridge | 145:64910690c574 | 544 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 545 | * @return Data read from data register. |
AnnaBridge | 145:64910690c574 | 546 | */ |
AnnaBridge | 145:64910690c574 | 547 | static inline uint8_t LPUART_ReadByte(LPUART_Type *base) |
AnnaBridge | 145:64910690c574 | 548 | { |
AnnaBridge | 145:64910690c574 | 549 | #if defined(FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT) && FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT |
AnnaBridge | 145:64910690c574 | 550 | uint32_t ctrl = base->CTRL; |
AnnaBridge | 145:64910690c574 | 551 | bool isSevenDataBits = ((ctrl & LPUART_CTRL_M7_MASK) || |
AnnaBridge | 145:64910690c574 | 552 | ((!(ctrl & LPUART_CTRL_M7_MASK)) && (!(ctrl & LPUART_CTRL_M_MASK)) && (ctrl & LPUART_CTRL_PE_MASK))); |
AnnaBridge | 145:64910690c574 | 553 | |
AnnaBridge | 145:64910690c574 | 554 | if (isSevenDataBits) |
AnnaBridge | 145:64910690c574 | 555 | { |
AnnaBridge | 145:64910690c574 | 556 | return (base->DATA & 0x7F); |
AnnaBridge | 145:64910690c574 | 557 | } |
AnnaBridge | 145:64910690c574 | 558 | else |
AnnaBridge | 145:64910690c574 | 559 | { |
AnnaBridge | 145:64910690c574 | 560 | return base->DATA; |
AnnaBridge | 145:64910690c574 | 561 | } |
AnnaBridge | 145:64910690c574 | 562 | #else |
AnnaBridge | 145:64910690c574 | 563 | return base->DATA; |
AnnaBridge | 145:64910690c574 | 564 | #endif |
AnnaBridge | 145:64910690c574 | 565 | } |
AnnaBridge | 145:64910690c574 | 566 | |
AnnaBridge | 145:64910690c574 | 567 | /*! |
AnnaBridge | 145:64910690c574 | 568 | * @brief Writes to transmitter register using a blocking method. |
AnnaBridge | 145:64910690c574 | 569 | * |
AnnaBridge | 145:64910690c574 | 570 | * This function polls the transmitter register, waits for the register to be empty or for TX FIFO to have |
AnnaBridge | 145:64910690c574 | 571 | * room and then writes data to the transmitter buffer. |
AnnaBridge | 145:64910690c574 | 572 | * |
AnnaBridge | 145:64910690c574 | 573 | * @note This function does not check whether all data has been sent out to the bus. |
AnnaBridge | 145:64910690c574 | 574 | * Before disabling the transmitter, check the kLPUART_TransmissionCompleteFlag to ensure that the transmit is |
AnnaBridge | 145:64910690c574 | 575 | * finished. |
AnnaBridge | 145:64910690c574 | 576 | * |
AnnaBridge | 145:64910690c574 | 577 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 578 | * @param data Start address of the data to write. |
AnnaBridge | 145:64910690c574 | 579 | * @param length Size of the data to write. |
AnnaBridge | 145:64910690c574 | 580 | */ |
AnnaBridge | 145:64910690c574 | 581 | void LPUART_WriteBlocking(LPUART_Type *base, const uint8_t *data, size_t length); |
AnnaBridge | 145:64910690c574 | 582 | |
AnnaBridge | 145:64910690c574 | 583 | /*! |
AnnaBridge | 145:64910690c574 | 584 | * @brief Reads the RX data register using a blocking method. |
AnnaBridge | 145:64910690c574 | 585 | * |
AnnaBridge | 145:64910690c574 | 586 | * This function polls the RX register, waits for the RX register full or RX FIFO |
AnnaBridge | 145:64910690c574 | 587 | * has data then reads data from the TX register. |
AnnaBridge | 145:64910690c574 | 588 | * |
AnnaBridge | 145:64910690c574 | 589 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 590 | * @param data Start address of the buffer to store the received data. |
AnnaBridge | 145:64910690c574 | 591 | * @param length Size of the buffer. |
AnnaBridge | 145:64910690c574 | 592 | * @retval kStatus_LPUART_RxHardwareOverrun Receiver overrun happened while receiving data. |
AnnaBridge | 145:64910690c574 | 593 | * @retval kStatus_LPUART_NoiseError Noise error happened while receiving data. |
AnnaBridge | 145:64910690c574 | 594 | * @retval kStatus_LPUART_FramingError Framing error happened while receiving data. |
AnnaBridge | 145:64910690c574 | 595 | * @retval kStatus_LPUART_ParityError Parity error happened while receiving data. |
AnnaBridge | 145:64910690c574 | 596 | * @retval kStatus_Success Successfully received all data. |
AnnaBridge | 145:64910690c574 | 597 | */ |
AnnaBridge | 145:64910690c574 | 598 | status_t LPUART_ReadBlocking(LPUART_Type *base, uint8_t *data, size_t length); |
AnnaBridge | 145:64910690c574 | 599 | |
AnnaBridge | 145:64910690c574 | 600 | /* @} */ |
AnnaBridge | 145:64910690c574 | 601 | |
AnnaBridge | 145:64910690c574 | 602 | /*! |
AnnaBridge | 145:64910690c574 | 603 | * @name Transactional |
AnnaBridge | 145:64910690c574 | 604 | * @{ |
AnnaBridge | 145:64910690c574 | 605 | */ |
AnnaBridge | 145:64910690c574 | 606 | |
AnnaBridge | 145:64910690c574 | 607 | /*! |
AnnaBridge | 145:64910690c574 | 608 | * @brief Initializes the LPUART handle. |
AnnaBridge | 145:64910690c574 | 609 | * |
AnnaBridge | 145:64910690c574 | 610 | * This function initializes the LPUART handle, which can be used for other LPUART |
AnnaBridge | 145:64910690c574 | 611 | * transactional APIs. Usually, for a specified LPUART instance, |
AnnaBridge | 145:64910690c574 | 612 | * call this API once to get the initialized handle. |
AnnaBridge | 145:64910690c574 | 613 | * |
AnnaBridge | 145:64910690c574 | 614 | * The LPUART driver supports the "background" receiving, which means that user can set up |
AnnaBridge | 145:64910690c574 | 615 | * an RX ring buffer optionally. Data received is stored into the ring buffer even when the |
AnnaBridge | 145:64910690c574 | 616 | * user doesn't call the LPUART_TransferReceiveNonBlocking() API. If there is already data received |
AnnaBridge | 145:64910690c574 | 617 | * in the ring buffer, the user can get the received data from the ring buffer directly. |
AnnaBridge | 145:64910690c574 | 618 | * The ring buffer is disabled if passing NULL as @p ringBuffer. |
AnnaBridge | 145:64910690c574 | 619 | * |
AnnaBridge | 145:64910690c574 | 620 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 621 | * @param handle LPUART handle pointer. |
AnnaBridge | 145:64910690c574 | 622 | * @param callback Callback function. |
AnnaBridge | 145:64910690c574 | 623 | * @param userData User data. |
AnnaBridge | 145:64910690c574 | 624 | */ |
AnnaBridge | 145:64910690c574 | 625 | void LPUART_TransferCreateHandle(LPUART_Type *base, |
AnnaBridge | 145:64910690c574 | 626 | lpuart_handle_t *handle, |
AnnaBridge | 145:64910690c574 | 627 | lpuart_transfer_callback_t callback, |
AnnaBridge | 145:64910690c574 | 628 | void *userData); |
AnnaBridge | 145:64910690c574 | 629 | /*! |
AnnaBridge | 145:64910690c574 | 630 | * @brief Transmits a buffer of data using the interrupt method. |
AnnaBridge | 145:64910690c574 | 631 | * |
AnnaBridge | 145:64910690c574 | 632 | * This function send data using an interrupt method. This is a non-blocking function, which |
AnnaBridge | 145:64910690c574 | 633 | * returns directly without waiting for all data written to the transmitter register. When |
AnnaBridge | 145:64910690c574 | 634 | * all data is written to the TX register in the ISR, the LPUART driver calls the callback |
AnnaBridge | 145:64910690c574 | 635 | * function and passes the @ref kStatus_LPUART_TxIdle as status parameter. |
AnnaBridge | 145:64910690c574 | 636 | * |
AnnaBridge | 145:64910690c574 | 637 | * @note The kStatus_LPUART_TxIdle is passed to the upper layer when all data are written |
AnnaBridge | 145:64910690c574 | 638 | * to the TX register. However, there is no check to ensure that all the data sent out. Before disabling the TX, |
AnnaBridge | 145:64910690c574 | 639 | * check the kLPUART_TransmissionCompleteFlag to ensure that the transmit is finished. |
AnnaBridge | 145:64910690c574 | 640 | * |
AnnaBridge | 145:64910690c574 | 641 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 642 | * @param handle LPUART handle pointer. |
AnnaBridge | 145:64910690c574 | 643 | * @param xfer LPUART transfer structure, see #lpuart_transfer_t. |
AnnaBridge | 145:64910690c574 | 644 | * @retval kStatus_Success Successfully start the data transmission. |
AnnaBridge | 145:64910690c574 | 645 | * @retval kStatus_LPUART_TxBusy Previous transmission still not finished, data not all written to the TX register. |
AnnaBridge | 145:64910690c574 | 646 | * @retval kStatus_InvalidArgument Invalid argument. |
AnnaBridge | 145:64910690c574 | 647 | */ |
AnnaBridge | 145:64910690c574 | 648 | status_t LPUART_TransferSendNonBlocking(LPUART_Type *base, lpuart_handle_t *handle, lpuart_transfer_t *xfer); |
AnnaBridge | 145:64910690c574 | 649 | |
AnnaBridge | 145:64910690c574 | 650 | /*! |
AnnaBridge | 145:64910690c574 | 651 | * @brief Sets up the RX ring buffer. |
AnnaBridge | 145:64910690c574 | 652 | * |
AnnaBridge | 145:64910690c574 | 653 | * This function sets up the RX ring buffer to a specific UART handle. |
AnnaBridge | 145:64910690c574 | 654 | * |
AnnaBridge | 145:64910690c574 | 655 | * When the RX ring buffer is used, data received is stored into the ring buffer even when |
AnnaBridge | 145:64910690c574 | 656 | * the user doesn't call the UART_TransferReceiveNonBlocking() API. If there is already data received |
AnnaBridge | 145:64910690c574 | 657 | * in the ring buffer, the user can get the received data from the ring buffer directly. |
AnnaBridge | 145:64910690c574 | 658 | * |
AnnaBridge | 145:64910690c574 | 659 | * @note When using RX ring buffer, one byte is reserved for internal use. In other |
AnnaBridge | 145:64910690c574 | 660 | * words, if @p ringBufferSize is 32, then only 31 bytes are used for saving data. |
AnnaBridge | 145:64910690c574 | 661 | * |
AnnaBridge | 145:64910690c574 | 662 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 663 | * @param handle LPUART handle pointer. |
AnnaBridge | 145:64910690c574 | 664 | * @param ringBuffer Start address of ring buffer for background receiving. Pass NULL to disable the ring buffer. |
AnnaBridge | 145:64910690c574 | 665 | * @param ringBufferSize size of the ring buffer. |
AnnaBridge | 145:64910690c574 | 666 | */ |
AnnaBridge | 145:64910690c574 | 667 | void LPUART_TransferStartRingBuffer(LPUART_Type *base, |
AnnaBridge | 145:64910690c574 | 668 | lpuart_handle_t *handle, |
AnnaBridge | 145:64910690c574 | 669 | uint8_t *ringBuffer, |
AnnaBridge | 145:64910690c574 | 670 | size_t ringBufferSize); |
AnnaBridge | 145:64910690c574 | 671 | |
AnnaBridge | 145:64910690c574 | 672 | /*! |
AnnaBridge | 145:64910690c574 | 673 | * @brief Abort the background transfer and uninstall the ring buffer. |
AnnaBridge | 145:64910690c574 | 674 | * |
AnnaBridge | 145:64910690c574 | 675 | * This function aborts the background transfer and uninstalls the ring buffer. |
AnnaBridge | 145:64910690c574 | 676 | * |
AnnaBridge | 145:64910690c574 | 677 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 678 | * @param handle LPUART handle pointer. |
AnnaBridge | 145:64910690c574 | 679 | */ |
AnnaBridge | 145:64910690c574 | 680 | void LPUART_TransferStopRingBuffer(LPUART_Type *base, lpuart_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 681 | |
AnnaBridge | 145:64910690c574 | 682 | /*! |
AnnaBridge | 145:64910690c574 | 683 | * @brief Aborts the interrupt-driven data transmit. |
AnnaBridge | 145:64910690c574 | 684 | * |
AnnaBridge | 145:64910690c574 | 685 | * This function aborts the interrupt driven data sending. The user can get the remainBtyes to find out |
AnnaBridge | 145:64910690c574 | 686 | * how many bytes are still not sent out. |
AnnaBridge | 145:64910690c574 | 687 | * |
AnnaBridge | 145:64910690c574 | 688 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 689 | * @param handle LPUART handle pointer. |
AnnaBridge | 145:64910690c574 | 690 | */ |
AnnaBridge | 145:64910690c574 | 691 | void LPUART_TransferAbortSend(LPUART_Type *base, lpuart_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 692 | |
AnnaBridge | 145:64910690c574 | 693 | /*! |
AnnaBridge | 145:64910690c574 | 694 | * @brief Get the number of bytes that have been written to LPUART TX register. |
AnnaBridge | 145:64910690c574 | 695 | * |
AnnaBridge | 145:64910690c574 | 696 | * This function gets the number of bytes that have been written to LPUART TX |
AnnaBridge | 145:64910690c574 | 697 | * register by interrupt method. |
AnnaBridge | 145:64910690c574 | 698 | * |
AnnaBridge | 145:64910690c574 | 699 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 700 | * @param handle LPUART handle pointer. |
AnnaBridge | 145:64910690c574 | 701 | * @param count Send bytes count. |
AnnaBridge | 145:64910690c574 | 702 | * @retval kStatus_NoTransferInProgress No send in progress. |
AnnaBridge | 145:64910690c574 | 703 | * @retval kStatus_InvalidArgument Parameter is invalid. |
AnnaBridge | 145:64910690c574 | 704 | * @retval kStatus_Success Get successfully through the parameter \p count; |
AnnaBridge | 145:64910690c574 | 705 | */ |
AnnaBridge | 145:64910690c574 | 706 | status_t LPUART_TransferGetSendCount(LPUART_Type *base, lpuart_handle_t *handle, uint32_t *count); |
AnnaBridge | 145:64910690c574 | 707 | |
AnnaBridge | 145:64910690c574 | 708 | /*! |
AnnaBridge | 145:64910690c574 | 709 | * @brief Receives a buffer of data using the interrupt method. |
AnnaBridge | 145:64910690c574 | 710 | * |
AnnaBridge | 145:64910690c574 | 711 | * This function receives data using an interrupt method. This is a non-blocking function |
AnnaBridge | 145:64910690c574 | 712 | * which returns without waiting to ensure that all data are received. |
AnnaBridge | 145:64910690c574 | 713 | * If the RX ring buffer is used and not empty, the data in the ring buffer is copied and |
AnnaBridge | 145:64910690c574 | 714 | * the parameter @p receivedBytes shows how many bytes are copied from the ring buffer. |
AnnaBridge | 145:64910690c574 | 715 | * After copying, if the data in the ring buffer is not enough for read, the receive |
AnnaBridge | 145:64910690c574 | 716 | * request is saved by the LPUART driver. When the new data arrives, the receive request |
AnnaBridge | 145:64910690c574 | 717 | * is serviced first. When all data is received, the LPUART driver notifies the upper layer |
AnnaBridge | 145:64910690c574 | 718 | * through a callback function and passes a status parameter @ref kStatus_UART_RxIdle. |
AnnaBridge | 145:64910690c574 | 719 | * For example, the upper layer needs 10 bytes but there are only 5 bytes in ring buffer. |
AnnaBridge | 145:64910690c574 | 720 | * The 5 bytes are copied to xfer->data, which returns with the |
AnnaBridge | 145:64910690c574 | 721 | * parameter @p receivedBytes set to 5. For the remaining 5 bytes, the newly arrived data is |
AnnaBridge | 145:64910690c574 | 722 | * saved from xfer->data[5]. When 5 bytes are received, the LPUART driver notifies the upper layer. |
AnnaBridge | 145:64910690c574 | 723 | * If the RX ring buffer is not enabled, this function enables the RX and RX interrupt |
AnnaBridge | 145:64910690c574 | 724 | * to receive data to xfer->data. When all data is received, the upper layer is notified. |
AnnaBridge | 145:64910690c574 | 725 | * |
AnnaBridge | 145:64910690c574 | 726 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 727 | * @param handle LPUART handle pointer. |
AnnaBridge | 145:64910690c574 | 728 | * @param xfer LPUART transfer structure, see #uart_transfer_t. |
AnnaBridge | 145:64910690c574 | 729 | * @param receivedBytes Bytes received from the ring buffer directly. |
AnnaBridge | 145:64910690c574 | 730 | * @retval kStatus_Success Successfully queue the transfer into the transmit queue. |
AnnaBridge | 145:64910690c574 | 731 | * @retval kStatus_LPUART_RxBusy Previous receive request is not finished. |
AnnaBridge | 145:64910690c574 | 732 | * @retval kStatus_InvalidArgument Invalid argument. |
AnnaBridge | 145:64910690c574 | 733 | */ |
AnnaBridge | 145:64910690c574 | 734 | status_t LPUART_TransferReceiveNonBlocking(LPUART_Type *base, |
AnnaBridge | 145:64910690c574 | 735 | lpuart_handle_t *handle, |
AnnaBridge | 145:64910690c574 | 736 | lpuart_transfer_t *xfer, |
AnnaBridge | 145:64910690c574 | 737 | size_t *receivedBytes); |
AnnaBridge | 145:64910690c574 | 738 | |
AnnaBridge | 145:64910690c574 | 739 | /*! |
AnnaBridge | 145:64910690c574 | 740 | * @brief Aborts the interrupt-driven data receiving. |
AnnaBridge | 145:64910690c574 | 741 | * |
AnnaBridge | 145:64910690c574 | 742 | * This function aborts the interrupt-driven data receiving. The user can get the remainBytes to find out |
AnnaBridge | 145:64910690c574 | 743 | * how many bytes not received yet. |
AnnaBridge | 145:64910690c574 | 744 | * |
AnnaBridge | 145:64910690c574 | 745 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 746 | * @param handle LPUART handle pointer. |
AnnaBridge | 145:64910690c574 | 747 | */ |
AnnaBridge | 145:64910690c574 | 748 | void LPUART_TransferAbortReceive(LPUART_Type *base, lpuart_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 749 | |
AnnaBridge | 145:64910690c574 | 750 | /*! |
AnnaBridge | 145:64910690c574 | 751 | * @brief Get the number of bytes that have been received. |
AnnaBridge | 145:64910690c574 | 752 | * |
AnnaBridge | 145:64910690c574 | 753 | * This function gets the number of bytes that have been received. |
AnnaBridge | 145:64910690c574 | 754 | * |
AnnaBridge | 145:64910690c574 | 755 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 756 | * @param handle LPUART handle pointer. |
AnnaBridge | 145:64910690c574 | 757 | * @param count Receive bytes count. |
AnnaBridge | 145:64910690c574 | 758 | * @retval kStatus_NoTransferInProgress No receive in progress. |
AnnaBridge | 145:64910690c574 | 759 | * @retval kStatus_InvalidArgument Parameter is invalid. |
AnnaBridge | 145:64910690c574 | 760 | * @retval kStatus_Success Get successfully through the parameter \p count; |
AnnaBridge | 145:64910690c574 | 761 | */ |
AnnaBridge | 145:64910690c574 | 762 | status_t LPUART_TransferGetReceiveCount(LPUART_Type *base, lpuart_handle_t *handle, uint32_t *count); |
AnnaBridge | 145:64910690c574 | 763 | |
AnnaBridge | 145:64910690c574 | 764 | /*! |
AnnaBridge | 145:64910690c574 | 765 | * @brief LPUART IRQ handle function. |
AnnaBridge | 145:64910690c574 | 766 | * |
AnnaBridge | 145:64910690c574 | 767 | * This function handles the LPUART transmit and receive IRQ request. |
AnnaBridge | 145:64910690c574 | 768 | * |
AnnaBridge | 145:64910690c574 | 769 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 770 | * @param handle LPUART handle pointer. |
AnnaBridge | 145:64910690c574 | 771 | */ |
AnnaBridge | 145:64910690c574 | 772 | void LPUART_TransferHandleIRQ(LPUART_Type *base, lpuart_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 773 | |
AnnaBridge | 145:64910690c574 | 774 | /*! |
AnnaBridge | 145:64910690c574 | 775 | * @brief LPUART Error IRQ handle function. |
AnnaBridge | 145:64910690c574 | 776 | * |
AnnaBridge | 145:64910690c574 | 777 | * This function handles the LPUART error IRQ request. |
AnnaBridge | 145:64910690c574 | 778 | * |
AnnaBridge | 145:64910690c574 | 779 | * @param base LPUART peripheral base address. |
AnnaBridge | 145:64910690c574 | 780 | * @param handle LPUART handle pointer. |
AnnaBridge | 145:64910690c574 | 781 | */ |
AnnaBridge | 145:64910690c574 | 782 | void LPUART_TransferHandleErrorIRQ(LPUART_Type *base, lpuart_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 783 | |
AnnaBridge | 145:64910690c574 | 784 | /* @} */ |
AnnaBridge | 145:64910690c574 | 785 | |
AnnaBridge | 145:64910690c574 | 786 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 787 | } |
AnnaBridge | 145:64910690c574 | 788 | #endif |
AnnaBridge | 145:64910690c574 | 789 | |
AnnaBridge | 145:64910690c574 | 790 | /*! @}*/ |
AnnaBridge | 145:64910690c574 | 791 | |
AnnaBridge | 145:64910690c574 | 792 | #endif /* _FSL_LPUART_H_ */ |