从单片机基础到程序框架(全集 2019pdf版).pdf - 第510页

VoiceSca n(); KeyScan( ); TH0=0xfc ; TL0=0x66 ; } void Syste mInitial( void) { TMOD=0x01; TH0=0xfc; TL0=0x66; EA=1; ET0=1; TR0=1; } void Delay (unsigned l ong u32Delay Time) { for(;u32 DelayTime>0 ;u32DelayT ime--); }…

100%1 / 836
{
Gu8LedStatus_P1_5=1;
LedOpen_P1_5();
}
else
{
Gu8LedStatus_P1_5=0;
LedClose_P1_5();
}
vGu8SingleKeySec=0;
break;
default:
vGu8SingleKeySec=0;
break;
}
}
void DoubleKeyTask(void)
{
if(0==vGu8DoubleKeySec)
{
return;
}
switch(vGu8DoubleKeySec)
{
case 1: //S1 S2 的组合按键触发,发出“嘀”一声
vGu8BeepTimerFlag=0;
vGu16BeepTimerCnt=KEY_VOICE_TIME;
vGu8BeepTimerFlag=1;
vGu8DoubleKeySec=0;
break;
}
}
void T0_time() interrupt 1
{
VoiceScan();
KeyScan();
TH0=0xfc;
TL0=0x66;
}
void SystemInitial(void)
{
TMOD=0x01;
TH0=0xfc;
TL0=0x66;
EA=1;
ET0=1;
TR0=1;
}
void Delay(unsigned long u32DelayTime)
{
for(;u32DelayTime>0;u32DelayTime--);
}
void PeripheralInitial(void)
{
if(0==Gu8LedStatus_P1_4)
{
LedClose_P1_4();
}
else
{
LedOpen_P1_4();
}
if(0==Gu8LedStatus_P1_5)
{
LedClose_P1_5();
}
else
{
LedOpen_P1_5();
}
}
void BeepOpen(void)
{
P3_4=0;
}
void BeepClose(void)
{
P3_4=1;
}
void LedOpen_P1_4(void)
{
P1_4=0;
}
void LedClose_P1_4(void)
{
P1_4=1;
}
void LedOpen_P1_5(void)
{
P1_5=0;
}
void LedClose_P1_5(void)
{
P1_5=1;
}
void VoiceScan(void)
{
static unsigned char Su8Lock=0;
if(1==vGu8BeepTimerFlag&&vGu16BeepTimerCnt>0)
{
if(0==Su8Lock)
{
Su8Lock=1;
BeepOpen();
}
else