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

📄 slrc632.lst

📁 读ISO14443 CPU卡源代码
💻 LST
📖 第 1 页 / 共 3 页
字号:
 440   2               waitFor = 0x04;
 441   2               recebyte=1;
 442   2               break;
 443   2            case PCD_LOADCONFIG:
 444   2            case PCD_LOADKEYE2:
 445   2            case PCD_AUTHENT1:
 446   2               irqEn   = 0x05;
 447   2               waitFor = 0x04;
 448   2               break;
 449   2            case PCD_CALCCRC:
 450   2               irqEn   = 0x11;
 451   2               waitFor = 0x10;
 452   2               break;
 453   2            case PCD_AUTHENT2:
 454   2               irqEn   = 0x04;
 455   2               waitFor = 0x04;
 456   2               break;
 457   2            case PCD_RECEIVE:
 458   2               irqEn   = 0x06;
 459   2               waitFor = 0x04;
 460   2               recebyte=1;
 461   2               break;
 462   2            case PCD_LOADKEY:
 463   2               irqEn   = 0x05;
 464   2               waitFor = 0x04;
 465   2               break;
 466   2            case PCD_TRANSMIT:
 467   2               irqEn   = 0x05;
 468   2               waitFor = 0x04;
 469   2               break;
 470   2            case PCD_TRANSCEIVE:
 471   2               irqEn   = 0x3D;
 472   2               waitFor = 0x04;
 473   2               recebyte=1;
 474   2               break;
 475   2            default:
 476   2               pi->MfCommand = MI_UNKNOWN_COMMAND;
 477   2               break;
 478   2         }
 479   1         
 480   1         if (pi->MfCommand != MI_UNKNOWN_COMMAND)
 481   1         {
 482   2            WriteRawRC(RegPage,0x00);
 483   2            WriteRawRC(RegInterruptEn,0x7F);
 484   2            WriteRawRC(RegInterruptRq,0x7F);
 485   2            WriteRawRC(RegCommand,PCD_IDLE);
 486   2            SetBitMask(RegControl,0x01);
 487   2            WriteRawRC(RegInterruptEn,irqEn|0x80);
 488   2            for (i=0; i<pi->MfLength; i++)
 489   2            {
C51 COMPILER V8.05a   SLRC632                                                              07/05/2010 23:34:44 PAGE 9   

 490   3               WriteRawRC(RegFIFOData, pi->MfData[i]);
 491   3            }
 492   2            WriteRawRC(RegCommand, pi->MfCommand);
 493   2            i = 0x3500;
 494   2            do
 495   2            {
 496   3               n = ReadRawRC(RegInterruptRq);
 497   3               i--;
 498   3            }
 499   2            while ((i!=0) && !(n&irqEn&0x20) && !(n&waitFor));
 500   2            status = MI_COM_ERR;
 501   2            if ((i!=0) && !(n&irqEn&0x20))
 502   2            {
 503   3               if (!(ReadRawRC(RegErrorFlag)&0x17))
 504   3               {
 505   4                  status = MI_OK;
 506   4                  if (recebyte)
 507   4                  {
 508   5                      n = ReadRawRC(RegFIFOLength);
 509   5                      lastBits = ReadRawRC(RegSecondaryStatus) & 0x07;
 510   5                      if (lastBits)
 511   5                      {
 512   6                         pi->MfLength = (n-1)*8 + lastBits;
 513   6                      }
 514   5                      else
 515   5                      {
 516   6                         pi->MfLength = n*8;
 517   6                      }
 518   5                      if (n == 0)
 519   5                      {
 520   6                         n = 1;
 521   6                      }
 522   5                      for (i=0; i<n; i++)
 523   5                      {
 524   6                          pi->MfData[i] = ReadRawRC(RegFIFOData);
 525   6                      }
 526   5                  }
 527   4               }
 528   3                       else if (ReadRawRC(RegErrorFlag)&0x01)
 529   3               {
 530   4                          status = MI_COLLERR;
 531   4                  if (recebyte)
 532   4                  {
 533   5                      n = ReadRawRC(RegFIFOLength);
 534   5                      lastBits = ReadRawRC(RegSecondaryStatus) & 0x07;
 535   5                      if (lastBits)
 536   5                      {
 537   6                         pi->MfLength = (n-1)*8 + lastBits;
 538   6                      }
 539   5                      else
 540   5                      {
 541   6                         pi->MfLength = n*8;
 542   6                      }
 543   5                      if (n == 0)
 544   5                      {
 545   6                         n = 1;
 546   6                      }
 547   5                      for (i=0; i<n; i++)
 548   5                      {
 549   6                          pi->MfData[i+1] = ReadRawRC(RegFIFOData);
 550   6                      }
 551   5                  }
C51 COMPILER V8.05a   SLRC632                                                              07/05/2010 23:34:44 PAGE 10  

 552   4                              pi->MfData[0]=ReadRawRC(0x0B);
 553   4               }
 554   3      
 555   3            }
 556   2            else if (n & irqEn & 0x20)
 557   2            {   status = MI_NOTAGERR;   }
 558   2            else if (!(ReadRawRC(RegErrorFlag)&0x17))
 559   2            {   status = MI_ACCESSTIMEOUT;   }
 560   2            else
 561   2            {   status = MI_COM_ERR;    }
 562   2            
 563   2            WriteRawRC(RegInterruptEn,0x7F);
 564   2            WriteRawRC(RegInterruptRq,0x7F);
 565   2            SetBitMask(RegControl,0x04);           // stop timer now
 566   2            WriteRawRC(RegCommand,PCD_IDLE); 
 567   2         }
 568   1         return status;
 569   1      }
 570          
 571          
 572          /*
 573          /////////////////////////////////////////////////////////////////////
 574          //读RC632EEPROM
 575          //input :startaddr=EEPROM地址(低位在前)
 576          //       length=读字节数
 577          //output:readdata=读出的数据
 578          /////////////////////////////////////////////////////////////////////
 579          char PcdReadE2(unsigned int startaddr,unsigned char length,unsigned char *readdata)
 580          {
 581              char status;
 582              struct TranSciveBuffer MfComData;
 583              struct TranSciveBuffer *pi;
 584              pi = &MfComData;
 585          
 586              MfComData.MfCommand = PCD_READE2;
 587              MfComData.MfLength  = 3;
 588              MfComData.MfData[0] = startaddr&0xFF;
 589              MfComData.MfData[1] = (startaddr >> 8) & 0xFF;
 590              MfComData.MfData[2] = length;
 591          
 592              status = PcdComTransceive(pi);
 593          
 594              if (status == MI_OK)
 595              {   memcpy(readdata, &MfComData.MfData[0], length);    }
 596              return status;
 597          }
 598          
 599          /////////////////////////////////////////////////////////////////////
 600          //写RC632EEPROM
 601          //input :startaddr=EEPROM地址(低位在前)
 602          //       length=写字节数
 603          //       writedata=要写入的数据
 604          /////////////////////////////////////////////////////////////////////
 605          char PcdWriteE2(unsigned int startaddr,unsigned char length,unsigned char *writedata)
 606          {
 607              char status;
 608              struct TranSciveBuffer MfComData;    
 609              struct TranSciveBuffer *pi;
 610              pi = &MfComData;
 611          
 612              MfComData.MfCommand = PCD_WRITEE2;
 613              MfComData.MfLength  = length+2;
C51 COMPILER V8.05a   SLRC632                                                              07/05/2010 23:34:44 PAGE 11  

 614              MfComData.MfData[0] = startaddr&0xFF;
 615              MfComData.MfData[1] = (startaddr >> 8) & 0xFF;
 616              memcpy(&MfComData.MfData[2], writedata, length);    
 617          
 618              status = PcdComTransceive(pi);
 619              return status;
 620          }
 621          */
 622          
 623          /////////////////////////////////////////////////////////////////////
 624          //开启天线  
 625          //每次启动或关闭天险发射之间应至少有1ms的间隔
 626          /////////////////////////////////////////////////////////////////////
 627          char PcdAntennaOn()
 628          {
 629   1          unsigned char i;
 630   1          i = ReadRawRC(RegTxControl);
 631   1          if (i & 0x03)
 632   1          {   return MI_OK;   }
 633   1          else
 634   1          {
 635   2              SetBitMask(RegTxControl, 0x03);
 636   2              return MI_OK;
 637   2          }
 638   1      }
 639          
 640          /////////////////////////////////////////////////////////////////////
 641          //关闭天线
 642          /////////////////////////////////////////////////////////////////////
 643          char PcdAntennaOff()
 644          {
 645   1          ClearBitMask(RegTxControl, 0x03);
 646   1          return MI_OK;
 647   1      }
 648          
 649          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1828    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      15
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----       1
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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