www.pudn.com > Bit1611_demo_code.rar > TIMER.H


/* ********************************************************************** 
 
         Copyright (c) 2002-2006 Beyond Innovation Technology Co., Ltd 
 
        All rights are reserved. Reproduction in whole or in parts is 
    prohibited without the prior written consent of the copyright owner. 
   ---------------------------------------------------------------------- 
 
    Module: TIMER.H 
 
    Purpose: Interface of TIMER module. 
 
    Version: 0.01                                   11:33AM  2005/11/17 
 
    Compiler: Keil 8051 C Compiler v8.01 
 
    Reference: 
 
   ---------------------------------------------------------------------- 
    Modification: 
 
    R0.01 11:33AM  2005/11/17 Jeffrey Chang 
    Reason: 
        1. Original. 
    Solution: 
 
   ********************************************************************** */ 
 
 
#ifndef _TIMER_H_ 
#define _TIMER_H_ 
 
 
/* ------------------------------------ 
    Header Files 
   ------------------------------------ */ 
#include "platform.h" 
 
 
/* ------------------------------------ 
    Macro Definitions 
   ------------------------------------ */ 
#undef EXTERN 
 
#ifdef _TIMER_C_ 
    #define EXTERN 
#else 
    #define EXTERN  extern 
#endif 
 
 
/* :::::::::::::::::::::::::::::::::::: 
   System Timer Configuration 
   :::::::::::::::::::::::::::::::::::: */ 
#define TIMER_USING             3 
 
 
#define TIMER_0                 0 
#define TIMER_1                 1 
#define TIMER_CFG               TIMER_0 
 
 
// [3]64, 89 
#define TIMER0_MODE             0x01    // Timer 0: Mode 1 (16-bit) 
#define TIMER1_MODE             0x10    // Timer 1: Mode 1 (16-bit) 
 
/* [3]89 Timer/Counter Mode Control */ 
#define TIMER_MODE              (TIMER1_MODE | TIMER0_MODE) 
 
#if (TIMER_CFG == TIMER_0)      /* [3]64 Using Timer 0 as System Timer */ 
 
    #define TIMER_INT           1   /* [2]92 Timer Interrupt Number (Vector=0x0B) */ 
    #define TIMER_RUN           TR0 /* [3]64,89 Timer 0 start running */ 
    #define TIMER_ENABLE        ET0 /* [3]64,87 Enable Timer 0 overflow interrupt */ 
    #define TIMER_COUNTER_H     TH0 /* [3]64,84 */ 
    #define TIMER_COUNTER_L     TL0 /* [3]64,84 */ 
 
#elif (TIMER_CFG == TIMER_1)    /* [3]64 Using Timer 1 as System Timer */ 
 
    #define TIMER_INT           3   /* [2]92 Timer Interrupt Number (Vector=0x1B) */ 
    #define TIMER_RUN           TR1 /* [3]64,89 Timer 1 start running */ 
    #define TIMER_ENABLE        ET1 /* [3]64,87 Enable Timer 1 overflow interrupt */ 
    #define TIMER_COUNTER_H     TH1 /* [3]64,84 */ 
    #define TIMER_COUNTER_L     TL1 /* [3]64,84 */ 
 
#else 
    #error TIMER.H - Invalid TIMER_CFG ! 
 
#endif // TIMER_CFG 
 
 
 
/* :::::::::::::::::::::::::::::::::::: 
    System Tick = 6 ms ! 
   :::::::::::::::::::::::::::::::::::: */ 
#if (CLOCK_CFG == CLOCK_X6) 
    #define MACHINE_PER_TICK    14318   /* Machine Cycles per System Tick   */ 
                                        // = 6 ms @6 clocks mode 
#else 
    #define MACHINE_PER_TICK     7159   /* Machine Cycles per System Tick   */ 
                                        // = 6 ms @12 clocks mode 
#endif // CLOCK_CFG 
 
 
#define US_PER_TICK             6000    /* Micro-second per System Tick     */ 
#define MS_PER_TICK             6       /* Milli-second per System Tick     */ 
 
 
/* ------------------------------------ 
    Variables Definitions/Declarations 
   ------------------------------------ */ 
EXTERN UW16 wTIMER_TickCnt;             // Free-run Up counter 
EXTERN UB8  bTIMER_Tick;                // One-shot down counter 
EXTERN UW16 wTIMER_Tick;                // One-shot down counter 
 
EXTERN UW16 wTIMER_BurnInTick;          // Added by JC 02:30PM  2004/08/13 
 
/* ------------------------------------ 
    Function Prototypes 
   ------------------------------------ */ 
EXTERN void TIMER_DelayMS(UW16 wMS); 
EXTERN void TIMER_Init(void); 
 
 
#endif /* _TIMER_H_ */ 
 
 
/* ********************************************************************** 
 
    Description: 
 
   ********************************************************************** */ 
 
/* %% End Of File %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */