#define uchar unsigned char
#define uint unsigned int
#define fadd 0x0000
sbit P3_7=P3^7;
uchar *q;
uchar Temp;
uint r,t,e,dat;
uchar flag=0; //用户自定义定时溢出标志位
uchar buffer[8]="00000000"; //huan cun
sbit rs=P2^7;
sbit rd=P2^6;
sbit lcden=P2^5;
sbit relay=P2^4; //定义继电器引脚
sbit laba=P2^3;
uchar DSY_BUFFER[16]=" "; //数组用于存放显示符号
uchar DSY_BUFFER1[16]=" "; //数组用于存放显示符号
uchar idata Userpassword[8]={0}; //存放用户密码
uchar code table2[8]="01234567"; //初始化密码
uchar code table[]="Input Password..";
uchar temp,i=0,j=0,k=0,n;
uchar IS_valid_user;
/*************delay************/
void delayms(uint z) //延时毫秒级
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void delay5s() //延时5s
{
unsigned char i, j, k;
_nop_();
_nop_();
i = 228;
j = 253;
k = 219;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
void delay3s() //延时3s
{
unsigned char i, j, k;
_nop_();
_nop_();
i = 137;
j = 203;
k = 232;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
void delay1s() //延时1s
{
unsigned char i, j, k;
_nop_();
_nop_();
i = 12;
j = 103;
k = 57;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
void delay()
{
unsigned char i, j, k;
_nop_();
_nop_();
i = 5;
j = 144;
k = 71;
do
{
do
{
while (--k);
} while (--j);
} while (--i);
}
/****************lcd1602******************/
void write_com(uchar com)
{
rs=0;
rd=0;
lcden=0;
P0=com;
delayms(3);
lcden=1;
delayms(3);
lcden=0;
}
void write_date(uchar date)
{
rs=1;
rd=0;
lcden=0;
P0=date;
delayms(3);
lcden=1;
delayms(3);
lcden=0;
}
void Display_String(uchar *p,uchar com)
{ uchar i;
write_com(com);
for(i=0;i<16;i++)
{
write_date(p);
}
}
void init_lcd()
{
lcden=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
Display_String(table,0x80);
Display_String("Lock OK! ",0xc0);
}
/***********EEPROM*************/
void chachu()
{
dat=0x10;
while(dat!=0)
{
IAP_CONTR=0x82;
IAP_CMD=0x03;
IAP_ADDRL=0x0000;
IAP_ADDRH=(0x0000>>8);
IAP_TRIG=0x5A;
IAP_TRIG=0xA5;
delay();
dat=(IAP_CONTR&0x10);
}
}