S32 SDK
lpuart_hal.h File Reference
#include "device_registers.h"
#include "status.h"
#include <stdbool.h>
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  lpuart_idle_line_config_t
 Structure for idle line configuration settings. More...
 

Macros

#define LPUART_SHIFT   (16U)
 
#define LPUART_BAUD_REG_ID   (1U)
 
#define LPUART_STAT_REG_ID   (2U)
 
#define LPUART_CTRL_REG_ID   (3U)
 
#define LPUART_DATA_REG_ID   (4U)
 
#define LPUART_MATCH_REG_ID   (5U)
 
#define LPUART_MODIR_REG_ID   (6U)
 
#define LPUART_FIFO_REG_ID   (7U)
 
#define LPUART_WATER_REG_ID   (8U)
 

Enumerations

enum  lpuart_stop_bit_count_t { LPUART_ONE_STOP_BIT = 0x0U, LPUART_TWO_STOP_BIT = 0x1U }
 LPUART number of stop bits. More...
 
enum  lpuart_parity_mode_t { LPUART_PARITY_DISABLED = 0x0U, LPUART_PARITY_EVEN = 0x2U, LPUART_PARITY_ODD = 0x3U }
 LPUART parity mode. More...
 
enum  lpuart_bit_count_per_char_t { LPUART_8_BITS_PER_CHAR = 0x0U, LPUART_9_BITS_PER_CHAR = 0x1U, LPUART_10_BITS_PER_CHAR = 0x2U }
 LPUART number of bits in a character. More...
 
enum  lpuart_operation_config_t { LPUART_OPERATES = 0x0U, LPUART_STOPS = 0x1U }
 LPUART operation configuration constants. More...
 
enum  lpuart_wakeup_method_t { LPUART_IDLE_LINE_WAKE = 0x0U, LPUART_ADDR_MARK_WAKE = 0x1U }
 LPUART wakeup from standby method constants. More...
 
enum  lpuart_break_char_length_t { LPUART_BREAK_CHAR_10_BIT_MINIMUM = 0x0U, LPUART_BREAK_CHAR_13_BIT_MINIMUM = 0x1U }
 LPUART break character length settings for transmit/detect. More...
 
enum  lpuart_singlewire_txdir_t { LPUART_SINGLE_WIRE_TX_DIR_IN = 0x0U, LPUART_SINGLE_WIRE_TX_DIR_OUT = 0x1U }
 LPUART single-wire mode TX direction. More...
 
enum  lpuart_match_config_t { LPUART_ADDRESS_MATCH_WAKEUP = 0x0U, LPUART_IDLE_MATCH_WAKEUP = 0x1U, LPUART_MATCH_ON_AND_MATCH_OFF = 0x2U, LPUART_ENABLE_RWU_ON_DATA_MATCH = 0x3U }
 LPUART Configures the match addressing mode used. More...
 
enum  lpuart_ir_tx_pulsewidth_t { LPUART_IR_THREE_SIXTEENTH_WIDTH = 0x0U, LPUART_IR_ONE_SIXTEENTH_WIDTH = 0x1U, LPUART_IR_ONE_THIRTYSECOND_WIDTH = 0x2U, LPUART_IR_ONE_FOURTH_WIDTH = 0x3U }
 LPUART infra-red transmitter pulse width options. More...
 
enum  lpuart_idle_char_t {
  LPUART_1_IDLE_CHAR = 0x0U, LPUART_2_IDLE_CHAR = 0x1U, LPUART_4_IDLE_CHAR = 0x2U, LPUART_8_IDLE_CHAR = 0x3U,
  LPUART_16_IDLE_CHAR = 0x4U, LPUART_32_IDLE_CHAR = 0x5U, LPUART_64_IDLE_CHAR = 0x6U, LPUART_128_IDLE_CHAR = 0x7U
}
 LPUART Configures the number of idle characters that must be received before the IDLE flag is set. More...
 
enum  lpuart_cts_source_t { LPUART_CTS_SOURCE_PIN = 0x0U, LPUART_CTS_SOURCE_INVERTED_RECEIVER_MATCH = 0x1U }
 LPUART Transmits the CTS Configuration. Configures the source of the CTS input. More...
 
enum  lpuart_cts_config_t { LPUART_CTS_SAMPLED_ON_EACH_CHAR = 0x0U, LPUART_CTS_SAMPLED_ON_IDLE = 0x1U }
 LPUART Transmits CTS Source.Configures if the CTS state is checked at the start of each character or only when the transmitter is idle. More...
 
