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

📄 main.lst

📁 学校水POS读卡程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V6.23a  MAIN                                                                  09/14/2004 14:19:20 PAGE 1   


C51 COMPILER V6.23a, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE main.c LARGE OPTIMIZE(2,SPEED) BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          /****************************************************************************
   2          *                                                                           *
   3          * File:         MAIN.C                                                      *
   4          *                                                                           *
   5          * Version:      V2.0                                                                *
   6          *                                                                           *
   7          * Created:      2003/10/11                                                  *
   8          * Last Change:  2004/9/14                                                   *
   9          *                                                                           *
  10          * Author:       DavidQi                                                     *
  11          *                                                                           *
  12          * Compiler:     KEIL C51 V6.23A                                             *
  13          *                                                                           *
  14          * Description:  输出 M1序列号                                                 *
  15          *                                                                           *
  16          ****************************************************************************/
  17          #pragma large
  18          #define __SRC
  19          
  20          #include <main.h>
  21          #undef  __SRC
  22          
  23          
  24          #include <string.h>
  25          #include <intrins.h>
  26          
  27          
  28          #include <stdio.h>
  29          #include <m500a.h>
  30          #include <w77e58.h>
  31          #include <rdio.h>
  32          
  33          #define MIS_CHK_OK              (0)
  34          #define MIS_CHK_FAILED          (-1)
  35          #define MIS_CHK_COMPERR         (-2)
  36          
  37          // Function: mifs_request
  38          #define IDLE                    0x00
  39          #define ALL                     0x01
  40          
  41          
  42          // PC Debug Data: 02 30 31 32 03 33     checksum =33 (30^31^32)
  43          // Release Number of the Firmware
  44          uchar code SW_Rel[] = "\n\r MFRC500 V1.0 8.03.2003 \n\r";
  45          uchar code ms[4][2] = {{0x0,0x0},{0x0,0x0},{0x0,0x0},{0x0,0x0}};
  46          
  47          // Serial Number of the MFRC500
  48          //uchar Snr_RC500[4];
  49          uchar xdata Snr_RC500[4];
  50          //static uint Crc;
  51          
  52          // Local Prototypes
  53          void init(void);
  54          void cmd_execution(void);
  55          
C51 COMPILER V6.23a  MAIN                                                                  09/14/2004 14:19:20 PAGE 2   

  56          // Interrupt Service Routines
  57          void isr_timer0(void);
  58          void isr_UART(void);
  59          
  60          //uchar card_snr[4];
  61          uchar  xdata card_snr[4];
  62          char   xdata ErrNum;
  63          
  64          unsigned char code CmdData_1[]={0x7f,0x40,0x05,0x0,0x0,0x0,0x0};
  65          
  66          unsigned char code CmdData_2[]={0x7f,0x42,0x08,0x0,0x0,0x0,0x0,0x0};
  67          
  68          uchar xdata SectorNum, BlockNum,CommandNum,Key[6],CardData[16],KeyData[6];
  69          
  70          uchar xdata CardSnrNum[6];
  71          
  72          uchar xdata SnrErr;
  73          
  74          uchar data ComeCard = 0,GoCard = 0;ChkSum1 = 0;
  75          uchar data DetCardCnt=0;
  76          bit   SendCardSnrFlag;
  77          
  78          void main (void)
  79          { 
  80   1        init();
  81   1      
  82   1        test();       
  83   1      
  84   1        M500PcdConfig();      // Initialise the RC500
  85   1                                  // must be call in the initialization
  86   1      
  87   1      //  RC500 E2PROM  0x00--0x0f Product Information Field
  88   1      //                0x08--0x0b  Product Serial Number
  89   1       
  90   1        PcdReadE2(8,4,Snr_RC500); // Read out the MFRC500 serial number and store it
  91   1          
  92   1        RingOn();
  93   1      
  94   1        SendCardSnrFlag = 1; 
  95   1      
  96   1        while(1)
  97   1        {
  98   2          init();
  99   2          M500PcdConfig();
 100   2      
 101   2          DetCardCnt = 10;
 102   2          ComeCard = 0;
 103   2          
 104   2      
 105   2          while(DetCardCnt!=0|ComeCard==3)
 106   2          {
 107   3           SerBuffer[1] = 0x40;
 108   3           cmd_execution();
 109   3                
 110   3           if(AccOk )
 111   3           {  
 112   4              ComeCard++;
 113   4              if(ComeCard == 3)
 114   4              {
 115   5                P1_6 = 1; 
 116   5               // ComeCard = 0; 
 117   5                break;      
C51 COMPILER V6.23a  MAIN                                                                  09/14/2004 14:19:20 PAGE 3   

 118   5              }
 119   4              
 120   4              AccOk = FALSE ;
 121   4              GoCard = 0;
 122   4           }  
 123   3           else
 124   3           {        
 125   4               GoCard++;
 126   4               if(GoCard == 3)
 127   4               {
 128   5                 P1_6 = 0; 
 129   5                 GoCard = 0;           
 130   5               }
 131   4               ComeCard = 0;
 132   4       
 133   4               SendCardSnrFlag = 1;      
 134   4      
 135   4           } 
 136   3           DetCardCnt--; 
 137   3           M500PcdConfig();
 138   3           //SerBuffer[1] = 0x45;
 139   3           //cmd_execution();
 140   3           //delay_10ms(5); 
 141   3         }
 142   2      
 143   2          M500PcdConfig();
 144   2         // SerBuffer[1] = 0x45;
 145   2         // cmd_execution();
 146   2         // delay_10ms(5); 
 147   2      
 148   2      // 检测是否有MIFARE卡在读头感应区,有卡将卡号发送到PC机
 149   2         /*   
 150   2          while(!AccOk)
 151   2          {
 152   2            memcpy(SerBuffer,CmdData_1,7);
 153   2            cmd_execution();
 154   2      
 155   2                AccOk = FALSE ;
 156   2          
 157   2            memcpy(SerBuffer,CmdData_2,8);
 158   2      
 159   2           // 命令码: 0x42:  执行 Anticoll 返回序列号
 160   2            cmd_execution();
 161   2      
 162   2           }
 163   2          
 164   2          AccOk = FALSE ;   
 165   2           
 166   2          TransHexAsi(&SerBuffer[3],SendBuffer,4);//4字节卡序列号
 167   2      
 168   2          SendDataToPc(SendBuffer,8);//发送8字节ASCII码到PC      
 169   2          */
 170   2          AccOk = FALSE ;
 171   2          //等待PC 发送命令
 172   2         // while(!FrameOk); 
 173   2          //RingOn();   
 174   2          
 175   2          //TransData(PcData,SerBuffer,DataLen);//SerBuffer: PC 与MCU交互数据缓冲区
 176   2      
 177   2          /*
 178   2           cmd_execution() 命令执行程序
 179   2           命令码:               命令功能:
C51 COMPILER V6.23a  MAIN                                                                  09/14/2004 14:19:20 PAGE 4   

 180   2           0x40:                  // PICC_REQALL
 181   2           0x41:                  // Request
 182   2           0x42:                  // Anticoll
 183   2           0x43:                  // Select
 184   2           0x44:                  // Authentication
 185   2           0x45:                  // Halt
 186   2               0x46:                  // Read
 187   2           0x47:                  // Write
 188   2               0x48:                  // Increment
 189   2           0x49:                                      // Decrement
 190   2           0x4A:                                      // Restore
 191   2               0x4B:                                  // Transfer
 192   2               0x4C:                                  // Load Key
 193   2           0x4D:                                      // comm check char
 194   2           0x4E:                                      // Reset
 195   2           0x4F:                      // Get Info
 196   2           0x50:                                      // Set Control Bit
 197   2           0x51:                                      // Clr Control Bit
 198   2           0x52:                      // Config
 199   2           0x53:                                      // Check Write
 200   2           0x54:                                      // Set Port
 201   2           0x55:                                      // Get Port
 202   2           0x56:                      // Authentication2
 203   2           0x57:                  // Decrement+Transfer
 204   2          */
 205   2          CommandNum =  SerBuffer[0]; //命令码
 206   2          SectorNum =  SerBuffer[1];  //mifare1卡:扇区号
 207   2          BlockNum =  SerBuffer[2];   //mifare1卡:块号 
 208   2          memcpy(KeyData,&SerBuffer[3],6);//mifare1卡:块密码6字节
 209   2          memcpy(CardData,&SerBuffer[3],16);//mifare1卡:待写的16字节数据
 210   2      
 211   2          FrameOk = 0;
 212   2          if(CommandNum == 0x4c)
 213   2          {      
 214   3           
 215   3             SerBuffer[1] = 0x4c;
 216   3             SerBuffer[MODE] = PICC_AUTHENT1A;  //MODE = 3
 217   3             SerBuffer[SECNR] = SectorNum;      //SECNR = 4
 218   3             memcpy(&SerBuffer[13],KeyData,6);
 219   3             cmd_execution();
 220   3             if(!ErrNum)
 221   3             {
 222   4                   SerBuffer[3] = 0x0;
 223   4                   TransHexAsi(&SerBuffer[3],SendBuffer,1);
 224   4                   SendDataToPc(SendBuffer,2);
 225   4                   RingOn();
 226   4             }
 227   3             
 228   3          }  
 229   2      
 230   2          else 
 231   2          {     
 232   3            memcpy(SerBuffer,CmdData_1,7);  //命令码:0x40  执行PICC_REQALL 返回卡型2字节 
 233   3      
 234   3            cmd_execution();
 235   3      
 236   3           if(!ErrNum)               
 237   3           {
 238   4            
 239   4              memcpy(SerBuffer,CmdData_2,8);
 240   4      
 241   4              cmd_execution();//命令码:0x42: 执行 Anticoll 返回序列号
C51 COMPILER V6.23a  MAIN                                                                  09/14/2004 14:19:20 PAGE 5   

 242   4      
 243   4              AccOk = FALSE ;
 244   4      
 245   4              memcpy(card_snr,&SerBuffer[SERNR],4);
 246   4      //--------------------------------------------------------------------------
 247   4      // | 02 | 10 ASCII Data |Characters Checksum | CR | LF | 03 |
 248   4      //--------------------------------------------------------------------------        
 249   4              SnrErr = CheckSnrNum();
 250   4              if(SnrErr == 0)
 251   4              {
 252   5                if(SendCardSnrFlag == 1)
 253   5                { 
 254   6                 SendSnrNum();   //发送序列号:02+10字节(0xff+0x + + + + )+checksum(2字节)+0d + 0a + 03
 255   6                 SendCardSnrFlag = 0;       
 256   6                 FlashLED();
 257   6                }
 258   5      
 259   5              }
 260   4      /*       
 261   4              if(!ErrNum)
 262   4              {
 263   4                 SerBuffer[1] = 0x43;
 264   4      
 265   4                 cmd_execution();// 命令码: 0x43:  选择卡片 返回卡片的 SIZE 字节 0x88h 
 266   4      
 267   4                 AccOk = FALSE ;
 268   4      
 269   4                 SerBuffer[1] = 0x44;
 270   4                 SerBuffer[2] = BlockNum;
 271   4      
 272   4                 SerBuffer[3] = 0 ;
 273   4              
 274   4                 SerBuffer[4] = SectorNum; //卡扇区号(0-15):= 2(含块8,9,10)
 275   4      
 276   4                 cmd_execution();//命令码:0x44: 密码认证操作
 277   4      
 278   4                 if(!ErrNum)
 279   4                 {
 280   4                     if(AuthOk == 0)
 281   4                     {

⌨️ 快捷键说明

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