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

📄 r6c.lst

📁 采用C52+R6C完成的ISO15693标准的刷卡器程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
 252   1      }
 253          
 254          void _sendfifocmd(void)
 255          {
 256   1              bit flag;
 257   1              uchar Bytecnt,nrofBytes ,bitcnt,nbBit,ISOcmd;
 258   1              uint i;  
 259   1              
 260   1              ISOcmd = ReflectBYTE(pcdata[5]);
 261   1              /*
 262   1              pcdata[1] = pcdata[1]&0x07;
 263   1              if (pcdata[2]==0x16)
 264   1                      nrofBytes = pcdata[0]-3-2; //last 2 bytes are for CRC.
 265   1              else if (pcdata[2]==0x18)
 266   1              {
 267   1                      nrofBytes = 1; // send only command nr
 268   1                      pcdata[1] = 0;
 269   1              }
 270   1              else
 271   1                      nrofBytes = pcdata[0]-3;
 272   1                      */
 273   1              nrofBytes = pcdata[0]-3;
 274   1      
 275   1              _startBit();
 276   1              
 277   1              for(Bytecnt=0;Bytecnt<nrofBytes ;Bytecnt++)
 278   1              {
 279   2                      if(Bytecnt<nrofBytes-1)
 280   2                              nbBit = 8;
 281   2                      else if(!pcdata[1])
 282   2                              nbBit = 8;
 283   2                      else
 284   2                              nbBit = pcdata[1];
 285   2                      for(bitcnt=0;bitcnt<nbBit;bitcnt++)
 286   2                      {       
 287   3                              //_setTimer(2); 
 288   3                              while ((DOUT)&&(!TIMERINT)); //FIFO Management
 289   3                              clrTimer();
 290   3                              pcdata[Bytecnt+3] = pcdata[Bytecnt+3] << 1;
 291   3                              flag = CY;
 292   3                              _sendBit(flag);
 293   3                      }
 294   2                      if(Bytecnt == 0)
 295   2                      {
 296   3                              for(i=0;i<0x5FF;i++);
 297   3                      }
 298   2              }
 299   1              /*      
 300   1         switch (ISOcmd)
 301   1         {
 302   1                      case 0x21: case 0x22: case 0x24:
 303   1                      case 0x27: case 0x28: case 0x29: case 0x2A:
C51 COMPILER V8.08   R6C                                                                   01/18/2009 20:00:52 PAGE 6   

 304   1                      case 0xA2: case 0xA3: case 0xa4: case 0xa5:
 305   1                      {               
 306   1                              _setTimer(2);
 307   1                              while((DOUT)&&(!TIMERINT)); _stopBit();
 308   1                              
 309   1                              _clrTimer();
 310   1                              for(i=0;i<0xbff;i++);  break;
 311   1                      }
 312   1              }
 313   1              */
 314   1      }
 315          
 316          bit b_collision;
 317          bit userCardOk;
 318          #define TIME_OUT_ASICRDY  3     //30 ms
 319          #define TIME_OUT_TAGRDY   3     //30 ms
 320          #define TIME_OUT_READDATA 10     //80 ms
 321          
 322          void _gettagresponse(uchar responseaftercmd, char SID)
 323          {
 324   1              uchar Bytecnt,bitcnt, ASICRDY, TAGRDY, TAGDONE, bitval, temp;
 325   1              bit b_col = 0;
 326   1              b_collision = 0;
 327   1              ASICRDY = 0;    TAGRDY = 0; 
 328   1              while((DOUT)); _stopBit(); _nop_(); _nop_();
 329   1              while((DOUT));    
 330   1              _trans1();
 331   1              if (responseaftercmd)                         // wait for buffer to empty before cont.
 332   1              {  
 333   2                      TH0 = 0x63; TL0 = 0xc0;                      //12ms
 334   2                      _setTimer(TIME_OUT_ASICRDY);                 //wait for ERR-pulse
 335   2                      while ((!M_ERR)&&(!TIMERINT));
 336   2                      if (M_ERR)
 337   2                      {
 338   3                              while ((M_ERR)&&(!TIMERINT));
 339   3                              if (!M_ERR)
 340   3                              {                                       //err pulse (typ. 18us) detected
 341   4                                      ASICRDY = 1;
 342   4                                      TH0 = 0x63; TL0 = 0xc0;                      //12ms
 343   4                                      _setTimer(TIME_OUT_TAGRDY);                             
 344   4                              }
 345   3                      }
 346   2              }
 347   1              /*
 348   1              else
 349   1              {
 350   1                      ASICRDY=1;
 351   1                      TH0 = 0x63; TL0 = 0xc0;                      //12ms
 352   1                      _setTimer(TIME_OUT_TAGRDY);
 353   1              }
 354   1              */
 355   1              if(ASICRDY)
 356   1              {                                             // wait for tag to respond; wait for S2 signal.
 357   2                      while((!TAGRDY)&&(!TIMERINT))
 358   2                      {
 359   3                              if (_findS2())
 360   3                              {
 361   4                                      TAGRDY=1;                               
 362   4                                      TH0 = 0x63; TL0 = 0xc0;                      //12ms
 363   4                                      _setTimer(TIME_OUT_READDATA);                           
 364   4                              }
 365   3                      }
C51 COMPILER V8.08   R6C                                                                   01/18/2009 20:00:52 PAGE 7   

 366   2              }
 367   1              if(TAGRDY)
 368   1              {
 369   2                      TAGDONE=0;
 370   2                      bitcnt=0;
 371   2                      Bytecnt=3;              //It's value is nr of bytes -1 (i.e. the value in [o])
 372   2      
 373   2                      temp= 0;
 374   2                      while ((!TAGDONE)&&(!TIMERINT))
 375   2                      {
 376   3                              bitval =_readbit();
 377   3                              switch (bitval)
 378   3                              {
 379   4                                      case 0x02:
 380   4                                              b_col = 1; 
 381   4                                      break;
 382   4      
 383   4                                      case 0x03:
 384   4                                              TAGDONE =1;             //received ES2                          
 385   4                                              pcdata[Bytecnt] = temp;
 386   4                                              pcdata[0] = Bytecnt;
 387   4                                              pcdata[1] = bitcnt;                     
 388   4                                              if(chkCRC(pcdata+3,Bytecnt-3))
 389   4                                              {
 390   5                                      userCardOk = 1;
 391   5                              } 
 392   4                              break;
 393   4      
 394   4                              case 0x04: //timeout
 395   4                              break;
 396   4      
 397   4                              default:
 398   4                                      if (bitcnt==8) //start new byte
 399   4                                      {
 400   5                                              if(Bytecnt <100) 
 401   5                                              {
 402   6                                                      pcdata[Bytecnt] = temp;
 403   6                                                      temp=0;
 404   6                                                      bitcnt =0;
 405   6                                                      Bytecnt++; 
 406   6                                              }
 407   5                                      }
 408   4                                      bitcnt++;
 409   4                                      temp = temp*2 + bitval;
 410   4                                      break;
 411   4                              }
 412   3                      }
 413   2              }
 414   1              /*
 415   1              else if (SID) //no tag in slot, doesn't mean timeout
 416   1                      TIMERINT=0;//TIFR = TIFR|0x10; //reset TIMERINT
 417   1                      */
 418   1              
 419   1              b_collision = b_col;
 420   1              _trans2(); //uctrl becomes again master of clock
 421   1              _clrTimer();
 422   1      }
*** WARNING C280 IN LINE 322 OF R6C.C: 'SID': unreferenced local variable
 423          uchar rd_ConReg(void)
 424          {
 425   1              uchar j,bitval;
 426   1              bit flag;
C51 COMPILER V8.08   R6C                                                                   01/18/2009 20:00:52 PAGE 8   

 427   1              
 428   1              pcdata[2]=0;
 429   1              _startBit();
 430   1              pcdata[0] =4;
 431   1              pcdata[1] =0;
 432   1              pcdata[2] =0;
 433   1              pcdata[3]=0x71;                      /* send command */
 434   1              for(j=0;j<8;j++)
 435   1              {
 436   2                      pcdata[3]  = pcdata[3] << 1;
 437   2                      flag = CY;
 438   2                      _sendBit(flag);
 439   2              }
 440   1              for(j=0;j<8;j++)                      /*get regCfg*/
 441   1              {
 442   2                      bitval = _rwbit(0);
 443   2                      pcdata[2] = pcdata[2]*2 + bitval;
 444   2              }
 445   1              _stopBit();                           /*send ES1*/
 446   1              pcdata[0] = 0x03;
 447   1              pcdata[1] = 0x00;
 448   1              return(pcdata[2]);
 449   1      }
 450          
 451          
 452          void switchon(void)
 453          {
 454   1              _startBit();
 455   1              _sendBit(1);
 456   1              _stopBit();
 457   1      }
 458          
 459          uchar xx = 0x30;
 460          uchar _commandrd(void)
 461          {
 462   1              uchar i;
 463   1              pcdata[1] = 0;                       
 464   1              pcdata[2] = 0x00;
 465   1              pcdata[3] = 0x39;                     /* 通讯参数设置:调制100%、低数据率、FM调制、无曼彻斯特解调*/
 466   1      
 467   1      
 468   1              //if(++xx>0x3F) xx = 0x30;
 469   1              
 470   1              
 471   1              for(i= 4;i<pcdata[0];i++)
 472   1              {
 473   2                      pcdata[i] = ReflectBYTE(pcdata[i]);  /*数据倒序*/
 474   2              }       
 475   1              _sendfifocmd(); 
 476   1              _gettagresponse(1,0);
 477   1         if (TIMERINT)  { return(0); }               
 478   1         else           { return(1); }
 479   1      }
 480          
 481          void send_ISO_cmd(uchar flags,uchar cmd,uchar dataPstion,uchar paraLength)
 482          {
 483   1              uint crc_val;
 484   1              
 485   1              pcdata[4] = flags;
 486   1              pcdata[5] = cmd;
 487   1              
 488   1              crc_val = crc16Calculate(pcdata+4,2+paraLength);
C51 COMPILER V8.08   R6C                                                                   01/18/2009 20:00:52 PAGE 9   

 489   1              pcdata[6+paraLength] = LOBYTE(crc_val);
 490   1              pcdata[7+paraLength] = HIBYTE(crc_val);
 491   1              pcdata[0] = 8+paraLength;   
 492   1              _commandrd();
 493   1      }
*** WARNING C280 IN LINE 481 OF R6C.C: 'dataPstion': unreferenced local variable


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    946    ----
   CONSTANT SIZE    =     16    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      5      15
   IDATA SIZE       =    140    ----
   BIT SIZE         =      5       5
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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