⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rc500.lst

📁 基于RC500射频卡读写模块的程序设计
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V7.20   RC500                                                                 02/04/2007 10:44:17 PAGE 1   


C51 COMPILER V7.20, COMPILATION OF MODULE RC500
OBJECT MODULE PLACED IN .\obj\Rc500.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Rc500.c LARGE OPTIMIZE(6,SPEED) BROWSE INCDIR(.\;.\c51) DEFINE(KEIL) DEBUG 
                    -OBJECTEXTEND PRINT(.\lst\Rc500.lst) OBJECT(.\obj\Rc500.obj)

line level    source

   1          ///////////////////////////////////////////////////////////////////////////////
   2          //    Copyright (c), Philips Semiconductors Gratkorn
   3          //
   4          //                  (C)PHILIPS Electronics N.V.2000
   5          //       All rights are reserved. Reproduction in whole or in part is 
   6          //      prohibited without the written consent of the copyright owner.
   7          //  Philips reserves the right to make changes without notice at any time.
   8          // Philips makes no warranty, expressed, implied or statutory, including but
   9          // not limited to any implied warranty of merchantibility or fitness for any
  10          //particular purpose, or that the use will not infringe any third party patent,
  11          // copyright or trademark. Philips must not be liable for any loss or damage
  12          //                          arising from its use.
  13          ///////////////////////////////////////////////////////////////////////////////
  14          #define __SRC
  15          #define __RC500
  16          #include "main.H"
  17          #include "rc500.h"
  18          
  19          #include <string.h>
  20          #include <stdio.h>
  21          
  22          
  23          
  24          ///////////////////////////////////////////////////////////////////////////////
  25          //                 Open Reader Communication
  26          ///////////////////////////////////////////////////////////////////////////////
  27          char OpenIO(void)
  28          {TOGGLE_WD();
  29   1         GpBase = &ini;
  30   1        RC500_CS = 0; 
  31   1         return 0x00;
  32   1      }
  33          
  34          
  35          
  36          
  37          
  38          ///////////////////////////////////////////////////////////////////////////////
  39          //                 Close Reader Communication
  40          ///////////////////////////////////////////////////////////////////////////////
  41          void CloseIO(void)
  42          {
  43   1         GpBase = 0xff00;
  44   1         RC500_CS = 1;        
  45   1      }
  46          
  47          ///////////////////////////////////////////////////////////////////////////////
  48          //          G E N E R I C    W R I T E
  49          ///////////////////////////////////////////////////////////////////////////////
  50          void WriteIO(unsigned char Address, unsigned char value)
  51          {
  52   1         WriteRawIO(Address,value);                 // write value at the specified 
  53   1                                                    // address
  54   1      }
C51 COMPILER V7.20   RC500                                                                 02/04/2007 10:44:17 PAGE 2   

  55          
  56          ///////////////////////////////////////////////////////////////////////////////
  57          //          G E N E R I C    R E A D
  58          ///////////////////////////////////////////////////////////////////////////////
  59          unsigned char ReadIO(unsigned char Address)
  60          {
  61   1         static unsigned char c;
  62   1         c = ReadRawIO(Address);                    // read value at the specified 
  63   1                                                 // address
  64   1         return c;
  65   1      }  
  66          #define SEC_NO_MICORE
  67          #ifndef SEC_NO_MICORE
              ///////////////////////////////////////////////////////////////////////////////
              //     W R I T E   S E V E R A L   M E M O R Y   L O C A T I O N S 
              ///////////////////////////////////////////////////////////////////////////////
              void WriteIOBlock(unsigned char *Addr_Data, unsigned short len)
              {
                 static unsigned short cnt;
              
                 for (cnt = 0; cnt < len; cnt++)
                 {
                      // write value at the specified address
                     WriteRawIO(Addr_Data[cnt*2],Addr_Data[cnt * 2 + 1]); 
                 }
              }
              
              ///////////////////////////////////////////////////////////////////////////////
              //     R E A D   S E V E R A L   M E M O R Y   L O C A T I O N S 
              ///////////////////////////////////////////////////////////////////////////////
              void ReadIOBlock(unsigned char* Addr_Data, unsigned short len)
              {
                 static unsigned short cnt;
              
                 for (cnt = 0; cnt < len; cnt)
                 {
                     Addr_Data[cnt*2 + 1] = ReadRawIO(Addr_Data[cnt*2]);// read value at the 
                                                                    // specified address
                 }
              }  
              #endif
  96          ///////////////////////////////////////////////////////////////////////////////
  97          //    Copyright (c), Philips Semiconductors Gratkorn
  98          //
  99          //                  (C)PHILIPS Electronics N.V.2000
 100          //       All rights are reserved. Reproduction in whole or in part is 
 101          //      prohibited without the written consent of the copyright owner.
 102          //  Philips reserves the right to make changes without notice at any time.
 103          // Philips makes no warranty, expressed, implied or statutory, including but
 104          // not limited to any implied warranty of merchantibility or fitness for any
 105          //particular purpose, or that the use will not infringe any third party patent,
 106          // copyright or trademark. Philips must not be liable for any loss or damage
 107          //                          arising from its use.
 108          ///////////////////////////////////////////////////////////////////////////////
 109          
 110          
 111          
 112          ////////////////////////////////////////////////////////////////////////////////
 113          //                M O D U L E   D E F I N I T I O N
 114          ////////////////////////////////////////////////////////////////////////////////
 115          // COMMENT: This library module is modified from the original source code for a
 116          //          microcontroller C164 CI, to suit the general purpose 8051 mcu.
