📄 main.lst
字号:
C51 COMPILER V7.02b MAIN 03/02/2006 18:25:03 PAGE 1
C51 COMPILER V7.02b, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #define __SRC
2 #include "main.h"
3 #undef __SRC
4
5 #include "zlg500B.h"
6
7 #define MF1_S50 0
8 #define MF1_S70 1
9 #define MF0_ULIGHT 2
10 #define MF1_LIGHT 3
11
12 sbit zlg500B_RST=P1^4;
13
14 uchar baud_num;
15
16 uchar card_snr[8];
17
18 void serial_init(void);
19
20 uchar code Nkey_a[6] = {0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5};
21 uchar code Nkey_b[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
22
23 main()
24 {
25 1 uchar cardtype=MF1_S50;
26 1 uchar i,j=40;
27 1 uchar databuf[16];
28 1 long value=1;
29 1
30 1 for(i=255;i>0;i--)
31 1 for(j=10;j>0;j--);
32 1 zlg500B_RST=0;
33 1 for(i=255;i>0;i--)
34 1 for(j=20;j>0;j--);
35 1
36 1 baud_num=2;
37 1 serial_init();
38 1 EA=1;
39 1
40 1 //i=mifs_config();
41 1
42 1 i=mifs_get_info(databuf);
43 1 // i=mifs_close();
44 1 // i=mifs_config();
45 1 // i=mifs_load_key(KEYA,15,Nkey_a);
46 1 i=mifs_load_key(KEYA,5,Nkey_b);
47 1 // i=mifs_read_E2(0x10,16,databuf);
48 1 // i=mifs_read_E2(0x20,16,databuf);
49 1 // databuf[0]=0x58;
50 1 // i=mifs_write_E2(0x11,1,databuf);
51 1 i=mifs_write_reg(0x11,0x59);
52 1 i=mifs_write_reg(0x12,0x01); //这两个函数可将读卡距离最短,功耗最低
53 1
54 1 while(1)
55 1 {
C51 COMPILER V7.02b MAIN 03/02/2006 18:25:03 PAGE 2
56 2 while(mifs_request(IDLE,databuf)!=MI_OK);
57 2 if(mifs_cascanticoll(ANTICOLL1,0,card_snr)!=MI_OK) continue;
58 2 if(mifs_cascselect(ANTICOLL1,card_snr,&i)!=MI_OK) continue;
59 2 if(i&0x04)
60 2 {
61 3 if(mifs_cascanticoll(ANTICOLL2,0,card_snr+4)!=MI_OK) continue;
62 3 if(mifs_cascselect(ANTICOLL2,card_snr+4,&i)!=MI_OK) continue;
63 3 }
64 2
65 2 if(cardtype == MF1_S50)
66 2 {
67 3 if(mifs_authentication(KEYA,5)!=0) continue;
68 3 databuf[0]=0x10;
69 3 databuf[4]=~0x10;
70 3 databuf[8]=0x10;
71 3 for(i=1;i<4;i++)
72 3 {
73 4 databuf[i]=0x00;
74 4 databuf[4+i]=0xff;
75 4 databuf[8+i]=0x00;
76 4 }
77 3 databuf[12]=0x14;
78 3 databuf[13]=~0x14;
79 3 databuf[14]=0x14;
80 3 databuf[15]=~0x14;
81 3 if(mifs_write(0x14,databuf)!=0) continue;
82 3 databuf[0]=0;
83 3 if(mifs_read(0x14,databuf)!=0) continue;
84 3 value=1;
85 3 if(mifs_value(PICC_DECREMENT,0x14,&value,0x15)!=0) continue;
86 3 if(mifs_read(0x15,databuf)!=0) continue;
87 3 if(mifs_value(PICC_INCREMENT,0x14,&value,0x16)!=0) continue;
88 3 if(mifs_read(0x16,databuf)!=0) continue;
89 3 }
90 2 else if(cardtype == MF1_S70)
91 2 {
92 3 if(mifs_authentication2(KEYA,39,5)!=0) continue;
93 3 if(mifs_read(240,databuf)!=0) continue;
94 3 }
95 2 else if(cardtype == MF0_ULIGHT)
96 2 {
97 3 databuf[0]=0x11;
98 3 databuf[1]=0x22;
99 3 databuf[2]=0x33;
100 3 databuf[3]=0x44;
101 3 if(mifs_ULwrite(15,databuf)!=0) continue;
102 3 databuf[0]=0x00;
103 3 databuf[1]=0x00;
104 3 databuf[2]=0x00;
105 3 databuf[3]=0x00;
106 3 if(mifs_read(15,databuf)!=0) continue;
107 3 }
108 2 else if(cardtype == MF1_LIGHT)
109 2 {
110 3 if(mifs_authKey(KEYA,2,Nkey_b)!=0) continue;
111 3 databuf[0]=0x10;
112 3 databuf[1]=0x00;
113 3 databuf[2]=0xef;
114 3 databuf[3]=0xff;
115 3 if(mifs_write(4,databuf)!=0) continue;
116 3 databuf[0]=0xff;
117 3 databuf[1]=0xff;
C51 COMPILER V7.02b MAIN 03/02/2006 18:25:03 PAGE 3
118 3 databuf[2]=0xff;
119 3 databuf[3]=0xff;
120 3 if(mifs_write(5,databuf)!=0) continue;
121 3 if(mifs_read(4,databuf)!=0) continue;
122 3 if(databuf[0]!=~databuf[2] || databuf[1]!=~databuf[3])
123 3 continue;
124 3 value=1;
125 3 if(mifs_valuedebit(0xc0,4,&value)!=0) continue;
126 3 if(mifs_read(4,databuf)!=0) continue;
127 3 }
128 2
129 2 mifs_halt();
130 2 // mifs_reset(1);
131 2
132 2 // i=mifs_write_E2(0x30,16,databuf);
133 2 // if(i!=0) continue;
134 2 mifs_clr_control_bit();
135 2 mifs_buzzer(250,20,10,3);
136 2 while(mifs_set_control_bit()!=0);
137 2 }
138 1 }
139
140
141
142
143
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -