RTEMS 6.1-rc6
|
Data Structures | |
struct | _lpuart_config |
LPUART configuration structure. More... | |
struct | _lpuart_transfer |
LPUART transfer structure. More... | |
struct | _lpuart_handle |
LPUART handle structure. More... | |
Driver version | |
enum | { kStatus_LPUART_TxBusy = MAKE_STATUS(kStatusGroup_LPUART, 0) , kStatus_LPUART_RxBusy = MAKE_STATUS(kStatusGroup_LPUART, 1) , kStatus_LPUART_TxIdle = MAKE_STATUS(kStatusGroup_LPUART, 2) , kStatus_LPUART_RxIdle = MAKE_STATUS(kStatusGroup_LPUART, 3) , kStatus_LPUART_TxWatermarkTooLarge = MAKE_STATUS(kStatusGroup_LPUART, 4) , kStatus_LPUART_RxWatermarkTooLarge = MAKE_STATUS(kStatusGroup_LPUART, 5) , kStatus_LPUART_FlagCannotClearManually = MAKE_STATUS(kStatusGroup_LPUART, 6) , kStatus_LPUART_Error = MAKE_STATUS(kStatusGroup_LPUART, 7) , kStatus_LPUART_RxRingBufferOverrun , kStatus_LPUART_RxHardwareOverrun = MAKE_STATUS(kStatusGroup_LPUART, 9) , kStatus_LPUART_NoiseError = MAKE_STATUS(kStatusGroup_LPUART, 10) , kStatus_LPUART_FramingError = MAKE_STATUS(kStatusGroup_LPUART, 11) , kStatus_LPUART_ParityError = MAKE_STATUS(kStatusGroup_LPUART, 12) , kStatus_LPUART_BaudrateNotSupport , kStatus_LPUART_IdleLineDetected = MAKE_STATUS(kStatusGroup_LPUART, 14) , kStatus_LPUART_Timeout = MAKE_STATUS(kStatusGroup_LPUART, 15) } |
Error codes for the LPUART driver. More... | |
enum | _lpuart_parity_mode { kLPUART_ParityDisabled = 0x0U , kLPUART_ParityEven = 0x2U , kLPUART_ParityOdd = 0x3U } |
LPUART parity mode. More... | |
enum | _lpuart_data_bits { kLPUART_EightDataBits = 0x0U } |
LPUART data bits count. More... | |
enum | _lpuart_stop_bit_count { kLPUART_OneStopBit = 0U , kLPUART_TwoStopBit = 1U } |
LPUART stop bit count. More... | |
enum | _lpuart_idle_type_select { kLPUART_IdleTypeStartBit = 0U , kLPUART_IdleTypeStopBit = 1U } |
LPUART idle flag type defines when the receiver starts counting. More... | |
enum | _lpuart_idle_config { kLPUART_IdleCharacter1 = 0U , kLPUART_IdleCharacter2 = 1U , kLPUART_IdleCharacter4 = 2U , kLPUART_IdleCharacter8 = 3U , kLPUART_IdleCharacter16 = 4U , kLPUART_IdleCharacter32 = 5U , kLPUART_IdleCharacter64 = 6U , kLPUART_IdleCharacter128 = 7U } |
LPUART idle detected configuration. This structure defines the number of idle characters that must be received before the IDLE flag is set. More... | |
enum | _lpuart_interrupt_enable { kLPUART_RxActiveEdgeInterruptEnable = (LPUART_BAUD_RXEDGIE_MASK >> 8U) , kLPUART_TxDataRegEmptyInterruptEnable = (LPUART_CTRL_TIE_MASK) , kLPUART_TransmissionCompleteInterruptEnable = (LPUART_CTRL_TCIE_MASK) , kLPUART_RxDataRegFullInterruptEnable = (LPUART_CTRL_RIE_MASK) , kLPUART_IdleLineInterruptEnable = (LPUART_CTRL_ILIE_MASK) , kLPUART_RxOverrunInterruptEnable = (LPUART_CTRL_ORIE_MASK) , kLPUART_NoiseErrorInterruptEnable = (LPUART_CTRL_NEIE_MASK) , kLPUART_FramingErrorInterruptEnable = (LPUART_CTRL_FEIE_MASK) , kLPUART_ParityErrorInterruptEnable = (LPUART_CTRL_PEIE_MASK) , kLPUART_AllInterruptEnable } |
LPUART interrupt configuration structure, default settings all disabled. More... | |
enum | _lpuart_flags { kLPUART_TxDataRegEmptyFlag , kLPUART_TransmissionCompleteFlag , kLPUART_RxDataRegFullFlag = (LPUART_STAT_RDRF_MASK) , kLPUART_IdleLineFlag = (LPUART_STAT_IDLE_MASK) , kLPUART_RxOverrunFlag = (LPUART_STAT_OR_MASK) , kLPUART_NoiseErrorFlag = (LPUART_STAT_NF_MASK) , kLPUART_FramingErrorFlag , kLPUART_ParityErrorFlag = (LPUART_STAT_PF_MASK) , kLPUART_RxActiveEdgeFlag = (LPUART_STAT_RXEDGIF_MASK) , kLPUART_RxActiveFlag , kLPUART_AllClearFlags , kLPUART_AllFlags } |
LPUART status flags. More... | |
typedef enum _lpuart_parity_mode | lpuart_parity_mode_t |
LPUART parity mode. | |
typedef enum _lpuart_data_bits | lpuart_data_bits_t |
LPUART data bits count. | |
typedef enum _lpuart_stop_bit_count | lpuart_stop_bit_count_t |
LPUART stop bit count. | |
typedef enum _lpuart_idle_type_select | lpuart_idle_type_select_t |
LPUART idle flag type defines when the receiver starts counting. | |
typedef enum _lpuart_idle_config | lpuart_idle_config_t |
LPUART idle detected configuration. This structure defines the number of idle characters that must be received before the IDLE flag is set. | |
typedef struct _lpuart_config | lpuart_config_t |
LPUART configuration structure. | |
typedef struct _lpuart_transfer | lpuart_transfer_t |
LPUART transfer structure. | |
typedef struct _lpuart_handle | lpuart_handle_t |
typedef void(* | lpuart_transfer_callback_t) (LPUART_Type *base, lpuart_handle_t *handle, status_t status, void *userData) |
LPUART transfer callback function. | |
typedef void(* | lpuart_isr_t) (LPUART_Type *base, void *handle) |
void * | s_lpuartHandle [] |
const IRQn_Type | s_lpuartIRQ [] |
lpuart_isr_t | s_lpuartIsr [] |
#define | FSL_LPUART_DRIVER_VERSION (MAKE_VERSION(2, 7, 0)) |
LPUART driver version. | |
#define | UART_RETRY_TIMES 0U /* Defining to zero means to keep waiting for the flag until it is assert/deassert. */ |
Retry times for waiting flag. | |
Initialization and deinitialization | |
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. | |
void | LPUART_Deinit (LPUART_Type *base) |
Deinitializes a LPUART instance. | |
void | LPUART_GetDefaultConfig (lpuart_config_t *config) |
Gets the default configuration structure. | |
Module configuration | |
status_t | LPUART_SetBaudRate (LPUART_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz) |
Sets the LPUART instance baudrate. | |
void | LPUART_Enable9bitMode (LPUART_Type *base, bool enable) |
Enable 9-bit data mode for LPUART. | |
Status | |
uint32_t | LPUART_GetStatusFlags (LPUART_Type *base) |
Gets LPUART status flags. | |
status_t | LPUART_ClearStatusFlags (LPUART_Type *base, uint32_t mask) |
Clears status flags with a provided mask. | |
Interrupts | |
void | LPUART_EnableInterrupts (LPUART_Type *base, uint32_t mask) |
Enables LPUART interrupts according to a provided mask. | |
void | LPUART_DisableInterrupts (LPUART_Type *base, uint32_t mask) |
Disables LPUART interrupts according to a provided mask. | |
uint32_t | LPUART_GetEnabledInterrupts (LPUART_Type *base) |
Gets enabled LPUART interrupts. | |
Bus Operations | |
uint32_t | LPUART_GetInstance (LPUART_Type *base) |
Get the LPUART instance from peripheral base address. | |
void | LPUART_SendAddress (LPUART_Type *base, uint8_t address) |
Transmit an address frame in 9-bit data mode. | |
status_t | LPUART_WriteBlocking (LPUART_Type *base, const uint8_t *data, size_t length) |
Writes to the transmitter register using a blocking method. | |
status_t | LPUART_ReadBlocking (LPUART_Type *base, uint8_t *data, size_t length) |
Reads the receiver data register using a blocking method. | |
Transactional | |
void | LPUART_TransferCreateHandle (LPUART_Type *base, lpuart_handle_t *handle, lpuart_transfer_callback_t callback, void *userData) |
Initializes the LPUART handle. | |
status_t | LPUART_TransferSendNonBlocking (LPUART_Type *base, lpuart_handle_t *handle, lpuart_transfer_t *xfer) |
Transmits a buffer of data using the interrupt method. | |
void | LPUART_TransferStartRingBuffer (LPUART_Type *base, lpuart_handle_t *handle, uint8_t *ringBuffer, size_t ringBufferSize) |
Sets up the RX ring buffer. | |
void | LPUART_TransferStopRingBuffer (LPUART_Type *base, lpuart_handle_t *handle) |
Aborts the background transfer and uninstalls the ring buffer. | |
size_t | LPUART_TransferGetRxRingBufferLength (LPUART_Type *base, lpuart_handle_t *handle) |
Get the length of received data in RX ring buffer. | |
void | LPUART_TransferAbortSend (LPUART_Type *base, lpuart_handle_t *handle) |
Aborts the interrupt-driven data transmit. | |
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. | |
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. | |
void | LPUART_TransferAbortReceive (LPUART_Type *base, lpuart_handle_t *handle) |
Aborts the interrupt-driven data receiving. | |
status_t | LPUART_TransferGetReceiveCount (LPUART_Type *base, lpuart_handle_t *handle, uint32_t *count) |
Gets the number of bytes that have been received. | |
void | LPUART_TransferHandleIRQ (LPUART_Type *base, void *irqHandle) |
LPUART IRQ handle function. | |
void | LPUART_TransferHandleErrorIRQ (LPUART_Type *base, void *irqHandle) |
LPUART Error IRQ handle function. | |
anonymous enum |
Error codes for the LPUART driver.
enum _lpuart_data_bits |
enum _lpuart_flags |
LPUART status flags.
This provides constants for the LPUART status flags for use in the LPUART functions.
enum _lpuart_idle_config |
LPUART idle detected configuration. This structure defines the number of idle characters that must be received before the IDLE flag is set.
LPUART interrupt configuration structure, default settings all disabled.
This structure contains the settings for all LPUART interrupt configurations.
enum _lpuart_parity_mode |
status_t LPUART_ClearStatusFlags | ( | LPUART_Type * | base, |
uint32_t | mask | ||
) |
Clears status flags with a provided mask.
This function clears LPUART status flags with a provided mask. Automatically cleared flags can't be cleared by this function. Flags that can only cleared or set by hardware are: kLPUART_TxDataRegEmptyFlag, kLPUART_TransmissionCompleteFlag, kLPUART_RxDataRegFullFlag, kLPUART_RxActiveFlag, kLPUART_NoiseErrorFlag, kLPUART_ParityErrorFlag, kLPUART_TxFifoEmptyFlag,kLPUART_RxFifoEmptyFlag Note: This API should be called when the Tx/Rx is idle, otherwise it takes no effects.
base | LPUART peripheral base address. |
mask | the status flags to be cleared. The user can use the enumerators in the _lpuart_status_flag_t to do the OR operation and get the mask. |
kStatus_LPUART_FlagCannotClearManually | The flag can't be cleared by this function but it is cleared automatically by hardware. |
kStatus_Success | Status in the mask are cleared. |
brief Clears status flags with a provided mask.
This function clears LPUART status flags with a provided mask. Automatically cleared flags can't be cleared by this function. Flags that can only cleared or set by hardware are: kLPUART_TxDataRegEmptyFlag, kLPUART_TransmissionCompleteFlag, kLPUART_RxDataRegFullFlag, kLPUART_RxActiveFlag, kLPUART_NoiseErrorFlag, kLPUART_ParityErrorFlag, kLPUART_TxFifoEmptyFlag,kLPUART_RxFifoEmptyFlag Note: This API should be called when the Tx/Rx is idle, otherwise it takes no effects.
param base LPUART peripheral base address. param mask the status flags to be cleared. The user can use the enumerators in the _lpuart_status_flag_t to do the OR operation and get the mask. return 0 succeed, others failed. retval kStatus_LPUART_FlagCannotClearManually The flag can't be cleared by this function but it is cleared automatically by hardware. retval kStatus_Success Status in the mask are cleared.
void LPUART_Deinit | ( | LPUART_Type * | base | ) |
Deinitializes a LPUART instance.
This function waits for transmit to complete, disables TX and RX, and disables the LPUART clock.
base | LPUART peripheral base address. |
brief Deinitializes a LPUART instance.
This function waits for transmit to complete, disables TX and RX, and disables the LPUART clock.
param base LPUART peripheral base address.
void LPUART_DisableInterrupts | ( | LPUART_Type * | base, |
uint32_t | mask | ||
) |
Disables LPUART interrupts according to a provided mask.
This function disables the LPUART interrupts according to a provided mask. The mask is a logical OR of enumeration members. See _lpuart_interrupt_enable. This example shows how to disable the TX empty interrupt and RX full interrupt:
base | LPUART peripheral base address. |
mask | The interrupts to disable. Logical OR of _lpuart_interrupt_enable. |
brief Disables LPUART interrupts according to a provided mask.
This function disables the LPUART interrupts according to a provided mask. The mask is a logical OR of enumeration members. See ref _lpuart_interrupt_enable. This example shows how to disable the TX empty interrupt and RX full interrupt: code LPUART_DisableInterrupts(LPUART1,kLPUART_TxDataRegEmptyInterruptEnable | kLPUART_RxDataRegFullInterruptEnable); endcode
param base LPUART peripheral base address. param mask The interrupts to disable. Logical OR of ref _lpuart_interrupt_enable.
void LPUART_Enable9bitMode | ( | LPUART_Type * | base, |
bool | enable | ||
) |
Enable 9-bit data mode for LPUART.
This function set the 9-bit mode for LPUART module. The 9th bit is not used for parity thus can be modified by user.
base | LPUART peripheral base address. |
enable | true to enable, flase to disable. |
brief Enable 9-bit data mode for LPUART.
This function set the 9-bit mode for LPUART module. The 9th bit is not used for parity thus can be modified by user.
param base LPUART peripheral base address. param enable true to enable, flase to disable.
void LPUART_EnableInterrupts | ( | LPUART_Type * | base, |
uint32_t | mask | ||
) |
Enables LPUART interrupts according to a provided mask.
This function enables the LPUART interrupts according to a provided mask. The mask is a logical OR of enumeration members. See the _lpuart_interrupt_enable. This examples shows how to enable TX empty interrupt and RX full interrupt:
base | LPUART peripheral base address. |
mask | The interrupts to enable. Logical OR of _lpuart_interrupt_enable. |
brief Enables LPUART interrupts according to a provided mask.
This function enables the LPUART interrupts according to a provided mask. The mask is a logical OR of enumeration members. See the ref _lpuart_interrupt_enable. This examples shows how to enable TX empty interrupt and RX full interrupt: code LPUART_EnableInterrupts(LPUART1,kLPUART_TxDataRegEmptyInterruptEnable | kLPUART_RxDataRegFullInterruptEnable); endcode
param base LPUART peripheral base address. param mask The interrupts to enable. Logical OR of ref _lpuart_interrupt_enable.
void LPUART_GetDefaultConfig | ( | lpuart_config_t * | config | ) |
Gets the default configuration structure.
This function initializes the LPUART configuration structure to a default value. The default values are: lpuartConfig->baudRate_Bps = 115200U; lpuartConfig->parityMode = kLPUART_ParityDisabled; lpuartConfig->dataBitsCount = kLPUART_EightDataBits; lpuartConfig->isMsb = false; lpuartConfig->stopBitCount = kLPUART_OneStopBit; lpuartConfig->txFifoWatermark = 0; lpuartConfig->rxFifoWatermark = 1; lpuartConfig->rxIdleType = kLPUART_IdleTypeStartBit; lpuartConfig->rxIdleConfig = kLPUART_IdleCharacter1; lpuartConfig->enableTx = false; lpuartConfig->enableRx = false;
config | Pointer to a configuration structure. |
brief Gets the default configuration structure.
This function initializes the LPUART configuration structure to a default value. The default values are: lpuartConfig->baudRate_Bps = 115200U; lpuartConfig->parityMode = kLPUART_ParityDisabled; lpuartConfig->dataBitsCount = kLPUART_EightDataBits; lpuartConfig->isMsb = false; lpuartConfig->stopBitCount = kLPUART_OneStopBit; lpuartConfig->txFifoWatermark = 0; lpuartConfig->rxFifoWatermark = 1; lpuartConfig->rxIdleType = kLPUART_IdleTypeStartBit; lpuartConfig->rxIdleConfig = kLPUART_IdleCharacter1; lpuartConfig->enableTx = false; lpuartConfig->enableRx = false;
param config Pointer to a configuration structure.
uint32_t LPUART_GetEnabledInterrupts | ( | LPUART_Type * | base | ) |
Gets enabled LPUART interrupts.
This function gets the enabled LPUART interrupts. The enabled interrupts are returned as the logical OR value of the enumerators _lpuart_interrupt_enable. To check a specific interrupt enable status, compare the return value with enumerators in _lpuart_interrupt_enable. For example, to check whether the TX empty interrupt is enabled:
base | LPUART peripheral base address. |
brief Gets enabled LPUART interrupts.
This function gets the enabled LPUART interrupts. The enabled interrupts are returned as the logical OR value of the enumerators ref _lpuart_interrupt_enable. To check a specific interrupt enable status, compare the return value with enumerators in ref _lpuart_interrupt_enable. For example, to check whether the TX empty interrupt is enabled: code uint32_t enabledInterrupts = LPUART_GetEnabledInterrupts(LPUART1);
if (kLPUART_TxDataRegEmptyInterruptEnable & enabledInterrupts) { ... } endcode
param base LPUART peripheral base address. return LPUART interrupt flags which are logical OR of the enumerators in ref _lpuart_interrupt_enable.
uint32_t LPUART_GetInstance | ( | LPUART_Type * | base | ) |
Get the LPUART instance from peripheral base address.
base | LPUART peripheral base address. |
brief Get the LPUART instance from peripheral base address.
param base LPUART peripheral base address. return LPUART instance.
uint32_t LPUART_GetStatusFlags | ( | LPUART_Type * | base | ) |
Gets LPUART status flags.
This function gets all LPUART status flags. The flags are returned as the logical OR value of the enumerators _lpuart_flags. To check for a specific status, compare the return value with enumerators in the _lpuart_flags. For example, to check whether the TX is empty:
base | LPUART peripheral base address. |
brief Gets LPUART status flags.
This function gets all LPUART status flags. The flags are returned as the logical OR value of the enumerators ref _lpuart_flags. To check for a specific status, compare the return value with enumerators in the ref _lpuart_flags. For example, to check whether the TX is empty: code if (kLPUART_TxDataRegEmptyFlag & LPUART_GetStatusFlags(LPUART1)) { ... } endcode
param base LPUART peripheral base address. return LPUART status flags which are ORed by the enumerators in the _lpuart_flags.
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.
This function configures the LPUART module with user-defined settings. Call the LPUART_GetDefaultConfig() function to configure the configuration structure and get the default configuration. The example below shows how to use this API to configure the LPUART.
base | LPUART peripheral base address. |
config | Pointer to a user-defined configuration structure. |
srcClock_Hz | LPUART clock source frequency in HZ. |
kStatus_LPUART_BaudrateNotSupport | Baudrate is not support in current clock source. |
kStatus_Success | LPUART initialize succeed |
brief Initializes an LPUART instance with the user configuration structure and the peripheral clock.
This function configures the LPUART module with user-defined settings. Call the LPUART_GetDefaultConfig() function to configure the configuration structure and get the default configuration. The example below shows how to use this API to configure the LPUART. code lpuart_config_t lpuartConfig; lpuartConfig.baudRate_Bps = 115200U; lpuartConfig.parityMode = kLPUART_ParityDisabled; lpuartConfig.dataBitsCount = kLPUART_EightDataBits; lpuartConfig.isMsb = false; lpuartConfig.stopBitCount = kLPUART_OneStopBit; lpuartConfig.txFifoWatermark = 0; lpuartConfig.rxFifoWatermark = 1; LPUART_Init(LPUART1, &lpuartConfig, 20000000U); endcode
param base LPUART peripheral base address. param config Pointer to a user-defined configuration structure. param srcClock_Hz LPUART clock source frequency in HZ. retval kStatus_LPUART_BaudrateNotSupport Baudrate is not support in current clock source. retval kStatus_Success LPUART initialize succeed
status_t LPUART_ReadBlocking | ( | LPUART_Type * | base, |
uint8_t * | data, | ||
size_t | length | ||
) |
Reads the receiver data register using a blocking method.
This function polls the receiver register, waits for the receiver register full or receiver FIFO has data, and reads data from the TX register.
base | LPUART peripheral base address. |
data | Start address of the buffer to store the received data. |
length | Size of the buffer. |
kStatus_LPUART_RxHardwareOverrun | Receiver overrun happened while receiving data. |
kStatus_LPUART_NoiseError | Noise error happened while receiving data. |
kStatus_LPUART_FramingError | Framing error happened while receiving data. |
kStatus_LPUART_ParityError | Parity error happened while receiving data. |
kStatus_LPUART_Timeout | Transmission timed out and was aborted. |
kStatus_Success | Successfully received all data. |
brief Reads the receiver data register using a blocking method.
This function polls the receiver register, waits for the receiver register full or receiver FIFO has data, and reads data from the TX register.
param base LPUART peripheral base address. param data Start address of the buffer to store the received data. param length Size of the buffer. retval kStatus_LPUART_RxHardwareOverrun Receiver overrun happened while receiving data. retval kStatus_LPUART_NoiseError Noise error happened while receiving data. retval kStatus_LPUART_FramingError Framing error happened while receiving data. retval kStatus_LPUART_ParityError Parity error happened while receiving data. retval kStatus_LPUART_Timeout Transmission timed out and was aborted. retval kStatus_Success Successfully received all data.
void LPUART_SendAddress | ( | LPUART_Type * | base, |
uint8_t | address | ||
) |
Transmit an address frame in 9-bit data mode.
base | LPUART peripheral base address. |
address | LPUART slave address. |
brief Transmit an address frame in 9-bit data mode.
param base LPUART peripheral base address. param address LPUART slave address.
status_t LPUART_SetBaudRate | ( | LPUART_Type * | base, |
uint32_t | baudRate_Bps, | ||
uint32_t | srcClock_Hz | ||
) |
Sets the LPUART instance baudrate.
This function configures the LPUART module baudrate. This function is used to update the LPUART module baudrate after the LPUART module is initialized by the LPUART_Init.
base | LPUART peripheral base address. |
baudRate_Bps | LPUART baudrate to be set. |
srcClock_Hz | LPUART clock source frequency in HZ. |
kStatus_LPUART_BaudrateNotSupport | Baudrate is not supported in the current clock source. |
kStatus_Success | Set baudrate succeeded. |
brief Sets the LPUART instance baudrate.
This function configures the LPUART module baudrate. This function is used to update the LPUART module baudrate after the LPUART module is initialized by the LPUART_Init. code LPUART_SetBaudRate(LPUART1, 115200U, 20000000U); endcode
param base LPUART peripheral base address. param baudRate_Bps LPUART baudrate to be set. param srcClock_Hz LPUART clock source frequency in HZ. retval kStatus_LPUART_BaudrateNotSupport Baudrate is not supported in the current clock source. retval kStatus_Success Set baudrate succeeded.
void LPUART_TransferAbortReceive | ( | LPUART_Type * | base, |
lpuart_handle_t * | handle | ||
) |
Aborts the interrupt-driven data receiving.
This function aborts the interrupt-driven data receiving. The user can get the remainBytes to find out how many bytes not received yet.
base | LPUART peripheral base address. |
handle | LPUART handle pointer. |
brief Aborts the interrupt-driven data receiving.
This function aborts the interrupt-driven data receiving. The user can get the remainBytes to find out how many bytes not received yet.
param base LPUART peripheral base address. param handle LPUART handle pointer.
void LPUART_TransferAbortSend | ( | LPUART_Type * | base, |
lpuart_handle_t * | handle | ||
) |
Aborts the interrupt-driven data transmit.
This function aborts the interrupt driven data sending. The user can get the remainBtyes to find out how many bytes are not sent out.
base | LPUART peripheral base address. |
handle | LPUART handle pointer. |
brief Aborts the interrupt-driven data transmit.
This function aborts the interrupt driven data sending. The user can get the remainBtyes to find out how many bytes are not sent out.
param base LPUART peripheral base address. param handle LPUART handle pointer.
void LPUART_TransferCreateHandle | ( | LPUART_Type * | base, |
lpuart_handle_t * | handle, | ||
lpuart_transfer_callback_t | callback, | ||
void * | userData | ||
) |
Initializes the LPUART handle.
This function initializes the LPUART handle, which can be used for other LPUART transactional APIs. Usually, for a specified LPUART instance, call this API once to get the initialized handle.
The LPUART driver supports the "background" receiving, which means that user can set up an RX ring buffer optionally. Data received is stored into the ring buffer even when the user doesn't call the LPUART_TransferReceiveNonBlocking() API. If there is already data received in the ring buffer, the user can get the received data from the ring buffer directly. The ring buffer is disabled if passing NULL as ringBuffer
.
base | LPUART peripheral base address. |
handle | LPUART handle pointer. |
callback | Callback function. |
userData | User data. |
brief Initializes the LPUART handle.
This function initializes the LPUART handle, which can be used for other LPUART transactional APIs. Usually, for a specified LPUART instance, call this API once to get the initialized handle.
The LPUART driver supports the "background" receiving, which means that user can set up an RX ring buffer optionally. Data received is stored into the ring buffer even when the user doesn't call the LPUART_TransferReceiveNonBlocking() API. If there is already data received in the ring buffer, the user can get the received data from the ring buffer directly. The ring buffer is disabled if passing NULL as p ringBuffer.
param base LPUART peripheral base address. param handle LPUART handle pointer. param callback Callback function. param userData User data.
status_t LPUART_TransferGetReceiveCount | ( | LPUART_Type * | base, |
lpuart_handle_t * | handle, | ||
uint32_t * | count | ||
) |
Gets the number of bytes that have been received.
This function gets the number of bytes that have been received.
base | LPUART peripheral base address. |
handle | LPUART handle pointer. |
count | Receive bytes count. |
kStatus_NoTransferInProgress | No receive in progress. |
kStatus_InvalidArgument | Parameter is invalid. |
kStatus_Success | Get successfully through the parameter count ; |
brief Gets the number of bytes that have been received.
This function gets the number of bytes that have been received.
param base LPUART peripheral base address. param handle LPUART handle pointer. param count Receive bytes count. retval kStatus_NoTransferInProgress No receive in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter count
;
size_t LPUART_TransferGetRxRingBufferLength | ( | LPUART_Type * | base, |
lpuart_handle_t * | handle | ||
) |
Get the length of received data in RX ring buffer.
base | LPUART peripheral base address. |
handle | LPUART handle pointer. |
brief Get the length of received data in RX ring buffer.
userData handle LPUART handle pointer. return Length of received data in RX ring buffer.
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.
This function gets the number of bytes that have been sent out to bus by an interrupt method.
base | LPUART peripheral base address. |
handle | LPUART handle pointer. |
count | Send bytes count. |
kStatus_NoTransferInProgress | No send in progress. |
kStatus_InvalidArgument | Parameter is invalid. |
kStatus_Success | Get successfully through the parameter count ; |
brief Gets the number of bytes that have been sent out to bus.
This function gets the number of bytes that have been sent out to bus by an interrupt method.
param base LPUART peripheral base address. param handle LPUART handle pointer. param count Send bytes count. retval kStatus_NoTransferInProgress No send in progress. retval kStatus_InvalidArgument Parameter is invalid. retval kStatus_Success Get successfully through the parameter count
;
void LPUART_TransferHandleErrorIRQ | ( | LPUART_Type * | base, |
void * | irqHandle | ||
) |
LPUART Error IRQ handle function.
This function handles the LPUART error IRQ request.
base | LPUART peripheral base address. |
irqHandle | LPUART handle pointer. |
brief LPUART Error IRQ handle function.
This function handles the LPUART error IRQ request.
param base LPUART peripheral base address. param irqHandle LPUART handle pointer.
void LPUART_TransferHandleIRQ | ( | LPUART_Type * | base, |
void * | irqHandle | ||
) |
LPUART IRQ handle function.
This function handles the LPUART transmit and receive IRQ request.
base | LPUART peripheral base address. |
irqHandle | LPUART handle pointer. |
brief LPUART IRQ handle function.
This function handles the LPUART transmit and receive IRQ request.
param base LPUART peripheral base address. param irqHandle LPUART handle pointer.
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.
This function receives data using an interrupt method. This is a non-blocking function which returns without waiting to ensure that all data are received. If the RX ring buffer is used and not empty, the data in the ring buffer is copied and the parameter receivedBytes
shows how many bytes are copied from the ring buffer. After copying, if the data in the ring buffer is not enough for read, the receive request is saved by the LPUART driver. When the new data arrives, the receive request is serviced first. When all data is received, the LPUART driver notifies the upper layer through a callback function and passes a status parameter kStatus_UART_RxIdle. For example, the upper layer needs 10 bytes but there are only 5 bytes in ring buffer. The 5 bytes are copied to xfer->data, which returns with the parameter receivedBytes
set to 5. For the remaining 5 bytes, the newly arrived data is saved from xfer->data[5]. When 5 bytes are received, the LPUART driver notifies the upper layer. If the RX ring buffer is not enabled, this function enables the RX and RX interrupt to receive data to xfer->data. When all data is received, the upper layer is notified.
base | LPUART peripheral base address. |
handle | LPUART handle pointer. |
xfer | LPUART transfer structure, see uart_transfer_t. |
receivedBytes | Bytes received from the ring buffer directly. |
kStatus_Success | Successfully queue the transfer into the transmit queue. |
kStatus_LPUART_RxBusy | Previous receive request is not finished. |
kStatus_InvalidArgument | Invalid argument. |
brief Receives a buffer of data using the interrupt method.
This function receives data using an interrupt method. This is a non-blocking function which returns without waiting to ensure that all data are received. If the RX ring buffer is used and not empty, the data in the ring buffer is copied and the parameter p receivedBytes shows how many bytes are copied from the ring buffer. After copying, if the data in the ring buffer is not enough for read, the receive request is saved by the LPUART driver. When the new data arrives, the receive request is serviced first. When all data is received, the LPUART driver notifies the upper layer through a callback function and passes a status parameter ref kStatus_UART_RxIdle. For example, the upper layer needs 10 bytes but there are only 5 bytes in ring buffer. The 5 bytes are copied to xfer->data, which returns with the parameter p receivedBytes set to 5. For the remaining 5 bytes, the newly arrived data is saved from xfer->data[5]. When 5 bytes are received, the LPUART driver notifies the upper layer. If the RX ring buffer is not enabled, this function enables the RX and RX interrupt to receive data to xfer->data. When all data is received, the upper layer is notified.
param base LPUART peripheral base address. param handle LPUART handle pointer. param xfer LPUART transfer structure, see #uart_transfer_t. param receivedBytes Bytes received from the ring buffer directly. retval kStatus_Success Successfully queue the transfer into the transmit queue. retval kStatus_LPUART_RxBusy Previous receive request is not finished. retval kStatus_InvalidArgument Invalid argument.
status_t LPUART_TransferSendNonBlocking | ( | LPUART_Type * | base, |
lpuart_handle_t * | handle, | ||
lpuart_transfer_t * | xfer | ||
) |
Transmits a buffer of data using the interrupt method.
This function send data using an interrupt method. This is a non-blocking function, which returns directly without waiting for all data written to the transmitter register. When all data is written to the TX register in the ISR, the LPUART driver calls the callback function and passes the kStatus_LPUART_TxIdle as status parameter.
base | LPUART peripheral base address. |
handle | LPUART handle pointer. |
xfer | LPUART transfer structure, see lpuart_transfer_t. |
kStatus_Success | Successfully start the data transmission. |
kStatus_LPUART_TxBusy | Previous transmission still not finished, data not all written to the TX register. |
kStatus_InvalidArgument | Invalid argument. |
brief Transmits a buffer of data using the interrupt method.
This function send data using an interrupt method. This is a non-blocking function, which returns directly without waiting for all data written to the transmitter register. When all data is written to the TX register in the ISR, the LPUART driver calls the callback function and passes the ref kStatus_LPUART_TxIdle as status parameter.
note The kStatus_LPUART_TxIdle is passed to the upper layer when all data are written to the TX register. However, there is no check to ensure that all the data sent out. Before disabling the TX, check the kLPUART_TransmissionCompleteFlag to ensure that the transmit is finished.
param base LPUART peripheral base address. param handle LPUART handle pointer. param xfer LPUART transfer structure, see lpuart_transfer_t. retval kStatus_Success Successfully start the data transmission. retval kStatus_LPUART_TxBusy Previous transmission still not finished, data not all written to the TX register. retval kStatus_InvalidArgument Invalid argument.
void LPUART_TransferStartRingBuffer | ( | LPUART_Type * | base, |
lpuart_handle_t * | handle, | ||
uint8_t * | ringBuffer, | ||
size_t | ringBufferSize | ||
) |
Sets up the RX ring buffer.
This function sets up the RX ring buffer to a specific UART handle.
When the RX ring buffer is used, data received is stored into the ring buffer even when the user doesn't call the UART_TransferReceiveNonBlocking() API. If there is already data received in the ring buffer, the user can get the received data from the ring buffer directly.
ringBufferSize
is 32, then only 31 bytes are used for saving data.base | LPUART peripheral base address. |
handle | LPUART handle pointer. |
ringBuffer | Start address of ring buffer for background receiving. Pass NULL to disable the ring buffer. |
ringBufferSize | size of the ring buffer. |
brief Sets up the RX ring buffer.
This function sets up the RX ring buffer to a specific UART handle.
When the RX ring buffer is used, data received is stored into the ring buffer even when the user doesn't call the UART_TransferReceiveNonBlocking() API. If there is already data received in the ring buffer, the user can get the received data from the ring buffer directly.
note When using RX ring buffer, one byte is reserved for internal use. In other words, if p ringBufferSize is 32, then only 31 bytes are used for saving data.
param base LPUART peripheral base address. param handle LPUART handle pointer. param ringBuffer Start address of ring buffer for background receiving. Pass NULL to disable the ring buffer. param ringBufferSize size of the ring buffer.
void LPUART_TransferStopRingBuffer | ( | LPUART_Type * | base, |
lpuart_handle_t * | handle | ||
) |
Aborts the background transfer and uninstalls the ring buffer.
This function aborts the background transfer and uninstalls the ring buffer.
base | LPUART peripheral base address. |
handle | LPUART handle pointer. |
brief Aborts the background transfer and uninstalls the ring buffer.
This function aborts the background transfer and uninstalls the ring buffer.
param base LPUART peripheral base address. param handle LPUART handle pointer.
status_t LPUART_WriteBlocking | ( | LPUART_Type * | base, |
const uint8_t * | data, | ||
size_t | length | ||
) |
Writes to the transmitter register using a blocking method.
This function polls the transmitter register, first waits for the register to be empty or TX FIFO to have room, and writes data to the transmitter buffer, then waits for the dat to be sent out to the bus.
base | LPUART peripheral base address. |
data | Start address of the data to write. |
length | Size of the data to write. |
kStatus_LPUART_Timeout | Transmission timed out and was aborted. |
kStatus_Success | Successfully wrote all data. |
brief Writes to the transmitter register using a blocking method.
This function polls the transmitter register, first waits for the register to be empty or TX FIFO to have room, and writes data to the transmitter buffer, then waits for the data to be sent out to bus.
param base LPUART peripheral base address. param data Start address of the data to write. param length Size of the data to write. retval kStatus_LPUART_Timeout Transmission timed out and was aborted. retval kStatus_Success Successfully wrote all data.
uint32_t _lpuart_config::baudRate_Bps |
LPUART baud rate
lpuart_transfer_callback_t _lpuart_handle::callback |
Callback function.
uint8_t* _lpuart_transfer::data |
The buffer of data to be transfer.
uint8_t* { ... } ::data |
The buffer of data to be transfer.
lpuart_data_bits_t _lpuart_config::dataBitsCount |
Data bits count, eight (default), seven
size_t _lpuart_transfer::dataSize |
The byte count to be transfer.
bool _lpuart_config::enableRx |
Enable RX
bool _lpuart_config::enableTx |
Enable TX
bool _lpuart_config::isMsb |
Data bits order, LSB (default), MSB
lpuart_parity_mode_t _lpuart_config::parityMode |
Parity mode, disabled (default), even, odd
uint8_t* _lpuart_transfer::rxData |
The buffer to receive data.
uint8_t* { ... } ::rxData |
The buffer to receive data.
uint8_t* volatile _lpuart_handle::rxData |
Address of remaining data to receive.
volatile size_t _lpuart_handle::rxDataSize |
Size of the remaining data to receive.
size_t _lpuart_handle::rxDataSizeAll |
Size of the data to receive.
lpuart_idle_config_t _lpuart_config::rxIdleConfig |
RX IDLE configuration.
lpuart_idle_type_select_t _lpuart_config::rxIdleType |
RX IDLE type.
uint8_t* _lpuart_handle::rxRingBuffer |
Start address of the receiver ring buffer.
volatile uint16_t _lpuart_handle::rxRingBufferHead |
Index for the driver to store received data into ring buffer.
size_t _lpuart_handle::rxRingBufferSize |
Size of the ring buffer.
volatile uint16_t _lpuart_handle::rxRingBufferTail |
Index for the user to get data from the ring buffer.
volatile uint8_t _lpuart_handle::rxState |
RX transfer state.
const uint8_t* { ... } ::txData |
The buffer of data to be sent.
const uint8_t* _lpuart_transfer::txData |
The buffer of data to be sent.
const uint8_t* volatile _lpuart_handle::txData |
Address of remaining data to send.
volatile size_t _lpuart_handle::txDataSize |
Size of the remaining data to send.
size_t _lpuart_handle::txDataSizeAll |
Size of the data to send out.
volatile uint8_t _lpuart_handle::txState |
TX transfer state.
void* _lpuart_handle::userData |
LPUART callback function parameter.