Gordon Craig / mbed-dev

Fork of mbed-dev by mbed official

Committer:
Dollyparton
Date:
Tue Dec 19 12:50:13 2017 +0000
Revision:
174:ed647f63e28d
Parent:
154:37f96f9d4de2
Added RAW socket.

Who changed what in which revision?

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