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

📄 m500auc.lst

📁 学校水POS读卡程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V7.06   M500AUC                                                               03/21/2005 16:36:23 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                                                               03/21/2005 16:36:23 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          //带参数的宏定义
  84          #define ResetInfo(info)    \
  85                      info.cmd            = 0; \
  86                      info.status         = MI_OK;\
  87                      info.irqSource      = 0;   \
  88                      info.nBytesSent     = 0;   \
  89                      info.nBytesToSend   = 0;  \
  90                      info.nBytesReceived = 0;  \
  91                      info.nBitsReceived  = 0;   \
  92                      info.collPos        = 0;
  93          
  94          // struct definition for a communication channel between function and ISR
  95          //定义一个结构体变量MfCmdInfo
  96          typedef struct
  97                   {
  98                      unsigned char   cmd;           //!< command code
  99                      char            status;        // communication status
 100                      unsigned char   nBytesSent;    // how many bytes already sent
 101                      unsigned char   nBytesToSend;  // how many bytes to send
 102                      unsigned char   nBytesReceived;// how many bytes received
 103                      unsigned short  nBitsReceived; // how many bits received
 104                      unsigned char   irqSource;     // which interrupts have occured
 105                      unsigned char   collPos;       // at which position occured a
 106                                                     // collision
 107                   } MfCmdInfo;
 108          
 109          // modul variables
 110          extern   unsigned char xdata *GpBase;//基地址0x7000;
 111          
 112          static   unsigned char data MFIFOLength = DEF_FIFO_LENGTH; // actual FIFO length
 113          
 114          static   unsigned char xdata MKeys[16][12]; // storage for authentication keys
 115                                       // in order to provide a calling
 116                                       // compatible interface to old libraries
 117                                       // Other reader modules keep several sets
C51 COMPILER V7.06   M500AUC                                                               03/21/2005 16:36:23 PAGE 3   

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

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

⌨️ 快捷键说明

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