What is S32K1‘s IDLE feature:
IDLE is set when the LPUART receive line becomes idle for a full character time after a period of activity.When CTRL[ILT] is cleared, the receiver starts counting idle bit times after the start bit.
Why write this demo?
Because the RTM driver does not support Lpuart's IDLE detect.
What needs to be modified?
-1.add "UART_EVENT_DMA_IDLE = 0x04U" to “callbacks.h”
-2 add "LPUART_DRV_RxIdleCallback" to ".lpuart_driver.c"
static void LPUART_DRV_RxIdleCallback(uint32_t instance)
{
DEV_ASSERT(instance < LPUART_INSTANCE_COUNT);
LPUART_Type *base = s_lpuartBase[instance];
lpuart_state_t * lpuartState = (lpuart_state_t *)s_lpuartStatePtr[instance];
LPUART_ClearStatusFlag(base,LPUART_IDLE_LINE_DETECT);
if(lpuartState->transferType == LPUART_USING_DMA)
{
lpuartState->rxSize = EDMA_DRV_GetRemainingMajorIterationsCount(lpuartState->rxDMAChannel);
LPUART_DRV_StopRxDma(instance);
lpuartState->rxCallback(lpuartState,UART_EVENT_DMA_IDLE,NULL);/*UART_EVENT_DMA_IDLE : 0x04*/
}
}
-4 add below code to "LPUART_DRV_IRQHandler" and be sure these code must be put before "LPUART_DRV_ErrIrqHandler(instance)"
/* Handle idle line interrupt */
if (LPUART_GetIntMode(base, LPUART_INT_IDLE_LINE))
{
if (LPUART_GetStatusFlag(base, LPUART_IDLE_LINE_DETECT))
{
LPUART_DRV_RxIdleCallback(instance);
}
}
-5 configure IDLE releated register in main function.
LPUART1->CTRL |= LPUART_CTRL_ILT(1);
LPUART1->CTRL |= LPUART_CTRL_IDLECFG(7);
LPUART1->CTRL |= LPUART_CTRL_ILIE(1);
Test environment:
Hardware is base on S32K144EVB-Q100
Software is S32 Design Studio for Arm V 2.2 + RTM 3.0.X
Demo Description:
The baud rate of the serial port is set to 19200, and the function implemented is to send back the received data using DMA methods
.