timer.h

来自「WinCE 3.0 BSP, 包含Inter SA1110, Intel_815」· C头文件 代码 · 共 56 行

H
56
字号
/* -*-C-*-
 *
 * $Revision: 1.3 $
 *   $Author: kwelton $
 *     $Date: 2000/08/08 21:45:52 $
 *
 * Copyright (c) 1999 ARM Limited
 * All Rights Reserved.
 *
 * The ARMX20 has limited timer facilities.  On the ODO, the FPGA is used to
 * provide an interval timer, and this timer is used for all timing functions.
 * The timer is a 17 bit count down register with auto reload.  It is clocked
 * off a 3.686375 MHz source and is reloaded with either 0x08FFF for a 10 ms
 * period or 0x167FF for a 25 ms period.
 *
 * To get finer than 1 ms precision as provided by SC_GetTickCount, both the
 * timer register and a portion of the the CurMSec field is stored into a
 * structure.
 *
 * This structure is returned from KCP_GetStartTime.  When KCP_GetElapsedTime
 * is called, it is passed in the start time structure and makes a call to get
 * the current time structure.  Some calculations are performed, then it
 * returns the number of TVR counts.  KCP_ScaleDown takes this tick count and
 * returns the number of microseconds it represents.
 *
 * Note that since CurMSec is updated every reschedule (25ms) we know that it
 * is a multiple of 25, so we can compress the data by storing CurMSec/25 in
 * the ms time structure field.
 *
 * The maximum interval we can measure is approximately 819.2 s = 
 *
 *      (2^15 - 1) * 25 ms    +    (2^17 -1 ticks  *  (1/3686400 ticks/s))
 */

#define TVR_FIELD_MAX   0x1FFFF
#define MS_FIELD_MAX    0x7FFF

#define TIMER_PERIOD    1
typedef union
{
    unsigned int u;                   // For KCP_* interface
    struct
    {
        unsigned int tvr : 17;        // Timer Value Register
        unsigned int ms  : 15;        // CurMSec/25
    } field;
} KCPTime_t;


extern  KCPTime_t KCP_GetCurrentTime(void) ;
extern  DWORD KCP_ScaleDown(DWORD N) ;
extern  DWORD KCP_GetStartTime(void) ;
extern  DWORD KCP_GetElapsedTime(DWORD t0) ;

/* EOF timer.h */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?