Академический Документы
Профессиональный Документы
Культура Документы
h>
void lcd_int();
void busycheck();
void delay();
void delay1();
void delay2();
void get_key_read();
void change_password();
void user_change_password();
void display_lcd(char *ptr);
void enter_password(char ch);
void wrong_password();
void press1_or_2();
void open_door();
void stepper_motor_control();
void wrong_password_ex();
strcompare(char *ptr,char *ptr1);
void strcopy(char *ptr,char *ptr1);
char xdata *CON;
char xdata *pa;
char xdata *pb;
char xdata *pc;
char xdata *CON1;
char xdata *pa1;
char xdata *pb1;
char xdata *pc1;
System
";
CON = 0xff0f;
pa = 0xff0c;
pb = 0xff0d;
pc = 0xff0e;
*CON=0x83;
of port c as a input port
*pa = 0x0f;
*pb = 0x00;
*pc = 0x00;
IOCNT=0xffc0;
DCNT=0xffc4;
lcd_int();
while(1)
{
back:
get_key_read();
cmp=strcompare(s_p_word,p_word);
//compare password
if(cmp==0)
{
change_password();
if(ch=='1')
{
display_lcd(arr3);
stepper_motor_control();
}
else
{
user_change_password();
goto back;
}
count=0;
}
else
{
count++;
if(!(count<3))
{
*CON=0x82;
is a output port
display_lcd(arr5);
*pc=0x01;
//access disconnect
//Port C assign Busser
while(1);
}
else
{
wrong_password();
delay1();
}
}
}
}
void get_key_read()
{
display_lcd(arr);
while(i<5)
{
*pa=0x00;
while((*pb&0x0f)==0x0f);
*pa=0x0e;
if(!((*pb & 0x0f)==0x0f))
{
switch(*pb & 0x0f)
{
case 0x0e:p_word[i]='0';
break;
case 0x0d:p_word[i]='1';
break;
case 0x0b:p_word[i]='2';
break;
case 0x7:p_word[i]='3';
break;
}
}
else
{
*pa=0x0d;
if(!((*pb & 0x0f)==0x0f))
{
break;
case 0x0d:p_word[i]='5';
break;
case 0x0b:p_word[i]='6';
break;
case 0x07:p_word[i]='7';
break;
}
}
else
{
*pa=0x0b;
if(!((*pb & 0x0f)==0x0f))
{
case 0x0d:p_word[i]='9';
break;
case 0x0b:p_word[i]='a';
break;
case 0x07:p_word[i]='b';
break;
}
}
else
{
*pa=0x07;
if(!((*pb & 0x0f)==0x0f))
{
switch(*pb & 0x0f)
{
case 0x0e:p_word[i]='c';
break;
case 0x0d:p_word[i]='d';
break;
case 0x0b:p_word[i]='e';
break;
case 0x07:p_word[i]='f';
break;
}
}
}
}
if(!(count1==1))
enter_password('*');
else
enter_password(p_word[i]);
i++;
delay2();
}
p_word[i]='\0';
i=0;
}
void stepper_motor_control()
{
int i,j,k;
CON1=0xff13;
pa1=0xff10;
pb1=0xff11;
pc1=0xff12;
*CON1=0x80;
*pa1=0x00;
*pb1=0x00;
*pc1=0x00;
for(i=0,j=0;j<=45;j++,i++)
{
if((j>10)&&(*pc==0x00))
check when ever open the door
{
break;
}
i=i & 3;
delay2();
*pa1=s_arr[i];
}
display_lcd(arr4);
for(i=0,k=0;k<=j;k++,i++)
{
i=i & 3;
delay2();
*pa1=s_arr1[i];
void user_change_password()
routine
{
count1++;
get_key_read();
strcopy(s_p_word,p_word);
count1=0;
void change_password()
{
int i;
busycheck();
display_lcd(arr6);
for(i=0;arr7[i]!='\0';i++)
{
busycheck();
*IOCNT=0x00;
*DCNT=0xc0+i;
busycheck();
*IOCNT=0x01;
*DCNT=arr7[i];
delay();
}
press1_or_2();
}
void press1_or_2()
{
*pa=0x00;
while((*pb&0x0f)==0x0f);
*pa=0x0e;
if(!((*pb & 0x0f)==0x0f))
{
switch(*pb & 0x0f)
{
case 0x0d:ch='1';
break;
selection
case 0x0b:ch='2';
break;
default:
goto jumb;
}
}
else
{
jumb:
display_lcd(arr8);
delay1();
change_password();
}
}
void enter_password(char ch)
{
delay();
busycheck();
*IOCNT=0x00;
*DCNT=0x89+i;
busycheck();
*IOCNT=0x01;
*DCNT=ch;
busycheck();
*IOCNT=0x00;
*DCNT=0x01;
for(i=0;*ptr!='\0';i++)
{
busycheck();
*IOCNT=0x00;
*DCNT=0x80+i;
busycheck();
*IOCNT=0x01;
*DCNT=*ptr;
ptr++;
}
}
void wrong_password()
{
int i;
delay();
display_lcd(arr1);
for(i=0;arr2[i]!='\0';i++)
{
busycheck();
*IOCNT=0x00;
*DCNT=0xC0+i;
busycheck();
*IOCNT=0x01;
*DCNT=arr2[i];
}
}
void delay()
{
int i,j;
for(i=0;i<0xfff;i++);
for(j=0;j<0xfff;j++);
}
void delay1()
{
int i,j;
for(i=0;i<0xfff;i++)
for(j=0;j<0x55;j++);
}
void delay2()
{
int j,m;
for(m=0;m<=0xff;m++)
for(j=0;j<=0xff;j++);
}
void busycheck()
{
delay();
*IOCNT=0x02;
while((*DCNT&0x80)!=0);
*IOCNT=0x00;
}
void lcd_int()
{
int i;
busycheck();
*IOCNT=0x00;
*DCNT=0x38;
busycheck();
*IOCNT=0x00;
//clear display
*DCNT=0x01;
busycheck();
*IOCNT=0x00;
*DCNT=0x80;
busycheck();
*IOCNT=0x00;
*DCNT=0x04;
busycheck();
*IOCNT=0x00;
*DCNT=0x0e;
for(i=0;array2[i]!='\0';i++)
{
busycheck();
*IOCNT=0x00;
*DCNT=0x80+i;
busycheck();
*IOCNT=0x01;
*DCNT=array2[i];
}
for(i=0;array1[i]!='\0';i++)
{
busycheck();
*IOCNT=0x00;
*DCNT=0xc0+i;
busycheck();
*IOCNT=0x01;
*DCNT=array1[i];
delay();
}
delay1();
}