⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.c

📁 凌阳MP3 spSPCA755yuanma
💻 C
字号:
/*++

Copyright (c) 2001 Sunplus Technology Co., Ltd.

Module Name:

        timer.c

Abstract:

        Module related to timer

Environment:

        Keil C51 Compiler

Note:

        Since in-line assembly code is included, pre-compile C51 file
        to A51 file. Then assemble A51 file.

Revision History:

        08/28/2001      Chi-Yeh Tsai    created

--*/

//=============================================================================
//Header file
//=============================================================================
#include "general.h"
#include "timer.h"
#include "cardlink.h"
#include "main.h"
#include "SPL10.h"


//=============================================================================
//Symbol
//=============================================================================
//-----------------------------------------------------------------------------
//Constant
//-----------------------------------------------------------------------------
data UCHAR  TMEvent;
data UCHAR  G_TMintervalMSB, G_TMintervalLSB;
xdata UCHAR  _1sec,_2sec, _3sec;
xdata UCHAR G_ShowDelay2Sec;
//-----------------------------------------------------------------------------
//Variable
//-----------------------------------------------------------------------------
xdata ULONG G_TimeStamp;
xdata UCHAR G_KeyScan;
xdata UCHAR G_Timer0Stop;
extern xdata UCHAR	G_IsKeyRelease;
//=============================================================================
//add by xyq
unsigned char xdata  G_SPL_BlinkTimer;
unsigned char xdata  G_SPL_BattBlinkTimer;
unsigned char xdata  G_Busy_Timer;
unsigned char xdata  G_Power_Off_Timer;
unsigned char xdata  G_LED_Blink_On_Timer;
unsigned char xdata  G_Battery_Detect_Timer;
// add Chamber for USB Plug-in Time out for switch to USB power charge!
unsigned char xdata  G_USB_PlugInTimeOut;
unsigned char xdata  G_AutoRepTimer;
//=============================================================================
//Program
//=============================================================================
void	TMEventSeg0(void);
void	TMEventSeg1(void);
void	TMEventSeg2(void);
void	TMEventSeg3(void);
void	TMEventSeg4(void);
void	TMEventSeg5(void);
void	TMEventSeg6(void);
void	TMEventSeg7(void);
void	TMEventSeg8(void);
void	TMEventSeg9(void);
void	TMEventSegA(void);
void	TMEventSegB(void);
void	TMEventSegC(void);
void	TMEventSegD(void);
void	TMEventSegE(void);
void	TMEventSegF(void);
//--
//data USHORT *TMEventFun;
#if ( SIMULATE == 0 ) // WMP3

code void (code *TMEventFun[])(void)= { TMEventSeg0, TMEventSeg1, TMEventSeg2, TMEventSeg3,  \
					TMEventSeg4, TMEventSeg5, TMEventSeg6, TMEventSeg7,  \
					TMEventSeg8, TMEventSeg9, TMEventSegA, TMEventSegB,  \
					TMEventSegC, TMEventSegD, TMEventSegE, TMEventSegF,  \	 
					NULL
                                      };
# endif										

//---
void	TMEvent_EVEN(void);		
void	TMEvent_ODD(void);		
void	TMEvent_4XTM0(void);		
void	TMEvent_4XTM1(void);		
void	TMEvent_4XTM2(void);		
void	TMEvent_4XTM3(void);		
void	TMEvent_8XTM0(void);		
void	TMEvent_8XTM1(void);		
void	TMEvent_8XTM2(void);		
void	TMEvent_8XTM3(void);		
void	TMEvent_8XTM4(void);		
void	TMEvent_8XTM5(void);		
void	TMEvent_8XTM6(void);		
void	TMEvent_8XTM7(void);		

void	TMEvent_16XTM0(void);		
void	TMEvent_16XTM1(void);		
void	TMEvent_16XTM2(void);		
void	TMEvent_16XTM3(void);		
void	TMEvent_16XTM4(void);		
void	TMEvent_16XTM5(void);		
void	TMEvent_16XTM6(void);		
void	TMEvent_16XTM7(void);		
void	TMEvent_16XTM8(void);		
void	TMEvent_16XTM9(void);		
void	TMEvent_16XTMA(void);		
void	TMEvent_16XTMB(void);		
void	TMEvent_16XTMC(void);		
void	TMEvent_16XTMD(void);		
void	TMEvent_16XTME(void);		
void	TMEvent_16XTMF(void);		
//-----------------------------------------------------------------------------
//                               TIMER0
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//TIMER0
//-----------------------------------------------------------------------------
void TIMER0_Routine(void) INTERRUPT_1 USING_2
{
     EX0 = 0;
#if ( SIMULATE == 0 )
#pragma asm
     CLR     TR0
//     MOV     A,#K_Timer0IntervalCompLo       ; 2 Instr. Cycles
	 MOV	 A, G_TMintervalLSB				 ; 2 Instr. Cycles
     ADD     A,TL0                           ; 2 Instr. Cycles
     MOV     TL0,A                           ; 2 Instr. Cycles
//     MOV     A,#K_Timer0IntervalCompHi       ; 2 Instr. Cycles
	 MOV	 A, G_TMintervalMSB				 ; 2 Instr. Cycles
     ADDC    A,TH0                           ; 2 Instr. Cycles
     MOV     TH0,A                           ; 2 Instr. Cycles
     NOP                                     ; 1 Instr. Cycles
     NOP                                     ; 1 Instr. Cycles
     NOP                                     ; 1 Instr. Cycles
     NOP                                     ; 1 Instr. Cycles
     SETB    TR0                             ; 2 Instr. Cycles
                                             ;-----------------------------
                                             ; 14 Instr. Cycles Total =
                                             ; 18 * (4 / 24M) us =
                                             ; 3 us
	 mov    A, TMEvent
	 inc	A
	 anl	A, #0Fh
	 mov	TMEvent, A
#pragma endasm
#endif
	 
	#if ( SIMULATE == 0 ) // WMP3
	 (*TMEventFun[TMEvent])();
	#endif
	 
     EX0 = 1;
}
//-----------------------------------------------------------------------------
//TIMER0_Start
//-----------------------------------------------------------------------------
//ada@0415 test ui
//patch4.2@ada@0527 for key scan
void TIMER0_Start(void) USING_0
{
     G_KeyScan = 0;
     G_Timer0Stop = 0;

     //start timer
     ET0 = 1;                //IE:    TIMER0 interrupt enable
     TR0 = 1;                //TCON:  TIMER0 enable
}

//==============================
//          TIMER0_Stop
//==============================
//ada@0415 test ui
//patch4.2@ada@0527 for key scan
void TIMER0_Stop(void) USING_0
{
     G_Timer0Stop = 1;

     //stop timer
     TR0 = 0;                //TCON:  TIMER0 disable
     ET0 = 0;                //IE:    TIMER0 interrupt disable
}

void	TMEventSeg0(void)
{
		TMEvent_EVEN();		
		TMEvent_4XTM0();		
		TMEvent_8XTM0();		
		TMEvent_16XTM0();		
}

void	TMEventSeg1(void)
{
//		 DbgPrint("TMEsegment 1 \n");
		TMEvent_ODD();		
		TMEvent_4XTM1();		
		TMEvent_8XTM1();		
		TMEvent_16XTM1();		
}

void	TMEventSeg2(void)
{
		TMEvent_EVEN();		
		TMEvent_4XTM2();		
		TMEvent_8XTM2();		
		TMEvent_16XTM2();		
}

void	TMEventSeg3(void)
{
		TMEvent_ODD();		
		TMEvent_4XTM3();		
		TMEvent_8XTM3();		
		TMEvent_16XTM3();		
}

void	TMEventSeg4(void)
{
		TMEvent_EVEN();		
		TMEvent_4XTM0();		
		TMEvent_8XTM4();		
		TMEvent_16XTM4();		
}

void	TMEventSeg5(void)
{
		TMEvent_ODD();		
		TMEvent_4XTM1();		
		TMEvent_8XTM5();		
		TMEvent_16XTM5();		
}

void	TMEventSeg6(void)
{
		TMEvent_EVEN();		
		TMEvent_4XTM2();		
		TMEvent_8XTM6();		
		TMEvent_16XTM6();		
}

void	TMEventSeg7(void)
{
		TMEvent_ODD();		
		TMEvent_4XTM3();		
		TMEvent_8XTM7();		
		TMEvent_16XTM7();		
}

void	TMEventSeg8(void)
{
		TMEvent_EVEN();		
		TMEvent_4XTM0();		
		TMEvent_8XTM0();		
		TMEvent_16XTM8();		
}

void	TMEventSeg9(void)
{
		TMEvent_ODD();		
		TMEvent_4XTM1();		
		TMEvent_8XTM1();		
		TMEvent_16XTM9();		
}

void	TMEventSegA(void)
{
		TMEvent_EVEN();		
		TMEvent_4XTM2();		
		TMEvent_8XTM2();		
		TMEvent_16XTMA();		
}

void	TMEventSegB(void)
{
		TMEvent_ODD();		
		TMEvent_4XTM3();		
		TMEvent_8XTM3();		
		TMEvent_16XTMB();		
}

void	TMEventSegC(void)
{
		TMEvent_EVEN();		
		TMEvent_4XTM0();		
		TMEvent_8XTM4();		
		TMEvent_16XTMC();		
}

void	TMEventSegD(void)
{
		TMEvent_ODD();		
		TMEvent_4XTM1();		
		TMEvent_8XTM5();		
		TMEvent_16XTMD();		
}

void	TMEventSegE(void)
{
		TMEvent_EVEN();		
		TMEvent_4XTM2();		
		TMEvent_8XTM6();		
		TMEvent_16XTME();		
}

void	TMEventSegF(void)
{
		TMEvent_ODD();		
		TMEvent_4XTM3();		
		TMEvent_8XTM7();		
		TMEvent_16XTMF();		
}

void	TMEvent_EVEN(void)
{
}		

void	TMEvent_ODD(void)		
{
}
		
void	TMEvent_4XTM0(void)		
{
//lstimer++;
}
		
void	TMEvent_4XTM1(void)		
{

 
	 
	_UIEvent = TRUE;
//	TIMER0_Keypad_Scan();
}	
	
void	TMEvent_4XTM2(void)		
{
}
		
void	TMEvent_4XTM3(void)		
{
}
		
void	TMEvent_8XTM0(void)		
{
}

void	TMEvent_8XTM1(void)		
{
}
		
void	TMEvent_8XTM2(void)		
{
}
		
void	TMEvent_8XTM3(void)		
{
}
		
void	TMEvent_8XTM4(void)		
{
}
		
void	TMEvent_8XTM5(void)		
{
}
		
void	TMEvent_8XTM6(void)		
{
}
				
void	TMEvent_8XTM7(void)		
{
}
		
void	TMEvent_16XTM0(void)		
{
}
		
void	TMEvent_16XTM1(void)		
{
	
}
		
void	TMEvent_16XTM2(void)		
{
	if(G_SPL_BattBlinkTimer) G_SPL_BattBlinkTimer--;
}
		
void	TMEvent_16XTM3(void)		
{
	if(G_SPL_BlinkTimer) G_SPL_BlinkTimer--;
}		
void	TMEvent_16XTM4(void)		
{
	if(G_Busy_Timer) G_Busy_Timer--;
}
void	TMEvent_16XTM5(void)		
{
	if(G_Power_Off_Timer) G_Power_Off_Timer--;
}		
void	TMEvent_16XTM6(void)		
{
	if(G_LED_Blink_On_Timer) G_LED_Blink_On_Timer--;
}		
void	TMEvent_16XTM7(void)		
{
	if(G_Battery_Detect_Timer) G_Battery_Detect_Timer--;
}
		
void	TMEvent_16XTM8(void)		
{
	if(G_USB_PlugInTimeOut) G_USB_PlugInTimeOut--;		
}
		
void	TMEvent_16XTM9(void)		
{
	if(G_AutoRepTimer) G_AutoRepTimer--;
}
		
void	TMEvent_16XTMA(void)		
{
}
		
void	TMEvent_16XTMB(void)		
{
}
		
void	TMEvent_16XTMC(void)		
{
}
		
void	TMEvent_16XTMD(void)		
{
}
		
void	TMEvent_16XTME(void)		
{
}
		
void	TMEvent_16XTMF(void)		
{
	if(_TClock) 
	{
		G_Time_SecBase ++;
		if(!(G_Time_SecBase & 0x03)) _SecBase = TRUE;
	}
}
                                               



//-----------------------------------------------------------------------------
//TIMER0_GetGPIOByte
//-----------------------------------------------------------------------------
//ada@0415 test ui
/*
UCHAR TIMER0_GetGPIOByte (UCHAR Index, UCHAR *GPIOByteValPt) USING_2
{
  USHORT Addr;
  UCHAR status = 0x00;
      
  Addr = 0x2040|(USHORT)(Index>>3);
  *GPIOByteValPt = XBYTE[Addr];
  
  return status;
}
*/
/*
//-----------------------------------------------------------------------------
//                               TIMER1
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//TIMER1
//-----------------------------------------------------------------------------
void TIMER1_Routine(void) INTERRUPT_3 USING_3
{
        EX0 = 0;
        TIMER1_Handler();     //TIMER1 handler
        EX0 = 1;
}

//-----------------------------------------------------------------------------
//TIMER1_Handler
//-----------------------------------------------------------------------------
void TIMER1_Handler(void) USING_3
{
        TR1 = 0 ;
        TH1 = K_Timer1IntervalHi;
        TL1 = K_Timer1IntervalLo;
        TR1 = 1 ;
}

//-----------------------------------------------------------------------------
//TIMER1_Start
//-----------------------------------------------------------------------------
void TIMER1_Start(void) USING_3
{
        //start timer
        ET1 = 1;                //IE:    TIMER1 interrupt enable
        TR1 = 1;                //TCON:  TIMER1 enable
}

//-----------------------------------------------------------------------------
//TIMER1_Stop
//-----------------------------------------------------------------------------
void TIMER1_Stop(void) USING_3
{
        ET1 = 0;                //IE:    TIMER1 interrupt disable
        TR1 = 0;                //TCON:  TIMER1 disable
}
*/

⌨️ 快捷键说明

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