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

📄 m500auc.lst

📁 学校水POS读卡程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V7.06   M500AUC                                                               02/25/2005 08:31:58 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE M500AUC
OBJECT MODULE PLACED IN M500AuC.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE M500AuC.c LARGE OPTIMIZE(2,SPEED) BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          
   2          #pragma large
   3          
   4          #include "w77e58.h"
   5          #include <Mfreg500.h>
   6          #include <M500A.h>
   7          #include <RdIo.h>
   8          
   9          #include <string.h>
  10          #include <stdio.h>
  11          #include <main.h>
  12          
  13          ////////////////////////////////////////////////////////////////////////////////
  14          //                M O D U L E   D E F I N I T I O N
  15          ////////////////////////////////////////////////////////////////////////////////
  16          // COMMENT: This library module is modified from the original source code for a
  17          //          microcontroller C164 CI, to suit the general purpose 8051 mcu.
  18          //          The source can be ported to other platforms very easily.
  19          //          The communication channel to the RC500 reader IC is assumed to be
  20          //          unknown. All data is written with the generic IO functions
  21          //          of the module ReaderIO.h. In our case the reader module is
  22          //          connected via memory mapped io at base address 0x7f00.
  23          //          The interrupt pin of the reader IC is assumed to be connected to
  24          //          the fast external interrupt pin INT0# (active low) and the reset
  25          //          pin of the reader IC should be connected to a dedicated port pin
  26          //          (Port3: Pin: 3).
  27          //          In this configuration, a reset of the reader module is independend
  28          //          from the reset of the microcontroller.
  29          //          In order to generate communication timeouts,
  30          //          general purpose timer 2 of the microcontroller is used. This
  31          //          timer need not to be initialised in advance. Before every usage
  32          //          the timer is completely initialised in each function.
  33          //          Non of the timers is essential for the functionality of the reader
  34          //          module, but are helpful furing software development. All protocoll
  35          //          relevant timing constraints are generated
  36          //          by the internal timer of the reader module.
  37          //
  38          //          Some explanations to the programming method of this library.
  39          //          There are three kind of functions coded in this module.
  40          //            a) internal functions, which have no prototypes in a header
  41          //               file and are not intended to be used outside of this file
  42          //            b) commands, which are intended for the reader module itself
  43          //            c) commands, which are intended for any tag in the rf field.
  44          //               These commands are send to the reader and the reader module
  45          //               transmitts the data to the rf interface.
  46          //          Commands for the reader and for the tag have the appropriate
  47          //          prefix (PCD for proximity coupled device or reader module
  48          //                  PICC for proximity integrated circuit card or tag)
  49          //          and their protypes are defined in the header file.
  50          //          Each command for a PICC consists of a PCD command. Therefore
  51          //          the function M500PcdCmd is very important for the understanding
  52          //          of the communication.
  53          //
  54          //          The basic functionality is provided by the interrupt service
  55          //          routine (ISR), which closely works together with the function