enum  lpuart_status_flag_t {
  LPUART_TX_DATA_REG_EMPTY, LPUART_TX_COMPLETE, LPUART_RX_DATA_REG_FULL, LPUART_IDLE_LINE_DETECT,
  LPUART_RX_OVERRUN, LPUART_NOISE_DETECT, LPUART_FRAME_ERR, LPUART_PARITY_ERR,
  LPUART_LIN_BREAK_DETECT, LPUART_RX_ACTIVE_EDGE_DETECT, LPUART_RX_ACTIVE, LPUART_NOISE_IN_CURRENT_WORD,
  LPUART_PARITY_ERR_IN_CURRENT_WORD, LPUART_MATCH_ADDR_ONE, LPUART_MATCH_ADDR_TWO, LPUART_FIFO_TX_OF,
  LPUART_FIFO_RX_UF
}
 LPUART status flags. More...
 
enum  lpuart_interrupt_t {
  LPUART_INT_LIN_BREAK_DETECT, LPUART_INT_RX_ACTIVE_EDGE, LPUART_INT_TX_DATA_REG_EMPTY, LPUART_INT_TX_COMPLETE,
  LPUART_INT_RX_DATA_REG_FULL, LPUART_INT_IDLE_LINE, LPUART_INT_RX_OVERRUN, LPUART_INT_NOISE_ERR_FLAG,
  LPUART_INT_FRAME_ERR_FLAG, LPUART_INT_PARITY_ERR_FLAG, LPUART_INT_MATCH_ADDR_ONE, LPUART_INT_MATCH_ADDR_TWO,
  LPUART_INT_FIFO_TXOF, LPUART_INT_FIFO_RXUF
}
 LPUART interrupt configuration structure, default settings are 0 (disabled) More...
 

Functions

LPUART Common Configurations
void LPUART_HAL_Init (LPUART_Type *base)
 Initializes the LPUART controller. More...
 
static void LPUART_HAL_SetTransmitterCmd (LPUART_Type *base, bool enable)
 Enable/Disable the LPUART transmitter. More...
 
static bool LPUART_HAL_GetTransmitterCmd (const LPUART_Type *base)
 Gets the LPUART transmitter enabled/disabled configuration. More...
 
static void LPUART_HAL_SetReceiverCmd (LPUART_Type *base, bool enable)
 Enable/Disable the LPUART receiver. More...
 
static bool LPUART_HAL_GetReceiverCmd (const LPUART_Type *base)
 Gets the LPUART receiver enabled/disabled configuration. More...
 
status_t LPUART_HAL_SetBaudRate (LPUART_Type *base, uint32_t sourceClockInHz, uint32_t desiredBaudRate)
 Configures the LPUART baud rate. More...
 
static void LPUART_HAL_SetBaudRateDivisor (LPUART_Type *base, uint32_t baudRateDivisor)
 Sets the LPUART baud rate modulo divisor. More...
 
static void LPUART_HAL_SetOversamplingRatio (LPUART_Type *base, uint32_t overSamplingRatio)
 Sets the LPUART baud rate oversampling ratio. More...
 
static void LPUART_HAL_SetBothEdgeSamplingCmd (LPUART_Type *base, bool enable)
 Configures the LPUART baud rate both edge sampling. More...
 
static bool LPUART_HAL_GetRxDataPolarity (const LPUART_Type *base)
 Returns whether the receive data is inverted or not. More...
 
static void LPUART_HAL_SetRxDataPolarity (LPUART_Type *base, bool polarity)
 Sets whether the recevie data is inverted or not. More...
 
void LPUART_HAL_SetBitCountPerChar (LPUART_Type *base, lpuart_bit_count_per_char_t bitCountPerChar)
 Configures the number of bits per character in the LPUART controller. More...
 
void LPUART_HAL_SetParityMode (LPUART_Type *base, lpuart_parity_mode_t parityModeType)
 Configures parity mode in the LPUART controller. More...
 
static void LPUART_HAL_SetStopBitCount (LPUART_Type *base, lpuart_stop_bit_count_t stopBitCount)
 Configures the number of stop bits in the LPUART controller. More...
 
static const volatile void * LPUART_HAL_GetDataRegAddr (const LPUART_Type *base)
 Get LPUART tx/rx data register address. More...
 
LPUART Interrupts and DMA
void LPUART_HAL_SetIntMode (LPUART_Type *base, lpuart_interrupt_t intSrc, bool enable)
 Configures the LPUART module interrupts. More...
 
bool LPUART_HAL_GetIntMode (const LPUART_Type *base, lpuart_interrupt_t intSrc)
 Returns LPUART module interrupts state. More...
 
static void LPUART_HAL_SetTxDmaCmd (LPUART_Type *base, bool enable)
 Configures DMA requests. More...
 
static void LPUART_HAL_SetRxDmaCmd (LPUART_Type *base, bool enable)
 Configures DMA requests. More...
 
static bool LPUART_HAL_IsTxDmaEnabled (const LPUART_Type *base)
 Gets the LPUART DMA request configuration. More...
 
static bool LPUART_HAL_IsRxDmaEnabled (const LPUART_Type *base)
 Gets the LPUART DMA request configuration. More...
 
LPUART Transfer Functions
static void LPUART_HAL_Putchar (LPUART_Type *base, uint8_t data)
 Sends the LPUART 8-bit character. More...
 
void LPUART_HAL_Putchar9 (LPUART_Type *base, uint16_t data)
 Sends the LPUART 9-bit character. More...
 
void LPUART_HAL_Putchar10 (LPUART_Type *base, uint16_t data)
 Sends the LPUART 10-bit character (Note: Feature available on select LPUART instances). More...
 
static void LPUART_HAL_Getchar (const LPUART_Type *base, uint8_t *readData)
 Gets the LPUART 8-bit character. More...
 
void LPUART_HAL_Getchar9 (const LPUART_Type *base, uint16_t *readData)
 Gets the LPUART 9-bit character. More...
 
void LPUART_HAL_Getchar10 (const LPUART_Type *base, uint16_t *readData)
 Gets the LPUART 10-bit character. More...
 
void LPUART_HAL_SendDataPolling (LPUART_Type *base, const uint8_t *txBuff, uint32_t txSize)
 Send out multiple bytes of data using polling method. More...
 
status_t LPUART_HAL_ReceiveDataPolling (LPUART_Type *base, uint8_t *rxBuff, uint32_t rxSize)
 Receive multiple bytes of data using polling method. More...
 
LPUART Status Flags
bool LPUART_HAL_GetStatusFlag (const LPUART_Type *base, lpuart_status_flag_t statusFlag)
 LPUART get status flag. More...
 
status_t LPUART_HAL_ClearStatusFlag (LPUART_Type *base, lpuart_status_flag_t statusFlag)
 LPUART clears an individual status flag. More...
 
LPUART Special Feature Configurations
static void LPUART_HAL_SetIdleChar (LPUART_Type *base, lpuart_idle_char_t idleConfig)
 Configures the number of idle characters. More...
 
static lpuart_idle_char_t LPUART_HAL_GetIdleChar (const LPUART_Type *base)
 Gets the number of idle characters for IDLE flag. More...
 
static bool LPUART_HAL_IsCurrentDataWithNoise (const LPUART_Type *base)
 Checks whether the current data word was received with noise. More...
 
static bool LPUART_HAL_IsCurrentDataWithFrameError (const LPUART_Type *base)
 Checks whether the current data word was received with frame error. More...
 
static void LPUART_HAL_SetTxSpecialChar (LPUART_Type *base, uint8_t specialChar)
 Indicates a special character is to be transmitted. More...
 
static bool LPUART_HAL_IsCurrentDataWithParityError (const LPUART_Type *base)
 Checks whether the current data word was received with parity error. More...
 
static bool LPUART_HAL_IsReceiveBufferEmpty (const LPUART_Type *base)
 Checks whether the receive buffer is empty. More...
 
static bool LPUART_HAL_WasPreviousReceiverStateIdle (const LPUART_Type *base)
 Checks whether the previous BUS state was idle before this byte is received. More...
 
static void LPUART_HAL_SetWaitModeOperation (LPUART_Type *base, lpuart_operation_config_t mode)
 Configures the LPUART operation in wait mode (operates or stops operations in wait mode). More...
 
static lpuart_operation_config_t LPUART_HAL_GetWaitModeOperation (const LPUART_Type *base)
 Gets the LPUART operation in wait mode. More...
 
void LPUART_HAL_SetLoopbackCmd (LPUART_Type *base, bool enable)
 Configures the LPUART loopback operation (enable/disable loopback operation) More...
 
void LPUART_HAL_SetSingleWireCmd (LPUART_Type *base, bool enable)
 Configures the LPUART single-wire operation (enable/disable single-wire mode). More...
 
static void LPUART_HAL_SetTxdirInSinglewireMode (LPUART_Type *base, lpuart_singlewire_txdir_t direction)
 Configures the LPUART transmit direction while in single-wire mode. More...
 
status_t LPUART_HAL_SetReceiverInStandbyMode (LPUART_Type *base)
 Places the LPUART receiver in standby mode. More...
 
static void LPUART_HAL_PutReceiverInNormalMode (LPUART_Type *base)
 Places the LPUART receiver in a normal mode. More...
 
static bool LPUART_HAL_IsReceiverInStandby (const LPUART_Type *base)
 Checks whether the LPUART receiver is in a standby mode. More...
 
static void LPUART_HAL_SetReceiverWakeupMode (LPUART_Type *base, lpuart_wakeup_method_t method)
 Sets the LPUART receiver wakeup method from standby mode. More...
 
static lpuart_wakeup_method_t LPUART_HAL_GetReceiverWakeupMode (const LPUART_Type *base)
 Gets the LPUART receiver wakeup method from standby mode. More...
 
void LPUART_HAL_SetIdleLineDetect (LPUART_Type *base, const lpuart_idle_line_config_t *config)
 LPUART idle-line detect operation configuration. More...
 
static void LPUART_HAL_SetBreakCharTransmitLength (LPUART_Type *base, lpuart_break_char_length_t length)
 LPUART break character transmit length configuration. More...
 
static void LPUART_HAL_SetBreakCharDetectLength (LPUART_Type *base, lpuart_break_char_length_t length)
 LPUART break character detect length configuration. More...
 
static void LPUART_HAL_QueueBreakField (LPUART_Type *base)
 LPUART transmit sends break character configuration. More...
 
static void LPUART_HAL_SetMatchAddressMode (LPUART_Type *base, lpuart_match_config_t config)
 Configures match address mode control. More...
 
void LPUART_HAL_SetMatchAddressReg1 (LPUART_Type *base, bool enable, uint8_t value)
 Configures address match register 1. More...
 
void LPUART_HAL_SetMatchAddressReg2 (LPUART_Type *base, bool enable, uint8_t value)
 Configures address match register 2. More...
 
static void LPUART_HAL_SetSendMsbFirstCmd (LPUART_Type *base, bool enable)
 LPUART sends the MSB first configuration. More...
 
static void LPUART_HAL_SetReceiveResyncCmd (LPUART_Type *base, bool enable)
 LPUART enable/disable re-sync of received data configuration. More...
 
static void LPUART_HAL_SetCtsSource (LPUART_Type *base, lpuart_cts_source_t source)
 Transmits the CTS source configuration. More...
 
static void LPUART_HAL_SetCtsMode (LPUART_Type *base, lpuart_cts_config_t mode)
 Transmits the CTS configuration. More...
 
static void LPUART_HAL_SetTxCtsCmd (LPUART_Type *base, bool enable)
 Enable/Disable the transmitter clear-to-send. More...
 
static void LPUART_HAL_SetRxRtsCmd (LPUART_Type *base, bool enable)
 Enable/Disable the receiver request-to-send. More...
 
static void LPUART_HAL_SetTxRtsCmd (LPUART_Type *base, bool enable)
 Enable/Disable the transmitter request-to-send. More...
 
static void LPUART_HAL_SetTxRtsPolarityMode (LPUART_Type *base, bool polarity)
 Configures the transmitter RTS polarity. More...
 
static void LPUART_HAL_SetTxFIFOCmd (LPUART_Type *base, bool enable)
 Enable/Disable the transmitter FIFO. More...
 
static void LPUART_HAL_SetRxFIFOCmd (LPUART_Type *base, bool enable)
 Enable/Disable the receiver FIFO. More...
 
static void LPUART_HAL_SetRxIdleEmptyDuration (LPUART_Type *base, uint8_t duration)
 Enables the assertion of RDRF when the receiver is idle. More...
 
static void LPUART_HAL_FlushTxFifoBuffer (LPUART_Type *base)
 Flush tx FIFO buffer. More...
 
static void LPUART_HAL_FlushRxFifoBuffer (LPUART_Type *base)
 Flush rx FIFO buffer. More...
 
static void LPUART_HAL_SetTxWatermark (LPUART_Type *base, uint8_t txWater)
 Sets the tx watermark. More...
 
static void LPUART_HAL_SetRxWatermark (LPUART_Type *base, uint8_t rxWater)
 Sets the rx watermark. More...
 
void LPUART_HAL_SetInfrared (LPUART_Type *base, bool enable, lpuart_ir_tx_pulsewidth_t pulseWidth)
 Configures the LPUART infrared operation. More...