63 #ifdef LPUART_ERR_IRQS
77 #ifdef LPUART_ERR_IRQS
95 uint32_t timeoutMSec);
114 uint32_t twoBitTimeLength);
117 uint32_t twoBitTimeLength);
143 uint32_t linSourceClockFreq = 0U;
151 #if (LPUART_INSTANCE_COUNT > 1U)
156 #if (LPUART_INSTANCE_COUNT > 2U)
161 #if (LPUART_INSTANCE_COUNT > 3U)
163 linLpuartClkName = PCC_LPUART3_CLOCK;
181 g_linStatePtr[instance] = linCurrentState;
184 g_linUserconfigPtr[instance] = linUserConfig;
255 #ifdef LPUART_ERR_IRQS
276 if (linUserConfig->
baudRate > 10000U)
318 lin_state_t * linCurrentState = g_linStatePtr[instance];
347 #ifdef LPUART_ERR_IRQS
355 g_linStatePtr[instance] = NULL;
376 lin_state_t * linCurrentState = g_linStatePtr[instance];
382 linCurrentState->
Callback =
function;
384 return currentCallback;
401 const uint8_t * txBuff,
403 uint32_t timeoutMSec)
413 lin_state_t * linCurrentState = g_linStatePtr[instance];
421 if ((8U < txSize) || (0U == txSize) || checkSleepMode)
438 linCurrentState->
txBuff = txBuff;
440 linCurrentState->
txSize = (uint8_t)(txSize + 1U);
486 const uint8_t * txBuff,
499 lin_state_t * linCurrentState = g_linStatePtr[instance];
506 if ((8U < txSize) || (0U == txSize) || checkSleepMode)
523 linCurrentState->
txBuff = txBuff;
525 linCurrentState->
txSize = (uint8_t)(txSize + 1U);
557 uint8_t * bytesRemaining)
565 const lin_state_t * linCurrentState = g_linStatePtr[instance];
568 *bytesRemaining = (uint8_t)(linCurrentState->
txSize - linCurrentState->
cntByte);
604 uint32_t timeoutMSec)
614 lin_state_t * linCurrentState = g_linStatePtr[instance];
622 if ((8U < rxSize) || (0U == rxSize) || checkSleepMode)
636 linCurrentState->
rxBuff = rxBuff;
638 linCurrentState->
rxSize = (uint8_t)(rxSize + 1U);
706 lin_state_t * linCurrentState = g_linStatePtr[instance];
713 if ((8U < rxSize) || (0U == rxSize) || checkSleepMode)
727 linCurrentState->
rxBuff = rxBuff;
729 linCurrentState->
rxSize = (uint8_t)(rxSize + 1U);
764 lin_state_t * linCurrentState = g_linStatePtr[instance];
789 uint8_t * bytesRemaining)
797 const lin_state_t * linCurrentState = g_linStatePtr[instance];
800 *bytesRemaining = (uint8_t)(linCurrentState->
rxSize - linCurrentState->
cntByte);
835 lin_state_t * linCurrentState = g_linStatePtr[instance];
873 const lin_state_t * linCurrentState = g_linStatePtr[instance];
904 const lin_state_t * linCurrentState = g_linStatePtr[instance];
906 if (linCurrentState != NULL)
930 lin_state_t * linCurrentState = g_linStatePtr[instance];
948 if (linCurrentState->
Callback != NULL)
950 linCurrentState->
Callback(instance, linCurrentState);
979 if (linCurrentState->
Callback != NULL)
981 linCurrentState->
Callback(instance, linCurrentState);
1013 uint32_t timeoutValue)
1019 lin_state_t * linCurrentState = g_linStatePtr[instance];
1057 lin_state_t * linCurrentState = g_linStatePtr[instance];
1064 if ((linUserConfig->
nodeFunction == (
bool)
SLAVE) || (0x3FU < id) || checkSleepMode)
1117 const lin_state_t * linCurrentState = g_linStatePtr[instance];
1138 #ifdef LPUART_ERR_IRQS
1163 const lin_state_t * linCurrentState = g_linStatePtr[instance];
1184 #ifdef LPUART_ERR_IRQS
1204 lin_state_t * linCurrentState = g_linStatePtr[instance];
1241 uint32_t timeoutMSec)
1244 lin_state_t * linCurrentState = g_linStatePtr[instance];
1247 if (linCurrentState->
isTxBusy ==
true)
1255 if (linCurrentState->
isRxBusy ==
true)
1281 uint8_t tmpByte = 0U;
1287 lin_state_t * linCurrentState = g_linStatePtr[instance];
1326 if (linCurrentState->
Callback != NULL)
1328 linCurrentState->
Callback(instance, linCurrentState);
1337 if (linCurrentState->
Callback != NULL)
1339 linCurrentState->
Callback(instance, linCurrentState);
1387 lin_state_t * linCurrentState = g_linStatePtr[instance];
1427 if (linCurrentState->
Callback != NULL)
1429 linCurrentState->
Callback(instance, linCurrentState);
1448 uint32_t wakeupSignalLength = 0U;
1457 lin_state_t * linCurrentState = g_linStatePtr[instance];
1477 if ((wakeupSignalLength >= 150000U) && (wakeupSignalLength <= 5000000U))
1482 if (linCurrentState->
Callback != NULL)
1484 linCurrentState->
Callback(instance, linCurrentState);
1505 const lin_state_t * linCurrentState = g_linStatePtr[instance];
1553 lin_state_t * linCurrentState = g_linStatePtr[instance];
1560 if (tmpByte == 0x55U)
1572 if (linCurrentState->
Callback != NULL)
1574 linCurrentState->
Callback(instance, linCurrentState);
1588 if (tmpByte == 0x55U)
1610 if (linCurrentState->
Callback != NULL)
1612 linCurrentState->
Callback(instance, linCurrentState);
1632 if (linCurrentState->
Callback != NULL)
1634 linCurrentState->
Callback(instance, linCurrentState);
1651 if (linCurrentState->
Callback != NULL)
1653 linCurrentState->
Callback(instance, linCurrentState);
1663 if (linCurrentState->
currentId != 0xFFU)
1672 if (linCurrentState->
Callback != NULL)
1674 linCurrentState->
Callback(instance, linCurrentState);
1683 if (linCurrentState->
Callback != NULL)
1685 linCurrentState->
Callback(instance, linCurrentState);
1714 lin_state_t * linCurrentState = g_linStatePtr[instance];
1716 if (linCurrentState->
rxSize > (linCurrentState->
cntByte + 1U))
1718 *(linCurrentState->
rxBuff) = tmpByte;
1719 linCurrentState->
rxBuff++;
1723 if ((linCurrentState->
rxSize - linCurrentState->
cntByte) == 1U)
1725 linCurrentState->
checkSum = tmpByte;
1733 linCurrentState->
rxBuff -= linCurrentState->
rxSize - 1U;
1740 if (linCurrentState->
Callback != NULL)
1742 linCurrentState->
Callback(instance, linCurrentState);
1769 if (linCurrentState->
Callback != NULL)
1771 linCurrentState->
Callback(instance, linCurrentState);
1793 bool sendFlag =
true;
1795 bool tmpCheckSumAndSize;
1796 bool tmpBuffAndSize;
1802 lin_state_t * linCurrentState = g_linStatePtr[instance];
1809 if (linCurrentState->
Callback != NULL)
1811 linCurrentState->
Callback(instance, linCurrentState);
1828 tmpSize = (uint8_t)(linCurrentState->
txSize - linCurrentState->
cntByte);
1829 tmpCheckSumAndSize = (tmpSize == 1U) && (linCurrentState->
checkSum != tmpByte);
1830 tmpBuffAndSize = (*linCurrentState->
txBuff != tmpByte) && (tmpSize != 1U);
1831 if (tmpBuffAndSize || tmpCheckSumAndSize)
1836 if (linCurrentState->
Callback != NULL)
1838 linCurrentState->
Callback(instance, linCurrentState);
1855 linCurrentState->
txBuff++;
1865 if ((linCurrentState->
txSize - linCurrentState->
cntByte) == 1U)
1882 if (linCurrentState->
Callback != NULL)
1884 linCurrentState->
Callback(instance, linCurrentState);
1916 uint32_t twoBitTimeLength)
1918 uint32_t MasterBaudrate = 0U;
1927 lin_state_t * linCurrentState = g_linStatePtr[instance];
1939 MasterBaudrate = 19200U;
1943 MasterBaudrate = 14400U;
1947 MasterBaudrate = 9600U;
1951 MasterBaudrate = 4800U;
1955 MasterBaudrate = 2400U;
1963 if ((MasterBaudrate != 0U) && (linUserConfig->
baudRate != MasterBaudrate))
1965 linUserConfig->
baudRate = MasterBaudrate;
1972 if (linUserConfig->
baudRate > 10000U)
1988 if (linCurrentState->
Callback != NULL)
1990 linCurrentState->
Callback(instance, linCurrentState);
2008 uint32_t twoBitTimeLength)
2011 lin_state_t * linCurrentState = g_linStatePtr[instance];
2068 lin_state_t * linCurrentState = g_linStatePtr[instance];
2070 uint32_t tmpTime = 0U;
2087 if ((tmpTime >= 150000U) && (tmpTime <= 5000000U))
2092 if (linCurrentState->
Callback != NULL)
2094 linCurrentState->
Callback(instance, linCurrentState);
2125 if (linCurrentState->
Callback != NULL)
2127 linCurrentState->
Callback(instance, linCurrentState);
lin_node_state_t
Define type for an enumerating LIN Node state. Implements : lin_node_state_t_Class.
LPUART_Type *const g_linLpuartBase[LPUART_INSTANCE_COUNT]
Table of base addresses for LPUART instances.
volatile bool timeoutCounterFlag
status_t LIN_LPUART_DRV_Init(uint32_t instance, lin_user_config_t *linUserConfig, lin_state_t *linCurrentState)
Initializes an LIN_LPUART instance for LIN Network.
volatile bool baudrateEvalEnable
status_t LIN_LPUART_DRV_SendWakeupSignal(uint32_t instance)
Sends a wakeup signal through the LIN_LPUART interface.
status_t OSIF_SemaDestroy(const semaphore_t *const pSem)
Destroys a previously created semaphore.
volatile lin_event_id_t currentEventId
status_t LIN_LPUART_DRV_SendFrameDataBlocking(uint32_t instance, const uint8_t *txBuff, uint8_t txSize, uint32_t timeoutMSec)
Sends Frame data out through the LIN_LPUART module using blocking method. This function will calculat...
static void LIN_LPUART_DRV_CheckWakeupSignal(uint32_t instance)
static void LPUART_HAL_QueueBreakField(LPUART_Type *base)
LPUART transmit sends break character configuration.
volatile uint32_t timeoutCounter
static void LIN_LPUART_DRV_ProcessFrameHeader(uint32_t instance, uint8_t tmpByte)
lin_user_config_t * g_linUserconfigPtr[LPUART_INSTANCE_COUNT]
Table to save LIN user config structure pointers.
status_t LIN_LPUART_DRV_SendFrameData(uint32_t instance, const uint8_t *txBuff, uint8_t txSize)
Sends frame data out through the LIN_LPUART module using non-blocking method. This enables an a-sync ...
void(* lin_callback_t)(uint32_t instance, void *linState)
LIN Driver callback function type Implements : lin_callback_t_Class.
IRQn_Type
Defines the Interrupt Numbers definitions.
status_t LIN_LPUART_DRV_GoToSleepMode(uint32_t instance)
This function puts current node to sleep mode This function changes current node state to LIN_NODE_ST...
status_t OSIF_SemaCreate(semaphore_t *const pSem, const uint8_t initValue)
Creates a semaphore with a given value.
static void LIN_LPUART_DRV_EvalTwoBitTimeLength(uint32_t instance, uint32_t twoBitTimeLength)
status_t LIN_LPUART_DRV_GetTransmitStatus(uint32_t instance, uint8_t *bytesRemaining)
Get status of an on-going non-blocking transmission While sending frame data using non-blocking metho...
static uint32_t s_timeMeasure[LPUART_INSTANCE_COUNT]
#define TWO_BIT_DURATION_MAX_4800
void LPUART_HAL_SetParityMode(LPUART_Type *base, lpuart_parity_mode_t parityModeType)
Configures parity mode in the LPUART controller.
static uint8_t s_countMeasure[LPUART_INSTANCE_COUNT]
status_t LIN_LPUART_DRV_DisableIRQ(uint32_t instance)
Disables LIN_LPUART hardware interrupts.
volatile lin_node_state_t currentNodeState
void INT_SYS_DisableIRQ(IRQn_Type irqNumber)
Disables an interrupt for a given IRQ number.
#define TWO_BIT_DURATION_MAX_14400
status_t LIN_LPUART_DRV_AutoBaudCapture(uint32_t instance)
LIN_LPUART capture time interval to set baudrate automatically when enable autobaud feature...
static void LIN_LPUART_DRV_ProcessReceiveFrameData(uint32_t instance, uint8_t tmpByte)
void LIN_LPUART_DRV_SetTimeoutCounter(uint32_t instance, uint32_t timeoutValue)
Set Value for Timeout Counter that is used in LIN_LPUART_DRV_TimeoutService.
#define TWO_BIT_DURATION_MIN_9600
static void LPUART_HAL_SetBreakCharTransmitLength(LPUART_Type *base, lpuart_break_char_length_t length)
LPUART break character transmit length configuration.
const IRQn_Type g_linLpuartRxTxIrqId[LPUART_INSTANCE_COUNT]
Table to save LPUART IRQ enumeration numbers defined in the device header file.
uint32_t linSourceClockFreq
#define TWO_BIT_DURATION_MIN_14400
volatile uint8_t fallingEdgeInterruptCount
bool LPUART_HAL_GetIntMode(const LPUART_Type *base, lpuart_interrupt_t intSrc)
Returns LPUART module interrupts state.
status_t CLOCK_SYS_GetFreq(clock_names_t clockName, uint32_t *frequency)
Gets the clock frequency for a specific clock name.
static void LPUART_HAL_SetBreakCharDetectLength(LPUART_Type *base, lpuart_break_char_length_t length)
LPUART break character detect length configuration.
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
#define TWO_BIT_DURATION_MAX_19200
lin_timer_get_time_interval_t timerGetTimeIntervalCallback
uint8_t LIN_DRV_ProcessParity(uint8_t PID, uint8_t typeAction)
Makes or checks parity bits. If action is checking parity, the function returns ID value if parity bi...
#define TWO_BIT_DURATION_MIN_2400
static status_t LIN_LPUART_DRV_WaitComplete(uint32_t instance, uint32_t timeoutMSec)
static void LIN_LPUART_DRV_ProcessFrame(uint32_t instance, uint8_t tmpByte)
static void LIN_LPUART_DRV_ProcessBreakDetect(uint32_t instance)
volatile bool isRxBlocking
void LIN_LPUART_DRV_TimeoutService(uint32_t instance)
Callback function for Timer Interrupt Handler Users shall initialize a timer (for example FTM) in Out...
static bool LPUART_HAL_GetRxDataPolarity(const LPUART_Type *base)
Returns whether the receive data is inverted or not.
static uint8_t s_wakeupSignal[LPUART_INSTANCE_COUNT]
status_t LIN_LPUART_DRV_GetReceiveStatus(uint32_t instance, uint8_t *bytesRemaining)
Get status of an on-going non-blocking reception While receiving frame data using non-blocking method...
Runtime state of the LIN driver.
status_t OSIF_SemaWait(semaphore_t *const pSem, const uint32_t timeout)
Decrement a semaphore with timeout.
clock_names_t
Clock names.
static void LPUART_HAL_SetTransmitterCmd(LPUART_Type *base, bool enable)
Enable/Disable the LPUART transmitter.
#define TWO_BIT_DURATION_MIN_4800
static void LPUART_HAL_Putchar(LPUART_Type *base, uint8_t data)
Sends the LPUART 8-bit character.
LIN hardware configuration structure Implements : lin_user_config_t_Class.
volatile bool isTxBlocking
static void LIN_LPUART_DRV_ProcessSendFrameData(uint32_t instance, uint8_t tmpByte)
#define AUTOBAUD_BREAK_TIME_MIN
status_t OSIF_SemaPost(semaphore_t *const pSem)
Increment a semaphore.
status_t LPUART_HAL_ClearStatusFlag(LPUART_Type *base, lpuart_status_flag_t statusFlag)
LPUART clears an individual status flag.
static uint32_t s_previousTwoBitTimeLength[LPUART_INSTANCE_COUNT]
status_t LIN_LPUART_DRV_RecvFrmData(uint32_t instance, uint8_t *rxBuff, uint8_t rxSize)
Receives frame data through the LIN_LPUART module using non-blocking method. This function returns im...
#define LPUART_INSTANCE_COUNT
#define TWO_BIT_DURATION_MAX_2400
void INT_SYS_EnableIRQ(IRQn_Type irqNumber)
Enables an interrupt for a given IRQ number.
status_t LPUART_HAL_SetBaudRate(LPUART_Type *base, uint32_t sourceClockInHz, uint32_t desiredBaudRate)
Configures the LPUART baud rate.
lin_node_state_t LIN_LPUART_DRV_GetCurrentNodeState(uint32_t instance)
Get the current LIN node state.
status_t LIN_LPUART_DRV_GotoIdleState(uint32_t instance)
Puts current LIN node to Idle state This function changes current node state to LIN_NODE_STATE_IDLE.
status_t LIN_LPUART_DRV_AbortTransferData(uint32_t instance)
Aborts an on-going non-blocking transmission/reception. While performing a non-blocking transferring ...
#define TWO_BIT_DURATION_MIN_19200
status_t LIN_LPUART_DRV_MasterSendHeader(uint32_t instance, uint8_t id)
Sends frame header out through the LIN_LPUART module using a non-blocking method. This function sends...
isr_t g_linLpuartIsrs[LPUART_INSTANCE_COUNT]
#define TWO_BIT_DURATION_MAX_9600
static void LPUART_HAL_SetReceiverCmd(LPUART_Type *base, bool enable)
Enable/Disable the LPUART receiver.
static void LIN_LPUART_DRV_AutobaudTimerValEval(uint32_t instance, uint32_t twoBitTimeLength)
void LIN_LPUART_DRV_IRQHandler(uint32_t instance)
LIN_LPUART interrupt handler for RX_TX and Error interrupts.
uint8_t LIN_DRV_MakeChecksumByte(const uint8_t *buffer, uint8_t sizeBuffer, uint8_t PID)
Makes the checksum byte for a frame.
lin_state_t * g_linStatePtr[LPUART_INSTANCE_COUNT]
Table to save LPUART state structure pointers.
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.
status_t LIN_LPUART_DRV_EnableIRQ(uint32_t instance)
Enables LIN_LPUART hardware interrupts.
void LPUART_HAL_SetIntMode(LPUART_Type *base, lpuart_interrupt_t intSrc, bool enable)
Configures the LPUART module interrupts.
status_t LIN_LPUART_DRV_Deinit(uint32_t instance)
Shuts down the LIN_LPUART by disabling interrupts and transmitter/receiver.
void(* isr_t)(void)
Interrupt handler type.
bool LPUART_HAL_GetStatusFlag(const LPUART_Type *base, lpuart_status_flag_t statusFlag)
LPUART get status flag.
#define BIT_RATE_TOLERANCE_UNSYNC
static void LPUART_HAL_SetStopBitCount(LPUART_Type *base, lpuart_stop_bit_count_t stopBitCount)
Configures the number of stop bits in the LPUART controller.
status_t LIN_LPUART_DRV_RecvFrmDataBlocking(uint32_t instance, uint8_t *rxBuff, uint8_t rxSize, uint32_t timeoutMSec)
Receives frame data through the LIN_LPUART module using blocking method. The function does not return...
#define LPUART_RX_TX_IRQS
void LPUART_HAL_Init(LPUART_Type *base)
Initializes the LPUART controller.
lin_callback_t LIN_LPUART_DRV_InstallCallback(uint32_t instance, lin_callback_t function)
Installs callback function that is used for LIN_LPUART_DRV_IRQHandler.
void INT_SYS_InstallHandler(IRQn_Type irqNumber, const isr_t newHandler, isr_t *const oldHandler)
Installs an interrupt handler routine for a given IRQ number.
static void LPUART_HAL_SetRxDataPolarity(LPUART_Type *base, bool polarity)
Sets whether the recevie data is inverted or not.
static void LPUART_HAL_Getchar(const LPUART_Type *base, uint8_t *readData)
Gets the LPUART 8-bit character.