📄 idk.h
字号:
#define ID_Card_no ((BYTE volatile idata *)0xE0)
bdata BYTE DM,DH;
sbit Dm0 = DM^0;
sbit Dm1 = DM^1;
sbit Dm2 = DM^2;
sbit Dm3 = DM^3;
sbit Dm4 = DM^4;
sbit Dm5 = DM^5;
sbit Dm6 = DM^6;
sbit Dm7 = DM^7;
sbit Dh0 = DH^0;
sbit Dh1 = DH^1;
bit Btemp,Bdone;
bit b_Card_In;
BYTE IDCarIn, Sum2;
BYTE IDCardTime;
/*
void delay(int n)
{
int i,j;
for(i=n;i>0;i--)
for(j=100;j>0;j--);
}*/
#define H_Mth (595/256) // 2
#define L_Mth (595%256) // 83
#define H_Mtl (365/256) // 1
#define L_Mtl (365%256) // 109
#define H_MMh (295/256) // 1
#define L_MMh (295%256) // 39
#define H_MMl (180/256) // 0
#define L_MMl (180%256) // 180
#define H_M43 (310/256) // 1
#define L_M43 (310%256) // 54
void Check_IDcard(void)
{
BYTE Sum0,Sum1,IDB;
BYTE i,Hi,Li;
TR0=0; TH0=TL0=0; TR0=1;
Hi=Li=i=0;
Btemp=B_RFIN; //B_RFIN = P3^4;
if(0xFF>IDCarIn) IDCarIn++;
IDCardTime=10;
while(1){
if(Btemp!=B_RFIN){ // TO get first bit
TR0=0;
if(TH0<H_Mth || (TH0==H_Mth && TL0<L_Mth)){
if(TH0>H_Mtl || (TH0==H_Mtl && TL0>L_Mtl)){
i++; TL0=28;
if(i>5) break;
}else if((TH0<H_MMh || (TH0==H_MMh&&TL0<L_MMh))&&(TH0>H_MMl || (TH0==H_MMl&&TL0>L_MMl))){
TL0=70; i++;
}else{TL0=58; if(0!=i) i--;}
}else{TL0=12; if(0!=i) i--;}
TH0=0; TR0=1; Btemp=!Btemp;
}
if(0==IDCardTime) return; // Time Up
if(0==i){
if(TH0>H_Mth){
TR0=0;
return;
}
} // Wait for U2270B working
}
TH0=TL0=0; TR0=1;
IDCardTime=1;
Dm0=B_RFIN;
IDB=1;
i=0;
Bdone=0;
do{
while(TL0<70);
if(Dm0!=B_RFIN) return;
if(0==IDCardTime) return; // Time Up
while(TH0<H_M43 || (TH0==H_M43&&TL0<L_M43));
Btemp=B_RFIN;
while(Btemp==B_RFIN);
TR0=0;
Hi=TH0; Li=TL0;
TH0=0; TL0=10; TR0=1;
if(Hi>H_Mth || (Hi==H_Mth && Li>L_Mth)) return;
IDB++;
if(1==Bdone){
DM=DM<<1; Dm0=B_RFIN;
if(0==IDB%8){ ID_Card_no[i++]=DM; Sum0+=DM; }
if(i==7){
if(0!=IDCarIn)IDCarIn--;
if(Sum1==Sum0) break;
else { Sum1=Sum0; Bdone=0; }
}
}else{
Dh1=0;
DH=DH<<1; Dh0=Dm7;
DM=DM<<1; Dm0=B_RFIN;
if(0x02==DH && 0x00==DM){
IDB=10;
i=0;
Bdone=1;
Sum0=0;
} // Get header
}
}while(0!=IDB); // can't found the header
TR0=0;
if(i==7){
if(Sum2!=Sum0||10<IDCarIn){
IDCarIn=0;
Sum2=Sum0;
b_Card_In=1;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -