📄 zlg500.lst
字号:
C51 COMPILER V7.09 ZLG500 08/18/2006 08:26:14 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE ZLG500
OBJECT MODULE PLACED IN zlg500.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE zlg500.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include "main.h"
2 #include <string.h>
3 #include "mface_3.h"
4
5 #define __SRC
6 #include "zlg500.h"
7 #undef __SRC
8
9 bit bdata newdata=0;
10
11 void spi_int(void) interrupt 0 using 1
12 {
13 1 spi_rcv(spi_buffer);
14 1 newdata=1;
15 1 }
16
17 uchar zlg500cmd(uchar length)
18 { uchar spi_wdg=10;
19 1 uchar i,BCC_sum;
20 1
21 1 spi_buffer[length]=spi_buffer[0];
22 1 for(i=1;i<length;i++)
23 1 {
24 2 spi_buffer[length]^=spi_buffer[i];
25 2 }
26 1 spi_buffer[length]=~spi_buffer[length];
27 1
28 1 TH0=0x2c; //Fosc=11059200,50ms timer interrupt
29 1 TL0=0xb0;
30 1
31 1 if(spi_send(spi_buffer,length+1)!=SPI_OK)
32 1 return SPI_ERR;
33 1
34 1 ET0=0;
35 1 TF0=0;
36 1 TR0=1;
37 1 SPI_REN();
38 1 while(newdata==0&&spi_wdg!=0)
39 1 {
40 2 if(TF0==1)
41 2 {
42 3 TH0=0x2c;
43 3 TL0=0xb0;
44 3 TF0=0;
45 3 spi_wdg--;
46 3 }
47 2 }
48 1 TR0=0;
49 1 SPI_RDIS();
50 1
51 1 if(newdata==0) return SPI_ERR;
52 1 newdata=0;
53 1
54 1
55 1 BCC_sum=spi_buffer[0];
C51 COMPILER V7.09 ZLG500 08/18/2006 08:26:14 PAGE 2
56 1 for(i=1;i<(spi_buffer[LENGTH]+3);i++)
57 1 {
58 2 BCC_sum^=spi_buffer[i];
59 2 }
60 1 if(BCC_sum==~spi_buffer[spi_buffer[LENGTH]+3])
61 1 return SPI_OK;
62 1 else return MI_CRCERR;
63 1 }
64
65 #if mifs_request_en
66 uchar mifs_request(uchar _Mode,uchar idata *_TagType)
67 {
68 1 spi_buffer[SEQNR]=0;
69 1 spi_buffer[COMMAND]=0x41;
70 1 spi_buffer[LENGTH]=0x01;
71 1 spi_buffer[MODE]=_Mode;
72 1
73 1 if(zlg500cmd(4)!=SPI_OK)
74 1 return SPI_ERR;
75 1
76 1 if(spi_buffer[STATUS]==MI_OK)
77 1 {
78 2 _TagType[0]=spi_buffer[TAGTYPE];
79 2 _TagType[1]=spi_buffer[TAGTYPE+1];
80 2 }
81 1 return spi_buffer[STATUS];
82 1 }
83 #endif
84
85 #if mifs_anticoll_en
uchar mifs_anticoll(uchar _Bcnt,uchar idata *_SNR)
{
spi_buffer[SEQNR]=0;
spi_buffer[COMMAND]=0x42;
spi_buffer[LENGTH]=0x01;
spi_buffer[MODE]=_Bcnt;
if(zlg500cmd(4)!=SPI_OK)
return SPI_ERR;
if(spi_buffer[STATUS]==MI_OK)
{
memcpy(_SNR,&spi_buffer[SERNR],4);
}
return spi_buffer[STATUS];
}
#endif
103
104 #if mifs_anticoll2_en
uchar mifs_anticoll2(uchar _Encoll,uchar _Bcnt,uchar idata *_SNR)
{
spi_buffer[SEQNR]=0;
spi_buffer[COMMAND]=0x71;
spi_buffer[LENGTH]=0x02;
spi_buffer[DATA]=_Encoll;
spi_buffer[DATA+1]=_Bcnt;
if(zlg500cmd(5)!=SPI_OK)
return SPI_ERR;
if(spi_buffer[STATUS]==MI_OK)
{
C51 COMPILER V7.09 ZLG500 08/18/2006 08:26:14 PAGE 3
memcpy(_SNR,&spi_buffer[DATA],4);
}
return spi_buffer[STATUS];
}
#endif
123
124 #if mifs_select_en
uchar mifs_select(uchar idata *_SNR,uchar idata *_Size)
{
spi_buffer[SEQNR]=0;
spi_buffer[COMMAND]=0x43;
spi_buffer[LENGTH]=0x04;
memcpy(&spi_buffer[SERNR],_SNR,4);
if(zlg500cmd(7)!=SPI_OK)
return SPI_ERR;
if(spi_buffer[STATUS]==MI_OK)
{
*_Size=spi_buffer[SIZE];
}
return spi_buffer[STATUS];
}
#endif
142
143 #if mifs_authentication_en
144 uchar mifs_authentication(uchar _Mode,uchar _SecNr)
145 {
146 1 spi_buffer[SEQNR]=0;
147 1 spi_buffer[COMMAND]=0x44;
148 1 spi_buffer[LENGTH]=0x02;
149 1 spi_buffer[MODE]=_Mode;
150 1 spi_buffer[SECNR]=_SecNr;
151 1
152 1 if(zlg500cmd(5)!=SPI_OK)
153 1 return SPI_ERR;
154 1
155 1 return spi_buffer[STATUS];
156 1 }
157 #endif
158
159 #if mifs_authentication2_en
160 uchar mifs_authentication2(uchar _Mode,uchar _SecNr,uchar _KeyNr)
161 {
162 1 spi_buffer[SEQNR]=0;
163 1 spi_buffer[COMMAND]=0x72;
164 1 spi_buffer[LENGTH]=0x03;
165 1 spi_buffer[MODE]=_Mode;
166 1 spi_buffer[SECNR]=_SecNr;
167 1 spi_buffer[DATA+2]=_KeyNr;
168 1
169 1 if(zlg500cmd(6)!=SPI_OK)
170 1 return SPI_ERR;
171 1
172 1 return spi_buffer[STATUS];
173 1 }
174 #endif
175
176 #if mifs_authKey_en
177 uchar mifs_authKey(uchar _Mode,uchar _SecNr,uchar *_Key)
178 {
179 1 spi_buffer[SEQNR]=0;
C51 COMPILER V7.09 ZLG500 08/18/2006 08:26:14 PAGE 4
180 1 spi_buffer[COMMAND]=0x73;
181 1 spi_buffer[LENGTH]=0x08;
182 1 spi_buffer[DATA]=_Mode;
183 1 spi_buffer[DATA+1]=_SecNr;
184 1 memcpy(&spi_buffer[DATA+2],_Key,6);
185 1
186 1 if(zlg500cmd(11)!=SPI_OK)
187 1 return SPI_ERR;
188 1
189 1 return spi_buffer[STATUS];
190 1 }
191 #endif
192
193 #if mifs_halt_en
194 uchar mifs_halt(void)
195 {
196 1 spi_buffer[SEQNR]=0;
197 1 spi_buffer[COMMAND]=0x45;
198 1 spi_buffer[LENGTH]=0x00;
199 1
200 1 if(zlg500cmd(3)!=SPI_OK)
201 1 return SPI_ERR;
202 1
203 1 return spi_buffer[STATUS];
204 1 }
205 #endif
206
207 #if mifs_read_en
208 uchar mifs_read(uchar _Adr,uchar idata *_Data)
209 {
210 1 spi_buffer[SEQNR]=0;
211 1 spi_buffer[COMMAND]=0x46;
212 1 spi_buffer[LENGTH]=0x01;
213 1 spi_buffer[ADR]=_Adr;
214 1
215 1 if(zlg500cmd(4)!=SPI_OK)
216 1 return SPI_ERR;
217 1
218 1 if(spi_buffer[STATUS]==MI_OK)
219 1 {
220 2 memcpy(_Data,&spi_buffer[DATABYTES-1],16);
221 2 }
222 1 return spi_buffer[STATUS];
223 1 }
224 #endif
225
226 #if mifs_write_en
227 uchar mifs_write(uchar _Adr,uchar idata *_Data)
228 {
229 1 spi_buffer[SEQNR]=0;
230 1 spi_buffer[COMMAND]=0x47;
231 1 spi_buffer[LENGTH]=17;
232 1 spi_buffer[ADR]=_Adr;
233 1 memcpy(&spi_buffer[DATABYTES],_Data,16);
234 1
235 1 if(zlg500cmd(20)!=SPI_OK)
236 1 return SPI_ERR;
237 1
238 1 return spi_buffer[STATUS];
239 1 }
240 #endif
241
C51 COMPILER V7.09 ZLG500 08/18/2006 08:26:14 PAGE 5
242 #if mifs_increment_en
uchar mifs_increment(uchar _Adr,long idata *_Value)
{ uchar *temp=(uchar *)_Value;
spi_buffer[SEQNR]=0;
spi_buffer[COMMAND]=0x48;
spi_buffer[LENGTH]=5;
spi_buffer[ADR]=_Adr;
spi_buffer[VALUE]=*(temp+3);
spi_buffer[VALUE+1]=*(temp+2);
spi_buffer[VALUE+2]=*(temp+1);
spi_buffer[VALUE+3]=*temp;
if(zlg500cmd(8)!=SPI_OK)
return SPI_ERR;
return spi_buffer[STATUS];
}
#endif
260
261 #if mifs_decrement_en
uchar mifs_decrement(uchar _Adr,long idata *_Value)
{
uchar *temp=(uchar *)_Value;
spi_buffer[SEQNR]=0;
spi_buffer[COMMAND]=0x49;
spi_buffer[LENGTH]=5;
spi_buffer[ADR]=_Adr;
spi_buffer[VALUE]=*(temp+3);
spi_buffer[VALUE+1]=*(temp+2);
spi_buffer[VALUE+2]=*(temp+1);
spi_buffer[VALUE+3]=*temp;
if(zlg500cmd(8)!=SPI_OK)
return SPI_ERR;
return spi_buffer[STATUS];
}
#endif
280
281 #if mifs_restore_en
uchar mifs_restore(uchar _Adr)
{
spi_buffer[SEQNR]=0;
spi_buffer[COMMAND]=0x4A;
spi_buffer[LENGTH]=1;
spi_buffer[ADR]=_Adr;
if(zlg500cmd(4)!=SPI_OK)
return SPI_ERR;
return spi_buffer[STATUS];
}
#endif
295
296 #if mifs_transfer_en
uchar mifs_transfer(uchar _Adr)
{
spi_buffer[SEQNR]=0;
spi_buffer[COMMAND]=0x4B;
spi_buffer[LENGTH]=1;
spi_buffer[ADR]=_Adr;
C51 COMPILER V7.09 ZLG500 08/18/2006 08:26:14 PAGE 6
if(zlg500cmd(4)!=SPI_OK)
return SPI_ERR;
return spi_buffer[STATUS];
}
#endif
310
311 #if mifs_load_key_en
312 uchar mifs_load_key(uchar _Mode,uchar _SecNr,uchar *_Nkey)
313 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -