?? jtimer.c
字號:
/*--------------------------------------------------------------------
TIMER.C
--------------------------------------------------------------------
Copyright (C) 1998-2004 Vector Informatik GmbH, Stuttgart
Function: Implementation of timer dependent routines
--------------------------------------------------------------------
* Comments: Includes BAM and CMDT
*
*
* Version Date Author Comments
* ------- ---------- -------------- ------------------------------
* 0.9 --.--.-- Hi Create
* 2.0 18.06.2001 Ma Version 2.0 new buffer concept and
* documented for doxygen
* 2.1 16.07.2003 Ma removed unused variables
* 2.2 24.06.2004 Ma removed unused function 'TimerHandler()'
*
* Copyright (c) 1998 - 2004 Vector Informatik GmbH
*/
/*--------------------------------------------------------------------*/
/* include files */
/*--------------------------------------------------------------------*/
#ifdef WIN32
# define STRICT
# include <windows.h>
#endif
#include "Includes.h"
#include "PortAB.h"
#include "Types.h"
#include "J1939.h"
#include "JTarget.h"
#include "JCanCntrl.h"
#include "JTimerDef.h"
#include "J1939CFG.h"
#include "J1939PGN.h"
#include "J1939TRA.h"
#include "J1939EXT.h"
#include <stdio.h>
/*--------------------------------------------------------------------*/
/* variable definitions */
/*--------------------------------------------------------------------*/
STATIC WORD DATA wSystemTime; /*!< basic period of the timer */
STATIC WORD DATA wTimerIncrement; /*!< incremented every interrupt */
#pragma CODE_SEG NON_BANKED
void Tim_PIT(void)
{
Timer_ClearPendingInterrupt();
wTimerIncrement = (WORD)(wTimerIncrement + wSystemTime);
Tim_ReloadTimer();
} /* Tim_PIT */
#pragma CODE_SEG DEFAULT_ROM
/*!
\brief Initialize system timer.
This function is called from the protocol stack to set up the system timer.
An optional hardware timer is configured.
\param wTime - basic period of the system timer
*/
void Tim_InitTimer(WORD wTime)
{
wSystemTime = wTime;
wTimerIncrement = 0;
#if TIME_FROM_OS == 1
#else
Tim_ConfigureTimer();
#endif /* TIME_FROM_OS == 1 */
} /* Tim_InitTimer */
/*!
\brief Start system timer.
This function is called from the protocol stack to start the system timer.
An optional hardware timer is enabled.
\retval TRUE - timer is running
\retval FALSE - timer not successful started
*/
BOOLEAN Tim_StartTimer(void)
{
#if TIME_FROM_OS == 1
#else
Tim_EnableTimer();
#endif /* TIME_FROM_OS == 1 */
return TRUE;
} /* Tim_StartTimer */
/*!
\brief Stop system timer.
This function is called from the protocol stack to stop the system timer.
An optional hardware timer is disabled.
\retval TRUE - timer has been stopped
\retval FALSE - timer not stopped
*/
BOOLEAN Tim_StopTimer(void)
{
#if TIME_FROM_OS == 1
#else
Tim_DisableTimer();
#endif /* TIME_FROM_OS == 1 */
return TRUE;
} /* Tim_StopTimer */
/*!
\brief Get the current time.
This function is called from the protocol stack to get the current value
of the system timer.
\return current time
*/
BOOLEAN Tim_CheckTimeOut(WORD wTimeStart, WORD wTimeNow, WORD wTimeOut)
/* END_FCTCALL *************************************************************/
{
#define wActivateCounter ((WORD)(wTimeOut+wTimeStart))
if (wActivateCounter > wTimeStart)
{
if ((wTimeNow >= wActivateCounter) ||
(wTimeNow < wTimeStart))
{
return TRUE;
}
}
else if ((wTimeNow >= wActivateCounter) &&
(wTimeNow < wTimeStart))
{
return TRUE;
}
return FALSE;
}
WORD Tim_GetCurrentTime(void)
{
#if TIME_FROM_OS == 1
# ifdef WIN32
return (WORD)GetTickCount();
# else
return (WORD)GetOsTicks();
# endif /* WIN32 */
#endif
#if TIME_FROM_OS == 2
return (WORD)(10*OSTimeGet());
#else
return wTimerIncrement;
#endif /* else TIME_FROM_OS == 1 */
} /* Tim_GetCurrentTime */
/*--------------------------------------------------------------------*/
/* documentation */
/*--------------------------------------------------------------------*/
/*!
\file
\brief Implementation of timer dependent routines.
*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -