📄 at89c52.c
字号:
/*-TAB=2-------------------------------------------------------------------*/
/**------------------------------------------------------------------------*
* *
* NAME:Display.c *
* *
* *
* UPDATE: 2002/8/15 YCD *
* *
* *
* *
*-------------------------------------------------------------------------*/
#include "..\SRC\ZM.H"
#define TL0_VALUE 0x18
#define TH0_VALUE 0xFC
void DelayMs(BYTE aCount);
BYTE gMsCount=0;
WORD gTimeCount=0;
BYTE gSecondTm=0;
BYTE gStandbyTmCount=0;
extern BYTE gMpgTmCount;
extern BYTE gLedTmCount;
extern WORD gRadioKeyToAutoTmCount;
extern WORD gCloseMuteWaitTm;
/**
*@void InitAt89c52(void)
*@update 2002/8/20
*/
void InitAt89c52(void)
{
IE=0;
/*TF1 TR1 TF0 TR0|IE1 IT1 IE0 IT0*/
/* 0 0 0 0 0 1 0 1 */
TCON=0X05;
/*GATE C/T M1 M0|GATE C/T M1 M0 */
/* 0 0 0 1 0 0 0 1 */
TMOD=0X11;
TL0=TL0_VALUE;
TH0=TH0_VALUE;
TL1=0;
TH1=0;
ET0=1;
EX1=1;
TR0=1;
TR1=1;
EA=1;
}
/**
*@interrupt [0x0B] void T0_int (void)
*@1ms
*@update 2002/8/20
*/
interrupt [0x0B] void T0_int (void)
{
gMsCount++;
if(gMpgTmCount) gMpgTmCount--;
if(gLedTmCount) gLedTmCount--;
if(gStandbyTmCount) gStandbyTmCount--;
if(gRadioKeyToAutoTmCount) gRadioKeyToAutoTmCount--;
if(gCloseMuteWaitTm) gCloseMuteWaitTm--;
if(gTimeCount==0){
gSecondTm++;
gTimeCount=1001;
}
gTimeCount--;
TL0=TL0_VALUE;
TH0=TH0_VALUE;
}
#ifdef EX0_INTERRUPTE
/**
*@interrupt [0x03] void EX0_int (void)
*@update 2002/8/20
*/
interrupt [0x03] void EX0_int (void) /* External Interrupt 0 */
{
}
#endif
/*-----------------------------------------------------------------------*/
bit gStandbyKey=P2.0;
bit gboolStandbyContinueKey;
/**
*@BYTE IsPressStandBy(void)
*@reutn 1:have 0:no
*@update 2002/9/19
*/
BYTE IsPressStandBy(void)
{
BYTE Result=0;
if(gStandbyKey==BIT_HI) gboolStandbyContinueKey=0;
if(gboolStandbyContinueKey==0){
if(gStandbyTmCount==0){
if(gStandbyKey==BIT_LOW){
gboolStandbyContinueKey=1;
gStandbyTmCount=100;
Result=1;
}
}
}
return(Result);
}
/*-------------------------------------------------------------------------*/
CTimeOut gGroupTime[INDEX_TOTAL];
/**
*@void InitTime(BYTE aIndex,BYTE aCount)
*@PARAM aIndex>=0X80 is second or aIndex<0X80 is Ms
*@UPDATE 2002/8/13
*/
void InitTime(BYTE aIndexType,BYTE aCount)
{
BYTE i=aIndexType&0x7f;
gGroupTime[i].mPrevTime=(aIndexType>0x7f)?gSecondTm:gMsCount;
gGroupTime[i].mCount=aCount;
}
/**
*@BYTE IsTimeOUt(BYTE aIndex)
*@PARAM aIndex>=0X80 is second or aIndex<0X80 is Ms
*@UPDATE 2002/8/13
*/
BYTE IsTimeOut(BYTE aIndexType)
{
BYTE CurTime,Result=0;
BYTE i=aIndexType&0x7f;
if(gGroupTime[i].mCount==0) Result=1;
else{
CurTime=(aIndexType>0x7f)?gSecondTm:gMsCount;
if(CurTime!=gGroupTime[i].mPrevTime){
gGroupTime[i].mCount--;
gGroupTime[i].mPrevTime=CurTime;
}
}
return(Result);
}
/**
*@void DelayMs(BYTE aCount)
*@update 2002/9/8
*/
void DelayMs(BYTE aCount)
{
InitTime(INDEX_DELAY_MS,aCount);
while( !IsTimeOut(INDEX_DELAY_MS) );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -