📄 baojian.c
字号:
}
case 0x02:
{ P3M1=_bin(1,0,1,0,1,1,0,0);
if(time_start>_20S)
{
heathigh=1;
time_start=0x00;
step++;
}
break;
}
///////////////////////////
case 0x03:
{ P3M1=_bin(1,0,1,0,1,1,0,0);
if(time_start>_6S)
{
heathigh=0;
time_start=0x00;
step++;
}
break;
}
case 0x04:
{ P3M1=_bin(1,0,1,0,1,1,0,0);
if(time_start>_12S)
{
heathigh=1;
time_start=0x00;
step++;
}
break;
}
case 0x05:
{ P3M1=_bin(1,0,1,0,1,1,0,0);
if(time_start>_2S)
{
heathigh=0;
time_start=0x00;
step++;
}
break;
}
case 0x06:
{ P3M1=_bin(1,0,1,0,1,1,0,0);
if(time_start>_60S)
{
heathigh=1;
time_start=0x00;
step=0x03;
}
break;
}
default : break;
}
break;
}
case 0x02:
{
switch(step)
{
case 0x01:
{
P3M1=_bin(1,0,1,0,1,1,0,0);
heathigh=1;
time_fly1=time_start;
if(time_start>(_20S-time_fly)) //
{
TR0=0;
heathigh=0;
time_start=0x00;
time_fly1=0x00;
step++;
TR0=1;
}
break;
}
case 0x02:
{ P3M1=_bin(1,0,1,0,1,1,0,0);
if(time_start>_20S)
{
heathigh=1;
time_start=0x00;
step++;
}
break;
}
//////////////////////////////////////////
case 0x03:
{ P3M1=_bin(1,0,1,0,1,1,0,0);
if(time_start>_6S)
{
heathigh=0;
time_start=0x00;
step++;
}
break;
}
case 0x04:
{ P3M1=_bin(1,0,1,0,1,1,0,0);
if(time_start>_60S)
{
heathigh=1;
time_start=0x00;
step=0x03;
}
break;
}
default : break;
}
break;
}
case 0x03:
{
switch(step)
{
case 0x01:
{
P3M1=_bin(1,0,1,0,1,1,0,0);
heathigh=1;
//time_fly=time_start;
if(time_start>_05S) // -time_fly
{
TR0=0;
heathigh=0;
time_start=0x00;
step++;
TR0=1;
}
break;
}
case 0x02:
{ P3M1=_bin(1,0,1,0,1,1,0,0);
if(time_start>_60S)
{
heathigh=1;
time_start=0x00;
step++;
}
break;
}
case 0x03:
{
P3M1=_bin(1,0,1,0,1,1,0,0);
heathigh=1;
//time_fly=time_start;
if(time_start>_05S) // -time_fly
{
TR0=0;
heathigh=0;
time_start=0x00;
step++;
TR0=1;
}
break;
}
case 0x04:
{ P3M1=_bin(1,0,1,0,1,1,0,0);
if(time_start>_60S)
{
heathigh=1;
time_start=0x00;
step=0x03;
}
break;
}
default : step=0x03; break;
}
break;
}
default:break;
}
}
//键盘扫描void key(void);
///////////////////////////////////////////////////////
void key(void)
{
bit temp;
if(power_flag)
{
temp=strong_key;
// P3M1=_bin(1,0,1,0,1,1,0,0);
// P3M0=_bin(0,0,0,0,0,0,0,0);
P1M1=_bin(1,1,0,0,0,0,0,0);
_nop_();
strong_key=1;
_nop_();
while(!strong_key)
{ _nop_();
while(!strong_key);
strong();
}
_nop_();
strong_key=temp;
_nop_();
temp=mid_key;
_nop_();
// P3M1=_bin(1,0,1,0,1,1,0,0);
// P3M0=_bin(0,0,0,0,0,0,0,0);
P1M1=_bin(1,0,1,0,0,0,0,0);
// _nop_();
// P1M0=0x00;//_bin(0,0,0,0,0,0,0,0);
_nop_();
mid_key=1;
_nop_();
while(!mid_key)
{ _nop_();
while(!mid_key);
mid();
}
mid_key=temp;
_nop_();
temp=lack_key;
_nop_();
P3M1=_bin(1,0,1,0,0,1,0,0);
_nop_();
P3M0=0x00;//_bin(0,0,0,0,0,0,0,0);
_nop_();
P1M1=_bin(1,1,1,0,0,0,0,0);
_nop_();
P1M0=_bin(1,0,0,0,0,0,0,0);
_nop_();
lack_key=1;
_nop_();
while(!lack_key)
{ _nop_();
while(!lack_key);
lack();
}
lack_key=temp;
}
temp=on_off;
_nop_();
P3M1=_bin(1,0,1,0,1,0,0,0);
_nop_();
// P1M1=_bin(0,1,1,0,0,0,0,0);
// P1M0=_bin(0,0,0,0,0,0,0,0);
on_off=1;
_nop_();
while(!on_off)
{ _nop_();
delay05S();
while(!on_off);
delay05S();
while(!on_off);
if(working_flag==0)
{
while(!on_off);
power();
while(!on_off);
}
else
{
first_sel=0;
working_flag=0;
D1=D2=D3=D4=1;
on_off=1;
TR0=0;
TR1=0;
mode=0x00;
bell=0;
time_count=0x00;
strong_key=mid_key=lack_key=1;
power_flag=1;
time_start=0x00;
heatlow=1;
heathigh=0;
flsh_sector_rd(0x1000,0x01,&liaocheng);
}
while(!on_off);
delay05S();
while(!on_off);
delay05S();
while(!on_off);
}
on_off=temp;
_nop_();
P3M1=_bin(1,0,1,0,1,1,0,0);
_nop_();
P3M0=_bin(0,0,0,0,0,0,0,0);
_nop_();
P1M1=_bin(1,1,1,0,0,0,0,0);
_nop_();
P1M0=_bin(1,0,0,0,0,0,0,0);
}
void bell_time1(void) interrupt 3 using 2
{
TH1=0x4C;
TL1=0x00;
time_bell++;
switch(bell_style)
{
case 0x01:
{
if(bell)
{
if(time_bell>_01S)
{
bell=~bell;
time_bell=0x00;
}
}
else
{
if(time_bell>_2S)
{
bell=~bell;
time_bell=0x00;
}
}
break;
}
case 0x02:
{
if(bell)
{
if(time_bell>_01S)
{
bell=~bell;
time_bell=0x00;
P1M1=_bin(1,1,1,1,0,0,0,0);
larmlight=1;
}
}
else
{
if(time_bell>_01S)
{
bell=~bell;
time_bell=0x00;
P1M1=_bin(1,1,1,1,0,0,0,0);
larmlight=0;
}
}
break;
}
default :break;
}
}
void Door_protect(void)
{
if(Door==0)
{
TR0=TR1=0;
strong_key=mid_key=lack_key=0;
on_off=1;
bell=1;
//power_flag=0;
larmlight=0;
liaocheng=0x00;
heatlow=0;heathigh=0;
mode=0x00;
}
else if((mode==0x00)&(liaocheng==0x00))
{
larmlight=1;
bell=0;
if(power_flag==1)
{
bell=0;
strong_key=mid_key=lack_key=1;
power_flag=1;
heatlow=1;
}
}
}
//************************************//
//main()
//////////////////////////////////////
void main(void)
{
P3M1=_bin(1,0,1,0,1,1,0,0);
P3M0=_bin(0,0,0,0,0,0,0,0);
P1M1=_bin(1,1,1,1,0,0,0,0);
P1M0=_bin(1,0,0,0,0,0,0,0);
D1=D2=D3=D4=larmlight=1;
heatlow=heathigh=bell=0;
strong_key=mid_key=lack_key=0;
first_power_on=0;
on_off=1;
TH0=0x4c;
TL0=0x00;
TH1=0x4C;
TL1=0x00;
TMOD=0x11;
time_fly1=0x00;
ET0=ET1=EA=1;
while(1)
{
key();
timer1_LED();
working();
alarm();
Door_protect();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -