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

📄 m500auc.lst

📁 mifarea卡程序mifarea卡程序mifarea卡程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V7.02a   M500AUC                                                              07/24/2003 11:05:36 PAGE 1   


C51 COMPILER V7.02a, COMPILATION OF MODULE M500AUC
OBJECT MODULE PLACED IN M500AuC.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE source\M500AuC.c LARGE BROWSE ORDER NOAREGS DEBUG OBJECTEXTEND PRINT(.\M500
                    -AuC.lst) OBJECT(M500AuC.obj)

stmt level    source

   1          /****************************************************************************
   2          * File:         M500AuC.c
   3          * Version:      1.0                                       
   4          * Created:     2003.07.08                                     
   5          * Last Change:  2003.07.08
   6          * Author:       dong yongde  , refer to philips
   7          * Company:  LANTOON TECH   
   8          * Compiler:     KEIL C51 uVision2 V2.32 
   9          * Description:  Low level I/O functions for RC500
  10          ****************************************************************************/
  11          #define DLL_EXPORT      // library source module definition
  12          //#include "p89c51rx.h"
  13          #include "reg52.h"
  14          #include "Mfreg500.h"
  15          #include "M500Auc.h"
  16          #include "ucio.h"
  17          #include "timer.h"
  18          
  19          #include <string.h>
  20          //#include <stdio.h>
  21          //#include "main.h"
  22          
  23          #define ReadRawIO       ReadIO
  24          #define WriteRawIO      WriteIO
  25          
  26          ////////////////////////////////////////////////////////////////////////////////
  27          //                M O D U L E   D E F I N I T I O N
  28          ////////////////////////////////////////////////////////////////////////////////
  29          // COMMENT: This library module is modified from the original source code for a
  30          //          microcontroller C164 CI, to suit the general purpose 8051 mcu.
  31          //          The source can be ported to other platforms very easily. 
  32          //          The communication channel to the RC500 reader IC is assumed to be 
  33          //          unknown. All data is written with the generic IO functions 
  34          //          of the module ReaderIO.h. In our case the reader module is 
  35          //          connected via memory mapped io at base address 0x7f00.
  36          //          The interrupt pin of the reader IC is assumed to be connected to 
  37          //          the fast external interrupt pin INT0# (active low) and the reset
  38          //          pin of the reader IC should be connected to a dedicated port pin
  39          //          (Port3: Pin: 3).
  40          //          In this configuration, a reset of the reader module is independend
  41          //          from the reset of the microcontroller.
  42          //          In order to generate communication timeouts, 
  43          //          general purpose timer 2 of the microcontroller is used. This 
  44          //          timer need not to be initialised in advance. Before every usage 
  45          //          the timer is completely initialised in each function. 
  46          //          Non of the timers is essential for the functionality of the reader
  47          //          module, but are helpful furing software development. All protocoll 
  48          //          relevant timing constraints are generated
  49          //          by the internal timer of the reader module.
  50          //
  51          //          Some explanations to the programming method of this library.
  52          //          There are three kind of functions coded in this module.
  53          //            a) internal functions, which have no prototypes in a header
  54          //               file and are not intended to be used outside of this file
C51 COMPILER V7.02a   M500AUC                                                              07/24/2003 11:05:36 PAGE 2   

  55          //            b) commands, which are intended for the reader module itself
  56          //            c) commands, which are intended for any tag in the rf field.
  57          //               These commands are send to the reader and the reader module
  58          //               transmitts the data to the rf interface.
  59          //          Commands for the reader and for the tag have the appropriate 
  60          //          prefix (PCD for proximity coupled device or reader module
  61          //                  PICC for proximity integrated circuit card or tag)
  62          //          and their protypes are defined in the header file.
  63          //          Each command for a PICC consists of a PCD command. Therefore
  64          //          the function M500PcdCmd is very important for the understanding
  65          //          of the communication.
  66          //
  67          //          The basic functionality is provided by the interrupt service
  68          //          routine (ISR), which closely works together with the function
  69          //          M500PcdCmd. All kinds of interrupts are serviced by the 
  70          //          same ISR. 
  71          
  72          
  73          // inline structure in order to reset the communication channel between 
  74          // function and ISR
  75          #define ResetInfo(info)    \
  76                      info.cmd            = 0; \
  77                      info.status         = MI_OK;\
  78                      info.irqSource      = 0;   \
  79                      info.nBytesSent     = 0;   \
  80                      info.nBytesToSend   = 0;  \
  81                      info.nBytesReceived = 0;  \
  82                      info.nBitsReceived  = 0;   \
  83                      info.collPos        = 0;
  84          
  85          // struct definition for a communication channel between function and ISR
  86          typedef struct 
  87                   {
  88                      unsigned char  cmd;           //!< command code 
  89                      char           status;        // communication status
  90                      unsigned char  nBytesSent;    // how many bytes already sent
  91                      unsigned char  nBytesToSend;  // how many bytes to send
  92                      unsigned char  nBytesReceived;// how many bytes received
  93                      unsigned short nBitsReceived; // how many bits received
  94                      unsigned char  irqSource;     // which interrupts have occured
  95                      unsigned char  collPos;       // at which position occured a
  96                                                    // collision
  97                   } MfCmdInfo;
  98          
  99          // modul variables 
 100          //extern         unsigned char xdata *GpBase;
 101          
 102          static   unsigned char idata MFIFOLength = DEF_FIFO_LENGTH; // actual FIFO length
 103          
 104          //static   unsigned char xdata MKeys[16][12]; // storage for authentication keys
 105                                                // in order to provide a calling 
 106                                                // compatible interface to old libraries
 107                                       // Other reader modules keep several sets
 108                                       // of keys in an E2PROM. In this case,
 109                                       // these keys are stored in the uC and
 110                                       // transfered to the reader module 
 111                                       // before authentication
 112          
 113          // Infomation concerning data processing
 114                   // send buffer for general use
 115          static   volatile unsigned char xdata MSndBuffer[SND_BUF_LEN];
 116                   // receive buffer for general use
C51 COMPILER V7.02a   M500AUC                                                              07/24/2003 11:05:36 PAGE 3   

 117          static   volatile unsigned char xdata MRcvBuffer[RCV_BUF_LEN];
 118                   // info struct for general use
 119          static   volatile MfCmdInfo     MInfo;                  
 120          
 121          // Interrupt service routine
 122          // Variable in order to exchange data between function and ISR
 123          static   volatile MfCmdInfo     *MpIsrInfo = 0; 
 124                  // ISR send buffer
 125          static   volatile unsigned char *MpIsrOut  = 0; 
 126                   // ISR receive buffer
 127          static   volatile unsigned char *MpIsrIn   = 0;     
 128          
 129          // storage of the last selected serial number including check byte.
 130          //For multi level serial numbers, only the first 4 bytes are stored.
 131          unsigned char MLastSelectedSnr[5];
 132          
 133          // Timer 2
 134          extern bit              T2IR            ;       // Timer2 timeout flag
 135          extern unsigned int CountDown   ;// Timeout counter with 50us resolution
 136          
 137          sbit    RC500RST                = P3^5;
 138          //sbit    LED                   = P3^4;
 139          
 140          ///////////////////////////////////////////////////////////////////////////////
 141          //             Prototypes for local functions 
 142          ///////////////////////////////////////////////////////////////////////////////
 143          
 144          
 145          // _____________________________________________________________________________
 146          //
 147          //  FUNCTION: M500PcdSetTmo
 148          //        IN: tmoLength   1  ... 1.0 ms timeout periode
 149          //                        2  ... 1.5 ms timeout periode
 150          //                        3  ... 6.0 ms timeout periode
 151          //                        4  ... 9.6 ms timeout period
 152          //                        5  ... 38.5 ms timeout period
 153          //                        6  ... 154 ms timeout period
 154          //                        7  ... 616.2 ms timeout period
 155          //       OUT: -
 156          //    RETURN: 
 157          //   COMMENT: Set timeout length of the reader internal timer.
 158          //               
 159          void M500PcdSetTmo(unsigned char tmoLength);
 160          
 161          // _____________________________________________________________________________
 162          //
 163          //  FUNCTION: M500PcdCmd
 164          //        IN: cmd  PCD_IDLE
 165          //                   PCD_WRITEE2
 166          //                   PCD_READE2
 167          //                   PCD_LOADCONFIG
 168          //                   PCD_LOADKEYE2
 169          //                   PCD_AUTHENT1
 170          //                   PCD_CALCCRC
 171          //                   PCD_AUTHENT2
 172          //                   PCD_RECEIVE
 173          //                   PCD_LOADKEY
 174          //                   PCD_TRANSMIT
 175          //                   PCD_TRANSCEIVE
 176          //                   PCD_RESETPHASE
 177          //                   for a detailed description of the parameter values, please
 178          //                   have a look on the header file of the reader register
C51 COMPILER V7.02a   M500AUC                                                              07/24/2003 11:05:36 PAGE 4   

 179          //                   definitions.
 180          //            send      byte stream of variable length, which should be send to
 181          //                      the PICC, the length of stream has to be specified
 182          //                      in the info - structure
 183          //       OUT: rcv    byte stream of variable length, which was received 
 184          //                      from the PICC or PCD
 185          //            info      communication and status structure
 186          //    RETURN: 
 187          //   COMMENT: This function provides the central interface to the reader module.
 188          //            Depending on the "cmd"-value, all necessary interrupts are enabled
 189          //            and the communication is started. While the processing is done by
 190          //            the reader module, this function waits for its completion.
 191          //            It's notable, that the data in the "send byte stream" is written 
 192          //            to the FIFO of the reader module by the ISR. Immediate after 
 193          //            enabling the interrupts, the LoAlert interrupt is activated.
 194          //            The ISR writes the data to the FIFO. This function is not involved
 195          //            in writing or fetching data from FIFO, all work is done by the 
 196          //            ISR.After command completion, the error status is evaluated and 
 197          //            returned to the calling function.
 198          //
 199          char M500PcdCmd(unsigned char cmd,
 200                          volatile unsigned char* send, 
 201                          volatile unsigned char* rcv,
 202                          volatile MfCmdInfo *info);
 203          
 204          // _____________________________________________________________________________
 205          //
 206          //  FUNCTION: SetBitMask
 207          //        IN: reg      register address
 208          //            mask     bit mask to set
 209          //       OUT: -
 210          //    RETURN: 
 211          //   COMMENT:  This function performs a read - modify - write sequence
 212          //             on the specified register. All bits with a 1 in the mask
 213          //             are set - all other bits keep their original value.
 214          //
 215          char SetBitMask(unsigned char reg,unsigned char mask);
 216          
 217          // _____________________________________________________________________________
 218          //
 219          //  FUNCTION: ClearBitMask
 220          //        IN: reg      register address
 221          //            mask     bit mask to clear
 222          //       OUT: -
 223          //    RETURN: 
 224          //   COMMENT:  This function performs a read - modify - write sequence
 225          //             on the specified register. All bits with a 1 in the mask
 226          //             are cleared - all other bits keep their original value.
 227          //
 228          char ClearBitMask(unsigned char reg,unsigned char mask);
 229          
 230          // _____________________________________________________________________________
 231          //

⌨️ 快捷键说明

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