C51 COMPILER V7.06   M500AUC                                                               02/25/2005 08:31:58 PAGE 2   

  56          //          M500PcdCmd. All kinds of interrupts are serviced by the
  57          //          same ISR.
  58          
  59          
  60          static  unsigned char   keycoded[12];
  61          //         存取控制字节:    0xff,0x07,0x80,0x69 
  62          
  63          uchar code AledKey[16][12]={{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
  64                                       {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
  65                                       {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                                       {0xff,0xff,0xff,0xff,0xff,0xff,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                                       {0xff,0xff,0xff,0xff,0xff,0xff,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                                     } ;
  80          
  81          // inline structure in order to reset the communication channel between
  82          // function and ISR
  83          #define ResetInfo(info)    \
  84                      info.cmd            = 0; \
  85                      info.status         = MI_OK;\
  86                      info.irqSource      = 0;   \
  87                      info.nBytesSent     = 0;   \
  88                      info.nBytesToSend   = 0;  \
  89                      info.nBytesReceived = 0;  \
  90                      info.nBitsReceived  = 0;   \
  91                      info.collPos        = 0;
  92          
  93          // struct definition for a communication channel between function and ISR
  94          typedef struct
  95                   {
  96                      unsigned char   cmd;           //!< command code
  97                      char            status;        // communication status
  98                      unsigned char   nBytesSent;    // how many bytes already sent
  99                      unsigned char   nBytesToSend;  // how many bytes to send
 100                      unsigned char   nBytesReceived;// how many bytes received
 101                      unsigned short  nBitsReceived; // how many bits received
 102                      unsigned char   irqSource;     // which interrupts have occured
 103                      unsigned char   collPos;       // at which position occured a
 104                                                    // collision
 105                   } MfCmdInfo;
 106          
 107          // modul variables
 108          extern   unsigned char xdata *GpBase;
 109          
 110          static   unsigned char data MFIFOLength = DEF_FIFO_LENGTH; // actual FIFO length
 111          
 112          static   unsigned char xdata MKeys[16][12]; // storage for authentication keys
 113                                                // in order to provide a calling
 114                                                // compatible interface to old libraries
 115                                       // Other reader modules keep several sets
 116                                       // of keys in an E2PROM. In this case,
 117                                       // these keys are stored in the uC and
C51 COMPILER V7.06   M500AUC                                                               02/25/2005 08:31:58 PAGE 3   

 118                                       // transfered to the reader module
 119                                       // before authentication
 120          
 121          // Infomation concerning data processing
 122                   // send buffer for general use
 123          static   volatile unsigned char xdata MSndBuffer[SND_BUF_LEN];
 124                   // receive buffer for general use
 125          static   volatile unsigned char xdata MRcvBuffer[RCV_BUF_LEN];
 126                   // info struct for general use
 127          static   volatile  MfCmdInfo  xdata   MInfo;
 128          
 129          // Interrupt service routine
 130          // Variable in order to exchange data between function and ISR
 131          static   volatile MfCmdInfo      xdata   *MpIsrInfo = 0;
 132                  // ISR send buffer
 133          static   volatile unsigned char  xdata   *MpIsrOut  = 0;
 134                   // ISR receive buffer
 135          static   volatile unsigned char  xdata   *MpIsrIn   = 0;
 136          
 137          // storage of the last selected serial number including check byte.
 138          //For multi level serial numbers, only the first 4 bytes are stored.
 139          unsigned char MLastSelectedSnr[5];
 140          
 141          // Timer 2
 142          bit                   data  T2IR                = 0;            // Timer2 timeout flag
 143          unsigned int  data      CountDown       = 0;    // Timeout counter with 50us resolution
 144          
 145          
 146          
 147          ///////////////////////////////////////////////////////////////////////////////
 148          //             Prototypes for local functions
 149          ///////////////////////////////////////////////////////////////////////////////
 150          
 151          void start_timeout(unsigned int _50us);
 152          void stop_timeout(void);
 153          
 154          // _____________________________________________________________________________
 155          //
 156          //  FUNCTION: M500PcdSetTmo
 157          //        IN: tmoLength   1  ... 1.0 ms timeout periode
 158          //                        2  ... 1.5 ms timeout periode
 159          //                        3  ... 6.0 ms timeout periode
 160          //                        4  ... 9.6 ms timeout period
 161          //                        5  ... 38.5 ms timeout period
 162          //                        6  ... 154 ms timeout period
 163          //                        7  ... 616.2 ms timeout period
 164          //       OUT: -
 165          //    RETURN:
 166          //   COMMENT: Set timeout length of the reader internal timer.
 167          //
 168          void M500PcdSetTmo(unsigned char tmoLength);
 169          
 170          // _____________________________________________________________________________
 171          //
 172          //  FUNCTION: M500PcdCmd
 173          //        IN: cmd  PCD_IDLE
 174          //                   PCD_WRITEE2
 175          //                   PCD_READE2
 176          //                   PCD_LOADCONFIG
 177          //                   PCD_LOADKEYE2
 178          //                   PCD_AUTHENT1
 179          //                   PCD_CALCCRC
C51 COMPILER V7.06   M500AUC                                                               02/25/2005 08:31:58 PAGE 4   

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

⌨️ 快捷键说明

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