📄 mfrc500uc.lst
字号:
C51 COMPILER V7.00 MFRC500UC 03/05/2004 15:25:52 PAGE 1
C51 COMPILER V7.00, COMPILATION OF MODULE MFRC500UC
OBJECT MODULE PLACED IN MfRc500uC.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE MfRc500uC.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c), Philips Semiconductors Gratkorn
3 //
4 // (C)PHILIPS Electronics N.V.2000
5 // All rights are reserved.
6 // Philips reserves the right to make changes without notice at any time.
7 // Philips makes no warranty, expressed, implied or statutory, including but
8 // not limited to any implied warranty of merchantibility or fitness for any
9 //particular purpose, or that the use will not infringe any third party patent,
10 // copyright or trademark. Philips must not be liable for any loss or damage
11 // arising from its use.
12 ///////////////////////////////////////////////////////////////////////////////
13 #include <string.h>
14 #include <stdio.h>
15
16 #include <RICReg.h>
17 #include <MfRc500.h>
18 #include <PICCCmdConst.h>
19 #include <MfErrNo.h>
20
21 /*
22 * Projekt: MF EV X00 Firmware
23 *
24 * $Workfile:: MfRc500uC.c $
25 * $Modtime:: 24.06.02 15:41 $
26 * $Author:: Hb $
27 * $Revision:: 8 $
28 *
29 *
30 * This library modul is written for a C166 microcontroller derivative.
31 * The source can be ported to other platforms very easily.
32 * In our case the reader module is
33 * connected via memory mapped io at base address 0x100000.
34 * The interrupt pin of the reader IC is assumed to be connected to
35 * the fast external interrupt pin INT0# (active low) and the reset
36 * pin of the reader IC should be connected to a dedicated port pin
37 * (Port: P1 Pin: 9).
38 * In this configuration, a reset of the reader module is independend
39 * from the reset of the microcontroller.
40 * All protocoll
41 * relevant timing constraints are generated
42 * by the internal timer of the reader module.
43 *
44 * Some explanations to the programming method of this library.
45 * There are three kind of functions coded in this module.
46 *
47 * ---- internal functions, which have no prototypes in a header
48 * file. This kind of functions are not intended to be used
49 * outside of this file
50 * ---- commands, which are intended for the reader module itself
51 * ---- commands, which are intended for any tag in the rf field.
52 * These commands are send to the reader and the reader module
53 * transmitts the data to the rf interface.
54 *
55 * Commands for the reader and for the tag have the appropriate
C51 COMPILER V7.00 MFRC500UC 03/05/2004 15:25:52 PAGE 2
56 * prefix (PCD for Proximity Coupled Device or reader module
57 * PICC for Proximity Integrated Circuit Card or tag)
58 * and their protypes are defined in the header file.
59 * Certainly, each command for a PICC consists of an instruction to the PCD.
60 * Therefore
61 * the function PcdSingleResponseCmd is very important for the understanding
62 * of the communication.
63 *
64 * The basic functionality is provided by the interrupt service
65 * routine (SingleResponseCmd), which closely works together with the function
66 * PcdSingleResponseCmd. All kinds of interrupts are serviced by the
67 * same ISR.
68 */
69
70 ///////////////////////////////////////////////////////////////////////////////
71 // M O D U L V A R I A B L E S
72 ///////////////////////////////////////////////////////////////////////////////
73
74
75 // interrupt vector number for interrupt of the RIC
76 // select the appropriate value corresponding to the microcontroller in use
77 #define READER_INT // e. g. 0x18
78 // disable reader interrupt
79 // select the appropriate value corresponding to the microcontroller in use
80 #define READER_INT_DISABLE // e. g. EXICON &= ~0x0002
81 // enable reader interrupt
82 // select the appropriate value corresponding to the microcontroller in use
83 #define READER_INT_ENABLE // e. g. EXICON |= 0x0002
84
85 // initialize reset pin and change port direction
86 // select the appropriate value corresponding to the microcontroller in use
87 #define READER_INIT_RESET // e. g. P6 |= 0x20; DP6 |= 0x20
88 // set reset pin
89 // select the appropriate value corresponding to the microcontroller in use
90 #define READER_RESET // e. g. P6 |= 0x20
91 // clear reset pin
92 // select the appropriate value corresponding to the microcontroller in use
93 #define READER_CLEAR_RESET // e. g. P6 &= ~0x20
94
95 // memory base address corresponding to the previous set address select register
96 // select the appropriate value corresponding to the microcontroller in use
97 #define MEMORY_BASE_ADDRESS 0x100000
98
99 // the RIC has only 3 address lines - page select is necessary
100 #define GetRegPage(addr) (0x80 | (addr>>3))
101
102 /* ISO14443 Support Properties
103 * Some of the protokoll functions of ISO14443 needs information about
104 * the capability of the reader device, which are provided by this
105 * constants.
106 */
107 //{
108 #define TCLFSDSNDMAX 8 ///< max. frame size send
109 #define TCLFSDRECMAX 8 ///< max. frame size rcv
110 #define TCLDSMAX 3 ///< max. baudrate divider PICC --> PCD
111 #define TCLDRMAX 3 ///< max. baudrate divider PCD --> PICC
112
113 #define TCLDSDFLT 0 ///< default baudrate divider PICC --> PCD
114 #define TCLDRDFLT 0 ///< default baudrate divider PCD --> PICC
115 //}
116
117 /* ISR communication structures
C51 COMPILER V7.00 MFRC500UC 03/05/2004 15:25:52 PAGE 3
118 * All parameters are passed to the ISR via this structure.
119 */
120 //{
121 // struct definition for a communication channel between function and ISR
122 typedef struct
123 {
124 unsigned char cmd; //!< command code
125 char status; //!< communication status
126 unsigned short nBytesSent; //!< how many bytes already sent
127 unsigned short nBytesToSend; //!< how many bytes to send
128 unsigned short nBytesReceived;//!< how many bytes received
129 unsigned long nBitsReceived; //!< how many bits received
130 unsigned char irqSource; //!< which interrupts have occured
131 unsigned char collPos; /*!< at which position occured a
132 collision*/
133 unsigned char errFlags; //!< error flags
134 unsigned char saveErrorState;//!< accumulated error flags for
135 //!< multiple responses
136 unsigned char RxAlignWA; //!< workaround for RxAlign = 7
137 unsigned char DisableDF; //!< disable disturbance filter
138 } MfCmdInfo;
139
140 // Convinience function for initialising the communication structure.
141 #define ResetInfo(info) \
142 info.cmd = 0; \
143 info.status = MI_OK;\
144 info.irqSource = 0; \
145 info.nBytesSent = 0; \
146 info.nBytesToSend = 0; \
147 info.nBytesReceived = 0; \
148 info.nBitsReceived = 0; \
149 info.collPos = 0; \
150 info.errFlags = 0; \
151 info.saveErrorState = 0; \
152 info.RxAlignWA = 0; \
153 info.DisableDF = 0;
154
155 // In order to exchange some values between the ISR and the calling function,
156 // a struct is provided.
157 volatile MfCmdInfo MInfo;
158
159 // communication info stucture
160 static volatile MfCmdInfo *MpIsrInfo = 0;
161 // ISR send buffer
162 static volatile unsigned char *MpIsrOut = 0;
163 // ISR receive buffer
164 static volatile unsigned char *MpIsrIn = 0;
165 //}
166
167
168 // storage of the last selected serial number including check byte.
169 // For multi level serial numbers, only the first 4 bytes are stored.
170 unsigned char MLastSelectedSnr[5];
171
172
173 // storage buffer for receive and transmit routines
174 //{
175 #define MEMORY_BUFFER_SIZE 300
176 volatile unsigned char MemPool[MEMORY_BUFFER_SIZE];
177
178 volatile unsigned char *MSndBuffer = MemPool; // pointer to the transmit buffer
179 volatile unsigned char *MRcvBuffer = MemPool; // pointer to the receive buffer
C51 COMPILER V7.00 MFRC500UC 03/05/2004 15:25:52 PAGE 4
180 //}
181
182 /* Higher Baudrate Control
183 * attention: RegDecoderControl is modified in CascAnticoll
184 * Because of standard baudrate usage during anticollision, the
185 * register can be written. For general purpose usage, only some bits
186 * should be set.
187 *
188 * Please pay attention, that the location of the configuration array is
189 * in ROM space, that means that on 16 bit microcontroller the access
190 * should be word aligned.
191 */
192 //{
193 typedef struct
194 {
195 unsigned short SubCarrierPulses; ///< RegRxControl1
196 unsigned short RxCoding; ///< RegDecoderControl
197 unsigned short RxThreshold; ///< RegRxThreshold
198 unsigned short BPSKDemControl; ///< RegBPSKDemControl
199 } t_DSCfg;
200
201 typedef struct
202 {
203 unsigned short CoderRate; ///< RegCoderControl
204 unsigned short ModWidth; ///< RegModWidth
205 } t_DRCfg;
206
207 const t_DSCfg MDSCfg[4] = {{0x73,0x08,0x88,0x00} // Manchaster 106 kBaud
208 ,{0x53,0x09,0x50,0x0C} // BPSK 212 kBaud
209 ,{0x33,0x09,0x50,0x0C} // BPSK 424 kBaud
210 ,{0x13,0x09,0x50,0x0C}}; // BPSK 848 kBaud
211 const t_DRCfg MDRCfg[4] = {{0x19,0x13} // Miller 106 kBaud
212 ,{0x11,0x07} // Miller 212 kBaud
213 ,{0x09,0x03} // Miller 424 kBaud
214 ,{0x01,0x01}}; // Miller 848 kBaud
215
216 // data send baudrate divider PICC --> PCD
217 static unsigned char MDSI = TCLDSDFLT;
218
219 // data send baudrate divider PCD --> PICC
220 static unsigned char MDRI = TCLDRDFLT;
221 //}
222
223 // Write one byte to the reader IC address space
224 /*!
225 * -o address (IN) reader ic register address
226 * -o value (IN) 8 bit value
227 * return: none
228 *
229 * Function for writting one char to the reader module
230 *
231 * The reader module is connected to a 16 bit demultiplexed bus,
232 * therefore the address pin of the reader module is mapped as
233 * follows: \n
234 * uC Reader \n
235 * A1 A0 \n
236 * A2 A1 \n
237 * A3 A2 \n
238 *
239 * In order to get the correct address, the original address need to
240 * be multiplied by 2.
241 */
C51 COMPILER V7.00 MFRC500UC 03/05/2004 15:25:52 PAGE 5
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -