📄 m500auc.lst
字号:
C51 COMPILER V4.01, M500AUC 29/08/06 08:02:01 PAGE 1
DOS C51 COMPILER V4.01, COMPILATION OF MODULE M500AUC
OBJECT MODULE PLACED IN F:\1\M500AUC.OBJ
COMPILER INVOKED BY: C:\COMP51\C51.EXE F:\1\M500AUC.C DB SB OE
stmt level source
1
2 #pragma large
3
4 //#include <w77e58.h>
5 #include <cpu.h>
6
7 #include <Mfreg500.h>
8 #include <M500A.h>
9 #include <RdIo.h>
10
11 #include <string.h>
12 #include <stdio.h>
13 #include <main.h>
14
15 ////////////////////////////////////////////////////////////////////////////////
16 // M O D U L E D E F I N I T I O N
17 ////////////////////////////////////////////////////////////////////////////////
18 // COMMENT: This library module is modified from the original source code for a
19 // microcontroller C164 CI, to suit the general purpose 8051 mcu.
20 // The source can be ported to other platforms very easily.
21 // The communication channel to the RC500 reader IC is assumed to be
22 // unknown. All data is written with the generic IO functions
23 // of the module ReaderIO.h. In our case the reader module is
24 // connected via memory mapped io at base address 0x7f00.
25 // The interrupt pin of the reader IC is assumed to be connected to
26 // the fast external interrupt pin INT0# (active low) and the reset
27 // pin of the reader IC should be connected to a dedicated port pin
28 // (Port3: Pin: 3).
29 // In this configuration, a reset of the reader module is independend
30 // from the reset of the microcontroller.
31 // In order to generate communication timeouts,
32 // general purpose timer 2 of the microcontroller is used. This
33 // timer need not to be initialised in advance. Before every usage
34 // the timer is completely initialised in each function.
35 // Non of the timers is essential for the functionality of the reader
36 // module, but are helpful furing software development. All protocoll
37 // relevant timing constraints are generated
38 // by the internal timer of the reader module.
39 //
40 // Some explanations to the programming method of this library.
41 // There are three kind of functions coded in this module.
42 // a) internal functions, which have no prototypes in a header
43 // file and are not intended to be used outside of this file
44 // b) commands, which are intended for the reader module itself
45 // c) commands, which are intended for any tag in the rf field.
46 // These commands are send to the reader and the reader module
47 // transmitts the data to the rf interface.
48 // Commands for the reader and for the tag have the appropriate
49 // prefix (PCD for proximity coupled device or reader module
50 // PICC for proximity integrated circuit card or tag)
51 // and their protypes are defined in the header file.
52 // Each command for a PICC consists of a PCD command. Therefore
53 // the function M500PcdCmd is very important for the understanding
54 // of the communication.
55 //
56 // The basic functionality is provided by the interrupt service
57 // routine (ISR), which closely works together with the function
58 // M500PcdCmd. All kinds of interrupts are serviced by the
59 // same ISR.
C51 COMPILER V4.01, M500AUC 29/08/06 08:02:01 PAGE 2
60
61
62 static unsigned char keycoded[12];
63 // 存取控制字节: 0xff,0x07,0x80,0x69
64
65 uchar code AledKey[16][12]={{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
66 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
67 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
68 {0x08,0x04,0x08,0x00,0x02,0x01,0xff,0xff,0xff,0xff,0xff,0xff},
69 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
70 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
71 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
72 {0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff},
73 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
74 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
75 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
76 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
77 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
78 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
79 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
80 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
81 } ;
82
83 // inline structure in order to reset the communication channel between
84 // function and ISR
85 #define ResetInfo(info) \
86 info.cmd = 0; \
87 info.status = MI_OK;\
88 info.irqSource = 0; \
89 info.nBytesSent = 0; \
90 info.nBytesToSend = 0; \
91 info.nBytesReceived = 0; \
92 info.nBitsReceived = 0; \
93 info.collPos = 0;
94
95 // struct definition for a communication channel between function and ISR
96 typedef struct
97 {
98 unsigned char cmd; //!< command code
99 char status; // communication status
100 unsigned char nBytesSent; // how many bytes already sent
101 unsigned char nBytesToSend; // how many bytes to send
102 unsigned char nBytesReceived;// how many bytes received
103 unsigned short nBitsReceived; // how many bits received
104 unsigned char irqSource; // which interrupts have occured
105 unsigned char collPos; // at which position occured a
106 // collision
107 } MfCmdInfo;
108
109 // modul variables
110 extern unsigned char xdata *GpBase;
111
112 static unsigned char data MFIFOLength = DEF_FIFO_LENGTH; // actual FIFO length
113
114 static unsigned char xdata MKeys[16][12]; // storage for authentication keys
115 // in order to provide a calling
116 // compatible interface to old libraries
117 // Other reader modules keep several sets
118 // of keys in an E2PROM. In this case,
119 // these keys are stored in the uC and
120 // transfered to the reader module
121 // before authentication
122
123 // Infomation concerning data processing
124 // send buffer for general use
125 static volatile unsigned char xdata MSndBuffer[SND_BUF_LEN];
C51 COMPILER V4.01, M500AUC 29/08/06 08:02:01 PAGE 3
126 // receive buffer for general use
127 static volatile unsigned char xdata MRcvBuffer[RCV_BUF_LEN];
128 // info struct for general use
129 static volatile MfCmdInfo xdata MInfo;
130
131 // Interrupt service routine
132 // Variable in order to exchange data between function and ISR
133 static volatile MfCmdInfo xdata *MpIsrInfo = 0;
*** WARNING 182 IN LINE 133 OF F:\1\M500AUC.C: pointer to different objects
134 // ISR send buffer
135 static volatile unsigned char xdata *MpIsrOut = 0;
*** WARNING 182 IN LINE 135 OF F:\1\M500AUC.C: pointer to different objects
136 // ISR receive buffer
137 static volatile unsigned char xdata *MpIsrIn = 0;
*** WARNING 182 IN LINE 137 OF F:\1\M500AUC.C: pointer to different objects
138
139 // storage of the last selected serial number including check byte.
140 //For multi level serial numbers, only the first 4 bytes are stored.
141 unsigned char MLastSelectedSnr[5];
142
143 // Timer 2
144 bit data T2IR = 0; // Timer2 timeout flag
145 unsigned int data CountDown = 0; // Timeout counter with 50us resolution
146
147
148
149 ///////////////////////////////////////////////////////////////////////////////
150 // Prototypes for local functions
151 ///////////////////////////////////////////////////////////////////////////////
152
153 void start_timeout(unsigned int _50us);
154 void stop_timeout(void);
155
156 // _____________________________________________________________________________
157 //
158 // FUNCTION: M500PcdSetTmo
159 // IN: tmoLength 1 ... 1.0 ms timeout periode
160 // 2 ... 1.5 ms timeout periode
161 // 3 ... 6.0 ms timeout periode
162 // 4 ... 9.6 ms timeout period
163 // 5 ... 38.5 ms timeout period
164 // 6 ... 154 ms timeout period
165 // 7 ... 616.2 ms timeout period
166 // OUT: -
167 // RETURN:
168 // COMMENT: Set timeout length of the reader internal timer.
169 //
170 void M500PcdSetTmo(unsigned char tmoLength);
171
172 // _____________________________________________________________________________
173 //
174 // FUNCTION: M500PcdCmd
175 // IN: cmd PCD_IDLE
176 // PCD_WRITEE2
177 // PCD_READE2
178 // PCD_LOADCONFIG
179 // PCD_LOADKEYE2
180 // PCD_AUTHENT1
181 // PCD_CALCCRC
182 // PCD_AUTHENT2
183 // PCD_RECEIVE
184 // PCD_LOADKEY
185 // PCD_TRANSMIT
186 // PCD_TRANSCEIVE
187 // PCD_RESETPHASE
188 // for a detailed description of the parameter values, please
C51 COMPILER V4.01, M500AUC 29/08/06 08:02:01 PAGE 4
189 // have a look on the header file of the reader register
190 // definitions.
191 // send byte stream of variable length, which should be send to
192 // the PICC, the length of stream has to be specified
193 // in the info - structure
194 // OUT: rcv byte stream of variable length, which was received
195 // from the PICC or PCD
196 // info communication and status structure
197 // RETURN:
198 // COMMENT: This function provides the central interface to the reader module.
199 // Depending on the "cmd"-value, all necessary interrupts are enabled
200 // and the communication is started. While the processing is done by
201 // the reader module, this function waits for its completion.
202 // It's notable, that the data in the "send byte stream" is written
203 // to the FIFO of the reader module by the ISR. Immediate after
204 // enabling the interrupts, the LoAlert interrupt is activated.
205 // The ISR writes the data to the FIFO. This function is not involved
206 // in writing or fetching data from FIFO, all work is done by the
207 // ISR.After command completion, the error status is evaluated and
208 // returned to the calling function.
209 //
210 char M500PcdCmd(unsigned char cmd,
211 volatile unsigned char* send,
212 volatile unsigned char* rcv,
213 volatile MfCmdInfo *info);
214
215 // _____________________________________________________________________________
216 //
217 // FUNCTION: SetBitMask
218 // IN: reg register address
219 // mask bit mask to set
220 // OUT: -
221 // RETURN:
222 // COMMENT: This function performs a read - modify - write sequence
223 // on the specified register. All bits with a 1 in the mask
224 // are set - all other bits keep their original value.
225 //
226 char SetBitMask(unsigned char reg,unsigned char mask);
227
228 // _____________________________________________________________________________
229 //
230 // FUNCTION: ClearBitMask
231 // IN: reg register address
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -