📄 lintmr.cxgate
字号:
#define LINTMR_CXGATE
/******************************************************************************
*
* Copyright (C) 2005 Freescale Semiconductor, Inc.
* All Rights Reserved
*
* Filename: lintmr.cxgate
*
* Revision:
*
* Functions: LIN Timeout management module
*
* Description:
*
* Notes: Protocol timeouts -- only for Master node
*
******************************************************************************/
#include <hidef.h> /* common defines and macros */
#include <linxgate.h>
#include <linbase.h>
#if defined (USEXGATE)
#if defined (MASTER)
/****************************************************************************
* All common-purpose RAM variables shall be declared here.
***************************************************************************/
extern LIN_WORD LIN_IdleTimeout; /* counter for idle timeout */
#if defined (MASTER)
extern LIN_BYTE LIN_ProtocolTimeout;
extern LIN_WORD LIN_LengthCh0Tick;
#endif /* defined (MASTER) */
/****************************************************************************
* Functions
***************************************************************************/
/***************************************************************************
* Function : XLIN_CancelTimeout
*
* Description: Cancel protocol timeout
*
* Returns: none
*
* Notes: none
*
**************************************************************************/
void XLIN_CancelTimeout( void )
{
/* disable channel interrupt */
LIN_PITINTE &= ~LIN_PITINTE_PINTE; /* disable PIT Channel Interrupt*/
}
/***************************************************************************
* Function : LIN_ISR_Timer
*
* Description: Timer interrupt routine.
* Used for: LIN_MaxFrameTime,
* LIN_WakeupDelimiterTime
* timeouts maintenance.
* Also used for: break generation.
*
* Returns: none
*
* Notes:
*
**************************************************************************/
void interrupt XLIN_ISR_Timer( void )
{
LIN_DBG_SET_PORT_0;
LIN_DBG_SET_PORT_4;
--LIN_ProtocolTimeout;
if ( LIN_ProtocolTimeout == 0)
{
/* timeout expired */
/* clear interrupt flag and disable channel interrupt */
LIN_PITINTE &= ~LIN_PITINTE_PINTE; /* disable PIT channel interrupt */
LIN_PITTF = LIN_PITTF_PTF; /* clear channel interrupt flag */
XLIN_Timeout();
}
else
{
/* timeout continued */
/* arm timer Channel for next compare */
LIN_PITTF = LIN_PITTF_PTF; /* clear channel interrupt flag */
LIN_PITINTE |= LIN_PITINTE_PINTE; /* enable channel Interrupt*/
}
LIN_DBG_CLR_PORT_0;
LIN_DBG_CLR_PORT_4;
}
/***************************************************************************
* Function : XLIN_SetTimeout
*
* Description: Set protocol timeout.
* - disable channel 0 interrupt
* - set timeout
* - enable channel 0 interrupt
* - set LIN_ProtocolTimeout value
*
* Returns: none
*
* Notes: none
*
**************************************************************************/
void XLIN_SetTimeout(LIN_BYTE timeoutIndex)
{
LIN_PITINTE &= ~LIN_PITINTE_PINTE; /* at first, disable PIT channel interrupt */
LIN_LengthCh0Tick = LIN_MTO_Ticks[timeoutIndex]; /* at second, set timeout */
LIN_PITMTLD0 = LIN_CfgConst.LIN_PIT_MicroCounterValue;/* Load the micro counter 0 value into the load register */
LIN_PITLD = LIN_LengthCh0Tick; /* Load the timeout value into channel load register */
LIN_PITCFLMT |= LIN_PITCFLMT_PFLMT0; /* load the micro counter 0 */
LIN_PITFLT |= LIN_PITFLT_PFLT; /* load the channel counter */
LIN_PITTF = LIN_PITTF_PTF; /* clear channel interrupt flag */
LIN_PITINTE |= LIN_PITINTE_PINTE; /* enable channel Interrupt*/
/* set LIN_ProtocolTimeout value for this timeout */
LIN_ProtocolTimeout = LIN_MTO_Counter[timeoutIndex];
}
#endif /*defined (MASTER)*/
/***************************************************************************
* Function : XLIN_SetIdleTimeout
*
* Description: Set/reset LIN_IdleTimeout variable from constant
*
* Returns: none
*
* Notes:
*
**************************************************************************/
void XLIN_SetIdleTimeout( void )
{
//LIN_IdleTimeout = LIN_CfgConst.LIN_IdleTimeoutClocks;
LIN_IdleTimeout = LIN_IDLETIMEOUT;
}
#endif /*defined (USEXGATE)*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -