📄 mfrc500uc.lst
字号:
C51 COMPILER V8.02 MFRC500UC 04/12/2009 10:36:17 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE MFRC500UC
OBJECT MODULE PLACED IN mfrc500uc.OBJ
COMPILER INVOKED BY: E:\Program Files\C51\BIN\C51.EXE mfrc500uc.c LARGE WARNINGLEVEL(0) BROWSE INCDIR(D:\UsefulDocument\
-Mifare\MF RC500\MFRC500 Demo Reader\RC500\For Test) DEBUG OBJECTEXTEND
line 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
18 #include <MfRc500.h>
19 #include <PcdShared.h>
*** ERROR C129 IN LINE 32 OF PCDSHARED.H: missing ';' before 'PcdReset'
20 #include <uCInit.h>
21 #include <RcCommunication.h>
22 #include <PcdUtils.h>
23 #include <MfErrNo.h>
24
25 /*! \file MfRc500uC.c
26 *
27 * Projekt: MF EV X00 Firmware
28 *
29 * $Workfile:: MfRc500uC.c $
30 * $Modtime:: 30.03.01 9:46 $
31 * $Author:: Hb $
32 * $Revision:: 31 $
33 *
34 *
35 * This library modul is written for a C166 microcontroller derivative.
36 * The source can be ported to other platforms very easily.
37 * The communication channel to the RC500 reader IC is assumed to be
38 * unknown. All data is written with the generic IO functions
39 * of the module RcComunication.h (Reader core communication).
40 * In our case the reader module is
41 * connected via memory mapped io at base address 0x100000.
42 * The interrupt pin of the reader IC is assumed to be connected to
43 * the fast external interrupt pin INT0# (active low) and the reset
44 * pin of the reader IC should be connected to a dedicated port pin
45 * (Port: P1 Pin: 9).
46 * In this configuration, a reset of the reader module is independend
47 * from the reset of the microcontroller.
48 * In order to generate communication timeouts,
49 * general purpose timer 3 of the microcontroller is used. This
50 * timer need not to be initialised in advance. Before every usage
51 * the timer is completely initialised in each function.
52 * Non of the timers is essential for the functionality of the reader
53 * module, but are helpful furing software development. All protocoll
C51 COMPILER V8.02 MFRC500UC 04/12/2009 10:36:17 PAGE 2
54 * relevant timing constraints are generated
55 * by the internal timer of the reader module.
56 *
57 * Some explanations to the programming method of this library.
58 * There are three kind of functions coded in this module.
59 * <ol>
60 * <li> internal functions, which have no prototypes in a header
61 * file. This kind of functions are not intended to be used
62 * outside of this file
63 * <li> commands, which are intended for the reader module itself
64 * <li> commands, which are intended for any tag in the rf field.
65 * These commands are send to the reader and the reader module
66 * transmitts the data to the rf interface.
67 * </ol>
68 * Commands for the reader and for the tag have the appropriate
69 * prefix (PCD for Proximity Coupled Device or reader module
70 * PICC for Proximity Integrated Circuit Card or tag)
71 * and their protypes are defined in the header file.
72 * Certainly, each command for a PICC consists of an instruction to the PCD.
73 * Therefore
74 * the function PcdSingleResponseCmd is very important for the understanding
75 * of the communication.
76 *
77 * The basic functionality is provided by the interrupt service
78 * routine (SingleResponseCmd), which closely works together with the function
79 * PcdSingleResponseCmd. All kinds of interrupts are serviced by the
80 * same ISR.
81 */
82
83 ///////////////////////////////////////////////////////////////////////////////
84 // M O D U L V A R I A B L E S
85 ///////////////////////////////////////////////////////////////////////////////
86
87 /*!
88 * \ingroup mfcompatible
89 * storage of the last selected serial number including check byte.
90 *
91 * For multi level serial numbers, only the first 4 bytes are stored.
92 */
93 unsigned char MLastSelectedSnr[5];
94
95 volatile unsigned char *MSndBuffer = 0; ///< pointer to the transmit buffer
96 volatile unsigned char *MRcvBuffer = 0; ///< pointer to the receive buffer
97
98 /*!
99 * In order to exchange some values between the ISR and the calling function,
100 * a struct is provided.
101 */
102 volatile MfCmdInfo MInfo;
103
104 /*! \name ISO14443 Support Properties
105 * \ingroup ISO14443
106 * Some of the protokoll functions of ISO14443 needs information about
107 * the capability of the reader device, which are provided by this
108 * constants.
109 */
110 //@{
111 #define TCLFSDSNDMAX 8 ///< max. frame size send
112 #define TCLFSDRECMAX 8 ///< max. frame size rcv
113 #define TCLDSMAX 3 ///< max. baudrate divider PICC --> PCD
114 #define TCLDRMAX 3 ///< max. baudrate divider PCD --> PICC
115
C51 COMPILER V8.02 MFRC500UC 04/12/2009 10:36:17 PAGE 3
116 #define TCLDSDFLT 0 ///< default baudrate divider PICC --> PCD
117 #define TCLDRDFLT 0 ///< default baudrate divider PCD --> PICC
118 //@}
119
120
121 ///////////////////////////////////////////////////////////////////////////////
122 // Prototypes for local functions
123 ///////////////////////////////////////////////////////////////////////////////
124
125 /// Internal Authentication State Switch
126 /*!
127 * \ingroup internal
128 * \param auth_mode (<em>IN</em>)
129 * <ul> selects master key A or master key B
130 * <li> PICC_AUTHENT1A
131 * <li> PICC_AUTHENT1B
132 * </ul>
133 * \param *snr (<em>IN</em>)
134 * 4 byte serial number of the card, which should be
135 * authenticated
136 * \param sector (<em>IN</em>) Range [0..15]
137 * specifies the key RAM address
138 * from which the keys should be taken
139 * \return <ul>
140 * <li> MI_OK
141 * <li> CCE
142 * <li> MI_BITCOUNTERR wrong number of bits received
143 * <li> MI_AUTHERR wrong keys for selected card
144 * <li> MI_KEYERR error while loading keys
145 * </ul>
146 *
147 * Internal authentication state function.
148 */
149 char Mf500PiccAuthState(unsigned char auth_mode,// PICC_AUTHENT1A, PICC_AUTHENT1B
150 unsigned char *snr, // 4 byte serial number
151 unsigned char sector); // 0 <= sector <= 15
152 // sector address for authentication
153
154 ///////////////////////////////////////////////////////////////////////
155 // M I F A R E M O D U L E C O N F I G U R A T I O N
156 ///////////////////////////////////////////////////////////////////////
157 char Mf500PcdConfig(void)
158 {
159 char status = MI_RESETERR;
160 unsigned short RstLoopCnt = 0;
161 unsigned short CmdWaitCnt = 0;
162
163 // global initialisation
164 MSndBuffer = RicRxTxBuffer; // initialise send buffer
165 MRcvBuffer = RicRxTxBuffer; // initialise receive buffer
166
167 status = PcdReset();
168
169 if (status == MI_OK)
170 {
171
172 // test clock Q calibration - value in the range of 0x46 expected
173 WriteRC(RegClockQControl,0x0);
174 WriteRC(RegClockQControl,0x40);
175 SleepUs(24); // wait approximately 100 us - calibration in progress
176 ClearBitMask(RegClockQControl,0x40); // clear bit ClkQCalib for
177 // further calibration
C51 COMPILER V8.02 MFRC500UC 04/12/2009 10:36:17 PAGE 4
178
179 // The following values for RegBitPhase and
180 // RegRxThreshold represents an optimal
181 // value for our demo package. For user
182 // implementation some changes could be
183 // necessary
184 // initialize bit phase
185 WriteRC(RegBitPhase,0xAD);
186
187 // initialize minlevel
188 WriteRC(RegRxThreshold,0xFF);
189
190 // disable auto power down
191 WriteRC(RegRxControl2,01);
192
193 // Depending on the processing speed of the
194 // operation environment, the waterlevel
195 // can be adapted. (not very critical for
196 // mifare applications)
197 // initialize waterlevel to value 4
198 WriteRC(RegFIFOLevel,0x1A); // initialize to 26d
199
200 //Timer Konfiguration
201 WriteRC(RegTimerControl,0x02); // TStopRxEnd=0,TStopRxBeg=0,
202 // TStartTxEnd=1,TStartTxBeg=0
203 // timer must be stopped manually
204
205 WriteRC(RegIRqPinConfig,0x3); // interrupt active low enable
206
207 PcdRfReset(1); // Rf - reset and enable output driver
208
209 }
210 return status;
211 }
212
213 ///////////////////////////////////////////////////////////////////////
214 // M I F A R E R E M O T E A N T E N N A
215 // Configuration of slave module
216 ///////////////////////////////////////////////////////////////////////
217 char Mf500ActiveAntennaSlaveConfig(void)
218 {
219 char status = MI_OK;
220
221 FlushFIFO(); // empty FIFO
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -