📄 rc500.lst
字号:
C51 COMPILER V7.05 RC500 12/20/2004 15:31:09 PAGE 1
C51 COMPILER V7.05, COMPILATION OF MODULE RC500
OBJECT MODULE PLACED IN RC500.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE RC500.c DEBUG OBJECTEXTEND
stmt level source
1 //#include<reg52.h>
2 #include "REG51F.H"
3 #include<rc500.h>
4 //sbit RC500_RST=P4^2;
5 sbit RC500_RST=P3^5;
6 idata struct TranSciveBuffer{uchar MfCommand;
7 uchar MfLength;
8 uchar MfData[19];
9 };
10 //*********************************************************************
11 void WriteRC(uchar Address,uchar value)
12 {
13 1 /* uchar pdata *pa;
14 1 pa=RegPage;
15 1 *pa=Address>>3;
16 1 pa=Address;
17 1 *pa=value;*/
18 1 uchar xdata *pa;
19 1 pa=Base_addr;
20 1 *pa=Address>>3;
21 1 pa=Address+Base_addr;
22 1 *pa=value;
23 1
24 1 }
25 //***************************************************
26 void ClearBitMask(uchar reg,uchar mask)
27 {
28 1 char tmp=0x0;
29 1 tmp = ReadRC(reg);
30 1 WriteRC(reg,tmp & ~mask);
31 1 }
32 //********************************************************
33 char PcdAnticoll(uchar *snr)
34 {
35 1 uchar i;
36 1 uchar snr_check=0;
37 1 char status=MI_OK;
38 1 idata struct TranSciveBuffer{uchar MfCommand;
39 1 uchar MfLength;
40 1 uchar MfData[5];
41 1 }MfComData;
42 1 struct TranSciveBuffer *pi;
43 1
44 1 pi=&MfComData;
45 1 PcdSetTmo(106);
46 1 WriteRC(RegDecoderControl,0x28);
47 1 ClearBitMask(RegControl,0x08);
48 1 WriteRC(RegChannelRedundancy,0x03);
49 1
50 1 MfComData.MfCommand=PCD_TRANSCEIVE;
51 1 MfComData.MfLength=2;
52 1 MfComData.MfData[0]=PICC_ANTICOLL1;
53 1 MfComData.MfData[1]=0x20;
54 1 status=PcdComTransceive(pi);
55 1 if(!status)
C51 COMPILER V7.05 RC500 12/20/2004 15:31:09 PAGE 2
56 1 {
57 2 for(i=0;i<4;i++)
58 2 {
59 3 snr_check^=MfComData.MfData[i];
60 3 }
61 2 if(snr_check!=MfComData.MfData[i])
62 2 {
63 3 status=MI_SERNRERR;
64 3 }
65 2 else
66 2 {
67 3 for(i=0;i<4;i++)
68 3 {
69 4 *(snr+i)=MfComData.MfData[i];
70 4 }
71 3 }
72 2
73 2 }
74 1 ClearBitMask(RegDecoderControl,0x20);
75 1 return status;
76 1 }
77 //**************************************************************
78 char PcdAuthKey(uchar *keys)
79 {
80 1 char status;
81 1 uchar i;
82 1 idata struct TranSciveBuffer{uchar MfCommand;
83 1 uchar MfLength;
84 1 uchar MfData[12];
85 1 }MfComData;
86 1 struct TranSciveBuffer *pi;
87 1 pi=&MfComData;
88 1 PcdSetTmo(106);
89 1 MfComData.MfCommand=PCD_LOADKEY;
90 1 MfComData.MfLength=12;
91 1 for(i=0;i<12;i++)
92 1 {
93 2 MfComData.MfData[i]=*(keys+i);
94 2 }
95 1 status=PcdComTransceive(pi);
96 1 return status;
97 1 }
98 //*************************************************************
99 char PcdAuthState(uchar auth_mode,uchar block,uchar *snr)
100 {
101 1 char status=MI_OK;
102 1 uchar i;
103 1 idata struct TranSciveBuffer{uchar MfCommand;
104 1 uchar MfLength;
105 1 uchar MfData[6];
106 1 }MfComData;
107 1 struct TranSciveBuffer *pi;
108 1 pi=&MfComData;
109 1
110 1 WriteRC(RegChannelRedundancy,0x07);
111 1 if(status==MI_OK)
112 1 {
113 2 PcdSetTmo(106);
114 2 MfComData.MfCommand=PCD_AUTHENT1;
115 2 MfComData.MfLength=6;
116 2 MfComData.MfData[0]=auth_mode;
117 2 MfComData.MfData[1]=block;
C51 COMPILER V7.05 RC500 12/20/2004 15:31:09 PAGE 3
118 2 for(i=0;i<4;i++)
119 2 {
120 3 MfComData.MfData[i+2]=*(snr+i);
121 3 }
122 2 if((status=PcdComTransceive(pi))==MI_OK)
123 2 {
124 3 if (ReadRC(RegSecondaryStatus)&0x07)
125 3 {
126 4 status = MI_BITCOUNTERR;
127 4 }
128 3 else
129 3 {
130 4 MfComData.MfCommand=PCD_AUTHENT2;
131 4 MfComData.MfLength=0;
132 4 if((status=PcdComTransceive(pi))==MI_OK)
133 4 {
134 5 if(ReadRC(RegControl)&0x08)
135 5 status=MI_OK;
136 5 else
137 5 status=MI_AUTHERR;
138 5 }
139 4 }
140 3 }
141 2 }
142 1 return status;
143 1 }
144 //***************************************
145
146
147 char PcdComTransceive(struct TranSciveBuffer *pi)
148 {
149 1 bit recebyte=0;
150 1 char status;
151 1 uchar irqEn=0x00;
152 1 uchar waitFor=0x00;
153 1 uchar lastBits;
154 1 uchar n;
155 1 uint i;
156 1 switch(pi->MfCommand)
157 1 {
158 2 case PCD_IDLE:
159 2 irqEn = 0x00;
160 2 waitFor = 0x00;
161 2 break;
162 2 case PCD_WRITEE2:
163 2 irqEn = 0x11;
164 2 waitFor = 0x10;
165 2 break;
166 2 case PCD_READE2:
167 2 irqEn = 0x07;
168 2 waitFor = 0x04;
169 2 recebyte=1;
170 2 break;
171 2 case PCD_LOADCONFIG:
172 2 case PCD_LOADKEYE2:
173 2 case PCD_AUTHENT1:
174 2 irqEn = 0x05;
175 2 waitFor = 0x04;
176 2 break;
177 2 case PCD_CALCCRC:
178 2 irqEn = 0x11;
179 2 waitFor = 0x10;
C51 COMPILER V7.05 RC500 12/20/2004 15:31:09 PAGE 4
180 2 break;
181 2 case PCD_AUTHENT2:
182 2 irqEn = 0x04;
183 2 waitFor = 0x04;
184 2 break;
185 2 case PCD_RECEIVE:
186 2 irqEn = 0x06;
187 2 waitFor = 0x04;
188 2 recebyte=1;
189 2 break;
190 2 case PCD_LOADKEY:
191 2 irqEn = 0x05;
192 2 waitFor = 0x04;
193 2 break;
194 2 case PCD_TRANSMIT:
195 2 irqEn = 0x05;
196 2 waitFor = 0x04;
197 2 break;
198 2 case PCD_TRANSCEIVE:
199 2 irqEn = 0x3D;
200 2 waitFor = 0x04;
201 2 recebyte=1;
202 2 break;
203 2 default:
204 2 pi->MfCommand=MI_UNKNOWN_COMMAND;
205 2 break;
206 2 }
207 1 if(pi->MfCommand!=MI_UNKNOWN_COMMAND)
208 1 {
209 2 WriteRC(RegPage,0x00);
210 2 WriteRC(RegInterruptEn,0x7F);
211 2 WriteRC(RegInterruptRq,0x7F);
212 2 WriteRC(RegCommand,PCD_IDLE);
213 2 SetBitMask(RegControl,0x01);
214 2 WriteRC(RegInterruptEn,irqEn|0x80);
215 2 for(i=0;i<pi->MfLength;i++)
216 2 {
217 3 WriteRC(RegFIFOData,pi->MfData[i]);
218 3 }
219 2 WriteRC(RegCommand,pi->MfCommand);
220 2 i=0x2000;
221 2 do
222 2 {
223 3 n=ReadRC(RegInterruptRq);
224 3 i--;
225 3 }
226 2 while((i!=0)&&!(n&irqEn&0x20)&&!(n&waitFor));
227 2 status=MI_COM_ERR;
228 2 if((i!=0)&&!(n&irqEn&0x20))
229 2 {
230 3 if(!(ReadRC(RegErrorFlag)&0x17))
231 3 {
232 4 status=MI_OK;
233 4 if(recebyte)
234 4 {
235 5 n=ReadRC(RegFIFOLength);
236 5 lastBits=ReadRC(RegSecondaryStatus)&0x07;
237 5 if(lastBits)
238 5 {
239 6 pi->MfLength=(n-1)*8+lastBits;
240 6 }
241 5 else
C51 COMPILER V7.05 RC500 12/20/2004 15:31:09 PAGE 5
242 5 {
243 6 pi->MfLength=n*8;
244 6 }
245 5 if(n==0)
246 5 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -