Go to the documentation of this file.
25 #define FSL_LPUART_DRIVER_VERSION (MAKE_VERSION(2, 3, 0))
29 #ifndef UART_RETRY_TIMES
30 #define UART_RETRY_TIMES 0U
68 #if defined(FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT) && FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT
69 kLPUART_SevenDataBits = 0x1U,
80 #if defined(FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT) && FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT
82 typedef enum _lpuart_transmit_cts_source
84 kLPUART_CtsSourcePin = 0U,
85 kLPUART_CtsSourceMatchResult = 1U,
86 } lpuart_transmit_cts_source_t;
89 typedef enum _lpuart_transmit_cts_config
91 kLPUART_CtsSampleAtStart = 0U,
92 kLPUART_CtsSampleAtIdle = 1U,
93 } lpuart_transmit_cts_config_t;
126 #if defined(FSL_FEATURE_LPUART_HAS_LIN_BREAK_DETECT) && FSL_FEATURE_LPUART_HAS_LIN_BREAK_DETECT
138 #if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
165 #if defined(FSL_FEATURE_LPUART_HAS_LIN_BREAK_DETECT) && FSL_FEATURE_LPUART_HAS_LIN_BREAK_DETECT
173 #if defined(FSL_FEATURE_LPUART_HAS_ADDRESS_MATCHING) && FSL_FEATURE_LPUART_HAS_ADDRESS_MATCHING
177 #if defined(FSL_FEATURE_LPUART_HAS_EXTENDED_DATA_REGISTER_FLAGS) && FSL_FEATURE_LPUART_HAS_EXTENDED_DATA_REGISTER_FLAGS
178 kLPUART_NoiseErrorInRxDataRegFlag =
180 kLPUART_ParityErrorInRxDataRegFlag =
183 #if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
186 kLPUART_TxFifoOverflowFlag =
188 kLPUART_RxFifoUnderflowFlag =
200 #if defined(FSL_FEATURE_LPUART_HAS_STOP_BIT_CONFIG_SUPPORT) && FSL_FEATURE_LPUART_HAS_STOP_BIT_CONFIG_SUPPORT
203 #if defined(FSL_FEATURE_LPUART_HAS_FIFO) && FSL_FEATURE_LPUART_HAS_FIFO
204 uint8_t txFifoWatermark;
205 uint8_t rxFifoWatermark;
207 #if defined(FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT) && FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT
210 lpuart_transmit_cts_source_t txCtsSource;
211 lpuart_transmit_cts_config_t txCtsConfig;
253 #if defined(FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT) && FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT
254 bool isSevenDataBits;
262 #if defined(__cplusplus)
266 #if defined(FSL_FEATURE_LPUART_HAS_GLOBAL) && FSL_FEATURE_LPUART_HAS_GLOBAL
281 static inline void LPUART_SoftwareReset(
LPUART_Type *base)
473 #if defined(FSL_FEATURE_LPUART_HAS_DMA_ENABLE) && FSL_FEATURE_LPUART_HAS_DMA_ENABLE
482 static inline uint32_t LPUART_GetDataRegisterAddress(
LPUART_Type *base)
484 return (uint32_t) & (base->
DATA);
495 static inline void LPUART_EnableTxDMA(
LPUART_Type *base,
bool enable)
515 static inline void LPUART_EnableRxDMA(
LPUART_Type *base,
bool enable)
608 #if defined(FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT) && FSL_FEATURE_LPUART_HAS_7BIT_DATA_SUPPORT
609 uint32_t ctrl = base->
CTRL;
617 result = (uint8_t)(base->
DATA & 0x7FU);
621 result = (uint8_t)base->
DATA;
626 return (uint8_t)(base->
DATA);
732 size_t ringBufferSize);
807 size_t *receivedBytes);
856 #if defined(__cplusplus)
size_t LPUART_TransferGetRxRingBufferLength(LPUART_Type *base, lpuart_handle_t *handle)
Get the length of received data in RX ring buffer.
@ kLPUART_TransmissionCompleteInterruptEnable
_lpuart_interrupt_enable
LPUART interrupt configuration structure, default settings all disabled.
@ kLPUART_IdleCharacter128
@ kStatus_LPUART_FramingError
enum _lpuart_parity_mode lpuart_parity_mode_t
LPUART parity mode.
@ kStatus_LPUART_NoiseError
#define LPUART_BAUD_LBKDIE_MASK
@ kStatus_LPUART_RxWatermarkTooLarge
_lpuart_idle_type_select
LPUART idle flag type defines when the receiver starts counting.
void LPUART_TransferHandleIRQ(LPUART_Type *base, lpuart_handle_t *handle)
LPUART IRQ handle function.
uint32_t LPUART_GetInstance(LPUART_Type *base)
Get the LPUART instance from peripheral base address.
#define LPUART_STAT_OR_MASK
#define LPUART_STAT_RAF_MASK
lpuart_data_bits_t dataBitsCount
status_t LPUART_SetBaudRate(LPUART_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz)
Sets the LPUART instance baudrate.
lpuart_parity_mode_t parityMode
#define LPUART_CTRL_RIE_MASK
struct _lpuart_transfer lpuart_transfer_t
LPUART transfer structure.
@ kStatus_LPUART_TxWatermarkTooLarge
@ kLPUART_IdleCharacter16
#define LPUART_CTRL_PE_MASK
volatile uint16_t rxRingBufferTail
status_t LPUART_TransferReceiveNonBlocking(LPUART_Type *base, lpuart_handle_t *handle, lpuart_transfer_t *xfer, size_t *receivedBytes)
Receives a buffer of data using the interrupt method.
@ kLPUART_FramingErrorInterruptEnable
static uint8_t LPUART_ReadByte(LPUART_Type *base)
Reads the receiver register.
@ kLPUART_TxDataRegEmptyFlag
#define LPUART_CTRL_TIE_MASK
@ kLPUART_NoiseErrorInterruptEnable
LPUART transfer structure.
void LPUART_EnableInterrupts(LPUART_Type *base, uint32_t mask)
Enables LPUART interrupts according to a provided mask.
void LPUART_TransferStopRingBuffer(LPUART_Type *base, lpuart_handle_t *handle)
Aborts the background transfer and uninstalls the ring buffer.
@ kLPUART_RxActiveEdgeInterruptEnable
#define LPUART_CTRL_FEIE_MASK
void LPUART_TransferAbortReceive(LPUART_Type *base, lpuart_handle_t *handle)
Aborts the interrupt-driven data receiving.
static void LPUART_EnableTx(LPUART_Type *base, bool enable)
Enables or disables the LPUART transmitter.
#define LPUART_STAT_LBKDIF_MASK
status_t LPUART_ReadBlocking(LPUART_Type *base, uint8_t *data, size_t length)
Reads the receiver data register using a blocking method.
enum _lpuart_idle_type_select lpuart_idle_type_select_t
LPUART idle flag type defines when the receiver starts counting.
static void LPUART_EnableRx(LPUART_Type *base, bool enable)
Enables or disables the LPUART receiver.
@ kLPUART_IdleTypeStartBit
void LPUART_DisableInterrupts(LPUART_Type *base, uint32_t mask)
Disables LPUART interrupts according to a provided mask.
_lpuart_stop_bit_count
LPUART stop bit count.
@ kLPUART_ParityErrorFlag
#define LPUART_BAUD_RDMAE_MASK
_lpuart_idle_config
LPUART idle detected configuration. This structure defines the number of idle characters that must be...
void LPUART_GetDefaultConfig(lpuart_config_t *config)
Gets the default configuration structure.
_lpuart_parity_mode
LPUART parity mode.
struct _lpuart_config lpuart_config_t
LPUART configuration structure.
#define LPUART_STAT_IDLE_MASK
void(* lpuart_transfer_callback_t)(LPUART_Type *base, lpuart_handle_t *handle, status_t status, void *userData)
LPUART transfer callback function.
#define MAKE_STATUS(group, code)
Construct a status code value from a group and code number.
#define LPUART_FIFO_TXOFE_MASK
lpuart_transfer_callback_t callback
void LPUART_TransferHandleErrorIRQ(LPUART_Type *base, lpuart_handle_t *handle)
LPUART Error IRQ handle function.
#define LPUART_STAT_FE_MASK
@ kLPUART_TxDataRegEmptyInterruptEnable
status_t LPUART_TransferGetSendCount(LPUART_Type *base, lpuart_handle_t *handle, uint32_t *count)
Gets the number of bytes that have been sent out to bus.
@ kStatus_LPUART_RxHardwareOverrun
#define LPUART_STAT_TDRE_MASK
#define LPUART_CTRL_RE_MASK
#define LPUART_GLOBAL_RST_MASK
#define LPUART_CTRL_TE_MASK
#define LPUART_FIFO_RXUFE_MASK
#define LPUART_STAT_TC_MASK
void LPUART_TransferStartRingBuffer(LPUART_Type *base, lpuart_handle_t *handle, uint8_t *ringBuffer, size_t ringBufferSize)
Sets up the RX ring buffer.
#define LPUART_STAT_PF_MASK
uint32_t LPUART_GetEnabledInterrupts(LPUART_Type *base)
Gets enabled LPUART interrupts.
#define LPUART_FIFO_RXEMPT_MASK
volatile size_t rxDataSize
enum _lpuart_stop_bit_count lpuart_stop_bit_count_t
LPUART stop bit count.
#define LPUART_CTRL_M7_MASK
status_t LPUART_WriteBlocking(LPUART_Type *base, const uint8_t *data, size_t length)
Writes to the transmitter register using a blocking method.
enum _lpuart_data_bits lpuart_data_bits_t
LPUART data bits count.
_lpuart_data_bits
LPUART data bits count.
@ kLPUART_RxDataRegFullFlag
LPUART configuration structure.
@ kStatus_LPUART_ParityError
enum _lpuart_idle_config lpuart_idle_config_t
LPUART idle detected configuration. This structure defines the number of idle characters that must be...
status_t LPUART_Init(LPUART_Type *base, const lpuart_config_t *config, uint32_t srcClock_Hz)
Initializes an LPUART instance with the user configuration structure and the peripheral clock.
#define LPUART_STAT_NF_MASK
#define LPUART_BAUD_TDMAE_MASK
status_t LPUART_TransferSendNonBlocking(LPUART_Type *base, lpuart_handle_t *handle, lpuart_transfer_t *xfer)
Transmits a buffer of data using the interrupt method.
@ kLPUART_RxOverrunInterruptEnable
#define LPUART_CTRL_NEIE_MASK
#define LPUART_DATA_PARITYE_MASK
#define LPUART_CTRL_ILIE_MASK
@ kStatus_LPUART_RxRingBufferOverrun
@ kLPUART_FramingErrorFlag
#define LPUART_DATA_NOISY_MASK
_lpuart_flags
LPUART status flags.
@ kLPUART_IdleTypeStopBit
#define LPUART_FIFO_RXUF_MASK
#define LPUART_STAT_MA2F_MASK
@ kStatus_LPUART_BaudrateNotSupport
lpuart_idle_config_t rxIdleConfig
status_t LPUART_ClearStatusFlags(LPUART_Type *base, uint32_t mask)
Clears status flags with a provided mask.
#define LPUART_CTRL_M_MASK
#define LPUART_CTRL_ORIE_MASK
#define LPUART_STAT_MA1F_MASK
#define LPUART_FIFO_TXEMPT_MASK
@ kStatus_LPUART_IdleLineDetected
lpuart_idle_type_select_t rxIdleType
#define LPUART_FIFO_TXOF_MASK
volatile uint16_t rxRingBufferHead
static void LPUART_WriteByte(LPUART_Type *base, uint8_t data)
Writes to the transmitter register.
static sai_transceiver_t config
status_t LPUART_TransferGetReceiveCount(LPUART_Type *base, lpuart_handle_t *handle, uint32_t *count)
Gets the number of bytes that have been received.
uint32_t LPUART_GetStatusFlags(LPUART_Type *base)
Gets LPUART status flags.
@ kLPUART_IdleCharacter32
@ kStatus_LPUART_FlagCannotClearManually
@ kLPUART_ParityErrorInterruptEnable
@ kLPUART_TransmissionCompleteFlag
@ kLPUART_IdleCharacter64
#define LPUART_STAT_RXEDGIF_MASK
volatile size_t txDataSize
#define LPUART_CTRL_PEIE_MASK
int32_t status_t
Type used for all status and error return values.
#define LPUART_CTRL_TCIE_MASK
void LPUART_TransferCreateHandle(LPUART_Type *base, lpuart_handle_t *handle, lpuart_transfer_callback_t callback, void *userData)
Initializes the LPUART handle.
@ kLPUART_RxActiveEdgeFlag
void LPUART_TransferAbortSend(LPUART_Type *base, lpuart_handle_t *handle)
Aborts the interrupt-driven data transmit.
@ kLPUART_RxDataRegFullInterruptEnable
@ kLPUART_IdleLineInterruptEnable
void LPUART_Deinit(LPUART_Type *base)
Deinitializes a LPUART instance.
#define LPUART_BAUD_RXEDGIE_MASK
#define LPUART_STAT_RDRF_MASK