S32DS s32k344 Lpuart_Lin lin slave

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32DS s32k344 Lpuart_Lin lin slave

583 Views
harryoceana
Contributor II

S32K344 

OS: Freertos

RTD: 3.0.0

5.PNG

6.PNG

lin slave 使用定时器接收任意长度的数据,6个lin 需要使用6个定时器吗?

0 Kudos
Reply
3 Replies

555 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @harryoceana,

The implementation of the timer mechanism is left to the application developer. A single continuously running timer shared across all LIN slave instances can be used.

When LinLpuart_StartTimerNotification(uint8 instance, uint32 microSeconds) is called for a LIN slave instance, capture the current timestamp. 

You would need to poll periodically the timer to check if the configured timeout has elapsed for each LIN instance.

OsIf_Timer_System.h

OsIf_Timer_System_GetElapsed()

 

Regards,

Daniel

 

0 Kudos
Reply

543 Views
harryoceana
Contributor II
/*FUNCTION**********************************************************************
 *
 * Function Name : Lpuart_Lin_Ip_TimerExpiredService
 * Description   : This is callback function for Timer Interrupt Handler.
 * Users shall initialize a timer (for example FTM)
 * and the time period in microseconds will be set by the driver via LinLpuartStartTimerNotification.
 * In timer IRQ handler, call this function.
 *
 *END**************************************************************************/
 /**
* @implements Lpuart_Lin_Ip_TimerExpiredService_Activity
*/
#if (LPUART_LIN_IP_FRAME_TIMEOUT_DISABLE == STD_OFF)
void Lpuart_Lin_Ip_TimerExpiredService(const uint8 Instance)
{
    Lpuart_Lin_Ip_StateStructType *LinCurrentState;
    const Lpuart_Lin_Ip_UserConfigType *UserConfig;

    #if (LPUART_LIN_IP_DEV_ERROR_DETECT == STD_ON)
    /* Assert parameters. */
    LPUART_LIN_IP_DEV_ASSERT(Instance < LPUART_INSTANCE_COUNT);
    #endif /* (LPUART_LIN_IP_DEV_ERROR_DETECT == STD_ON) */

    /* Get the current LIN state of this LPUART Instance. */
    LinCurrentState = Lpuart_Lin_Ip_apxStateStructureArray[Instance];
    UserConfig   = Lpuart_Lin_Ip_apxUserConfigs[Instance];

    #if (LPUART_LIN_IP_DEV_ERROR_DETECT == STD_ON)
    /* Assert parameters. */
    LPUART_LIN_IP_DEV_ASSERT(NULL_PTR != LinCurrentState);
    #endif /* (LPUART_LIN_IP_DEV_ERROR_DETECT == STD_ON) */

    #ifdef LPUART_LIN_IP_STOP_TIMER_NOTIFICATION
    LinCurrentState->TimerCounting = FALSE;
    /* Call notification to stop timer when timeout occurred */
    LPUART_LIN_IP_STOP_TIMER_NOTIFICATION(Instance);
    #endif

    /* Check LIN node's current state when timeout occurred */
    switch (LinCurrentState->CurrentNodeState)
    {
        /* If the node is receiving SYNC byte */
        case LPUART_LIN_IP_NODE_STATE_RECV_SYNC:
            /* fall-through */
        /* If the node is receiving PID byte */
        case LPUART_LIN_IP_NODE_STATE_RECV_PID:
            /* fall-through */
        /* If the node is receiving DATA response bytes */
        case LPUART_LIN_IP_NODE_STATE_RECV_DATA:
            /* fall-through */
        /* If the node is receiving CHECKSUM byte */
        case LPUART_LIN_IP_NODE_STATE_RECV_DATA_COMPLETED:
            /* Set current event to timeout error */
            LinCurrentState->CurrentEventId = LPUART_LIN_IP_TIMEOUT_ERROR;
            /* Change node's current state to IDLE to switch lin node ready operation soon */
            Lpuart_Lin_Ip_GoToIdleState(Instance);
            if (NULL_PTR != UserConfig->Callback)
            {
                UserConfig->Callback(Instance, LinCurrentState);
            }
            break;
        default:
            /* The node state is not receiving header, response data bytes or checksum */
            break;
    }
}
#endif /* (LPUART_LIN_IP_FRAME_TIMEOUT_DISABLE == STD_OFF) */

 

在Lpuart_Lin_Ip.c文件里,lin的超时处理是在这个函数里完成,这要用到定时器中断的,而不是简单的设置时间戳,如果6个lin同时工作,是需要6个定时器来避免时间干扰

0 Kudos
Reply

524 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @harryoceana,

You should call the timeout service at the end of the timeout given by the StartTimerNotification. But the implementation down to the user. The timer can be theoretically polled. But yes, using separate timers in Output Compare mode is preferable.

Regards,

Daniel

 

0 Kudos
Reply