C51 COMPILER V7.20   RC500                                                                 02/04/2007 10:44:17 PAGE 3   

 117          //          The source can be ported to other platforms very easily. 
 118          //          The communication channel to the RC500 reader IC is assumed to be 
 119          //          unknown. All data is written with the generic IO functions 
 120          //          of the module ReaderIO.h. In our case the reader module is 
 121          //          connected via memory mapped io at base address 0x7f00.
 122          //          The interrupt pin of the reader IC is assumed to be connected to 
 123          //          the fast external interrupt pin INT0# (active low) and the reset
 124          //          pin of the reader IC should be connected to a dedicated port pin
 125          //          (Port3: Pin: 3).
 126          //          In this configuration, a reset of the reader module is independend
 127          //          from the reset of the microcontroller.
 128          //          In order to generate communication timeouts, 
 129          //          general purpose timer 2 of the microcontroller is used. This 
 130          //          timer need not to be initialised in advance. Before every usage 
 131          //          the timer is completely initialised in each function. 
 132          //          Non of the timers is essential for the functionality of the reader
 133          //          module, but are helpful furing software development. All protocoll 
 134          //          relevant timing constraints are generated
 135          //          by the internal timer of the reader module.
 136          //
 137          //          Some explanations to the programming method of this library.
 138          //          There are three kind of functions coded in this module.
 139          //            a) internal functions, which have no prototypes in a header
 140          //               file and are not intended to be used outside of this file
 141          //            b) commands, which are intended for the reader module itself
 142          //            c) commands, which are intended for any tag in the rf field.
 143          //               These commands are send to the reader and the reader module
 144          //               transmitts the data to the rf interface.
 145          //          Commands for the reader and for the tag have the appropriate 
 146          //          prefix (PCD for proximity coupled device or reader module
 147          //                  PICC for proximity integrated circuit card or tag)
 148          //          and their protypes are defined in the header file.
 149          //          Each command for a PICC consists of a PCD command. Therefore
 150          //          the function M500PcdCmd is very important for the understanding
 151          //          of the communication.
 152          //
 153          //          The basic functionality is provided by the interrupt service
 154          //          routine (ISR), which closely works together with the function
 155          //          M500PcdCmd. All kinds of interrupts are serviced by the 
 156          //          same ISR. 
 157          
 158          
 159          // inline structure in order to reset the communication channel between 
 160          // function and ISR
 161          #define ResetInfo(info)    \
 162                      info.cmd            = 0; \
 163                      info.status         = MI_OK;\
 164                      info.irqSource      = 0;   \
 165                      info.nBytesSent     = 0;   \
 166                      info.nBytesToSend   = 0;  \
 167                      info.nBytesReceived = 0;  \
 168                      info.nBitsReceived  = 0;   \
 169                      info.collPos        = 0;
 170          
 171          // struct definition for a communication channel between function and ISR
 172          typedef struct 
 173                   {
 174                      unsigned char  cmd;           //!< command code 
 175                      char           status;        // communication status
 176                      unsigned char  nBytesSent;    // how many bytes already sent
 177                      unsigned char  nBytesToSend;  // how many bytes to send
 178                      unsigned char  nBytesReceived;// how many bytes received
C51 COMPILER V7.20   RC500                                                                 02/04/2007 10:44:17 PAGE 4   

 179                      unsigned short nBitsReceived; // how many bits received
 180                      unsigned char  irqSource;     // which interrupts have occured
 181                      unsigned char  collPos;       // at which position occured a
 182                                                    // collision
 183                   } MfCmdInfo;
 184          
 185          // modul variables 
 186          //extern TOGGLE_WD();
 187          //extern         unsigned char xdata *GpBase;
 188          
 189          static   unsigned char idata MFIFOLength = DEF_FIFO_LENGTH; // actual FIFO length
 190          
 191          //static   unsigned char xdata MKeys[16][12]; // storage for authentication keys
 192                                                // in order to provide a calling 
 193                              // compatible interface to old libraries
 194                                       // Other reader modules keep several sets
 195                                       // of keys in an E2PROM. In this case,
 196                                       // these keys are stored in the uC and
 197                                       // transfered to the reader module 
 198                                       // before authentication
 199          
 200          // Infomation concerning data processing
 201                   // send buffer for general use
 202                  
 203          static   volatile unsigned char idata MSndBuffer[SND_BUF_LEN]; /*pan dele xdata */
 204                   
 205          static   volatile unsigned char idata MRcvBuffer[RCV_BUF_LEN];
 206                   // info struct for general use
 207          static   volatile MfCmdInfo     MInfo;                  
 208          
 209          // Interrupt service routine
 210          // Variable in order to exchange data between function and ISR
 211          static  volatile MfCmdInfo     *MpIsrInfo = 0; 
 212                  // ISR send buffer
 213          static   volatile unsigned char   *MpIsrOut  = 0; /*pan add*/
 214                   // ISR receive buffer
 215          static  volatile unsigned char  *MpIsrIn   = 0;     
 216          
 217          // storage of the last selected serial number including check byte.
 218          //For multi level serial numbers, only the first 4 bytes are stored.
 219          unsigned char MLastSelectedSnr[5];
 220          
 221          // Timer 2
 222          bit             T2IR            = 0;    // Timer2 timeout flag
 223          unsigned int    CountDown       = 0;    // Timeout counter with 50us resolution
 224          
 225          ///////////////////////////////////////////////////////////////////////////////
 226          //             Prototypes for local functions 
 227          ///////////////////////////////////////////////////////////////////////////////
 228          
 229          void start_timeout(unsigned int _50us);
 230          void stop_timeout(void);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -