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

📄 main.lst

📁 keilc写RFID独T5557卡的源程序,
💻 LST
📖 第 1 页 / 共 3 页
字号:
 542   2              }
 543   1      
 544   1      
 545   1              check_stat=ERR_EM4469_NEITHER_ACK;
 546   1      
 547   1              for (j=0;j<10;j++)
 548   1              {
 549   2                      if(((halfDataRate*2+8)<capture_time[j])&&(capture_time[j]<(halfDataRate*3+8))
C51 COMPILER V7.50   MAIN                                                                  09/17/2007 14:50:28 PAGE 10  

 550   2                      &&(capture_time[j+1]<MaxCaptureHalfDateRate)&&(capture_time[j+2]>MaxCaptureHalfDateRate)
 551   2                      &&(capture_time[j+2]<(halfDataRate*3+8)))
 552   2                              break;
 553   2              }
 554   1              if(j==5)
 555   1              {
 556   2                      check_stat = 0xf1;
 557   2                      return;         
 558   2              }
 559   1              
 560   1              check_stat = UART_MESSAGE_OK;
 561   1              for(i=0;i<120;i++)
 562   1              {
 563   2                      capture_time[i]=0xff;
 564   2              }
 565   1      }
 566          
 567          
 568          
 569          void ClearCaptureBuffers(void) 
 570          {
 571   1              uchar i;
 572   1              for(i=0; i<CAPTURE_SIZE; i++) 
 573   1              {
 574   2              capture_data[i] = 0;
 575   2              }
 576   1      }
 577          
 578          void capture(void)
 579          {
 580   1              uint capt;
 581   1              uint icr = count_module();   
 582   1                
 583   1              capt = icr - last_capture;
 584   1              last_capture = icr;                             
 585   1              *capture_read_time_data_ptr++=capt;             //保存高低电平的时间(以125K的脉冲个数),ptr++
 586   1      }
 587          
 588          
 589          //保存解码数据
 590          void store_bit(bit b)
 591          {               
 592   1                      if(b==1) 
 593   1                              captured_byte = captured_byte|(0x80>>captured_bit_count);
 594   1                      if (captured_bit_count==7)
 595   1                      {
 596   2                              capture_data[capture_cnt++] = captured_byte;
 597   2                              captured_byte=0;
 598   2                              captured_bit_count = 0;
 599   2                      }
 600   1                      else captured_bit_count++;
 601   1      }
 602          
 603          uint count_module(void)
 604          {
 605   1              do
 606   1              {
 607   2                      count_timer2.bytes.high2 = TH2;
 608   2                      count_timer2.bytes.low2 = TL2;
 609   2              }while(count_timer2.bytes.high2 != TH2);
 610   1              return count_timer2.word;
 611   1      }
C51 COMPILER V7.50   MAIN                                                                  09/17/2007 14:50:28 PAGE 11  

 612          
 613          
 614          
 615          //从串口发送数据出去
 616          void trace(uchar *str,uchar len)
 617          {
 618   1              uint i;
 619   1              MYTI = 0;
 620   1              for(i=0;i<len;i++)
 621   1              {
 622   2                      myputchar(*str);
 623   2                      str++;
 624   2              }
 625   1      }
 626          
 627          //trace调用
 628          void myputchar(uchar c)
 629          {       
 630   1              //ES = 0;
 631   1              SBUF = c;
 632   1              while (MYTI == 0);
 633   1              MYTI = 0;
 634   1              //ES = 1;
 635   1      }
 636          
 637          
 638          
 639          
 640          void ResetT5557(void)
 641          {
 642   1              uchar fwd_bit_count;
 643   1              fwd_bit_count = Prepare_Cmd(0x00);
 644   1              SendForward(fwd_bit_count);             
 645   1      }
 646          void WakeUpT5557(void)
 647          {
 648   1              uchar fwd_bit_count;
 649   1              fwd_bit_count = Prepare_Cmd(0x01);
 650   1              fwd_bit_count += Prepare_Data(rx_buff);         
 651   1              SendForward(fwd_bit_count);
 652   1      }
 653          void GeneralRead_T5557()//发送时序 Opcode
 654          {
 655   1              uchar fwd_bit_count;
 656   1              fwd_bit_count = Prepare_Cmd(rx_buff[1]);
 657   1              SendForward(fwd_bit_count);
 658   1              maxCaptureTimeLow = maxTRead; 
 659   1          maxCaptureTimeHi = 0;
 660   1              ManchesterRead();
 661   1              if (check_stat==UART_MESSAGE_OK)
 662   1              {
 663   2                      tx_buff[0]=capture_data[0];     //数据
 664   2                      tx_buff[1]=capture_data[1];     //数据
 665   2                      tx_buff[2]=capture_data[2];     //数据
 666   2                      tx_buff[3]=capture_data[3];     //数据
 667   2      
 668   2                      tx_buff[4]=capture_data[4];     //数据
 669   2                      tx_buff[5]=capture_data[5];     //数据
 670   2                      tx_buff[6]=capture_data[6];     //数据
 671   2                      tx_buff[7]=capture_data[7];     //数据
 672   2      ;
 673   2                      trace(tx_buff,8);               //发送到PC 11个字节
C51 COMPILER V7.50   MAIN                                                                  09/17/2007 14:50:28 PAGE 12  

 674   2              }
 675   1              else
 676   1              {
 677   2                      tx_buff[0]= check_stat; //数据
 678   2                      tx_buff[1]=0xee;        //数据
 679   2                      tx_buff[2]=0xee;        //数据
 680   2                      tx_buff[3]=0xee;        //数据
 681   2                      trace(tx_buff,4);               //发送到PC 11个字节
 682   2              }       
 683   1      }
 684          
 685          void ReadT5557(void)//发送时序 Opcode + Lock + Addr
 686          {
 687   1              uchar fwd_bit_count;
 688   1              fwd_bit_count = Prepare_Cmd(rx_buff[1]);
 689   1              fwd_bit_count += Prepare_Lock();
 690   1              fwd_bit_count += Prepare_Addr(rx_buff[2]);
 691   1              SendForward(fwd_bit_count);
 692   1              maxCaptureTimeLow = maxTRead; 
 693   1          maxCaptureTimeHi = 0;
 694   1              ManchesterRead();
 695   1              if (check_stat==UART_MESSAGE_OK)
 696   1              {
 697   2                      tx_buff[0]=capture_data[0];     //数据
 698   2                      tx_buff[1]=capture_data[1];     //数据
 699   2                      tx_buff[2]=capture_data[2];     //数据
 700   2                      tx_buff[3]=capture_data[3];     //数据
 701   2                      trace(tx_buff,4);               //发送到PC 11个字节
 702   2              }
 703   1              else
 704   1              {
 705   2                      tx_buff[0]= check_stat; //数据
 706   2                      tx_buff[1]=0xee;        //数据
 707   2                      tx_buff[2]=0xee;        //数据
 708   2                      tx_buff[3]=0xee;        //数据
 709   2                      trace(tx_buff,4);               //发送到PC 11个字节
 710   2              }               
 711   1      }
 712          
 713          void WriteT5557(void)//发送时序 Opcode + Lock + Data + Addr
 714          {
 715   1              uchar fwd_bit_count;
 716   1              fwd_bit_count = Prepare_Cmd(0x01);
 717   1              fwd_bit_count += Prepare_Lock();
 718   1              fwd_bit_count += Prepare_Data(rx_buff); 
 719   1              fwd_bit_count += Prepare_Addr(rx_buff[5]);
 720   1              SendForward(fwd_bit_count);
 721   1              maxCaptureTimeLow = maxTWrite;
 722   1              maxCaptureTimeHi = 0;   
 723   1              ManchesterWrite();
 724   1              if (check_stat==UART_MESSAGE_OK)
 725   1              {
 726   2                      tx_buff[0]=0xe0;        //数据
 727   2                      tx_buff[1]=0x00;        //数据
 728   2                      tx_buff[2]=0x00;        //数据
 729   2                      tx_buff[3]=0x00;        //数据
 730   2                      trace(tx_buff,4);               //发送到PC 11个字节
 731   2              }
 732   1              else
 733   1              {
 734   2                      tx_buff[0]= check_stat; //数据
 735   2                      tx_buff[1]=0xee;        //数据
C51 COMPILER V7.50   MAIN                                                                  09/17/2007 14:50:28 PAGE 13  

 736   2                      tx_buff[2]=0xee;        //数据
 737   2                      tx_buff[3]=0xee;        //数据
 738   2                      trace(tx_buff,4);               //发送到PC 11个字节
 739   2              }
 740   1      }
 741          
 742          void ReadT5557_PWD(void) //发送时序 Opcode + PassWord + Lock + Addr
 743          {
 744   1              uchar fwd_bit_count;
 745   1              fwd_bit_count = Prepare_Cmd(0x01);
 746   1              fwd_bit_count += Prepare_Data(rx_buff);
 747   1              fwd_bit_count += Prepare_Lock();
 748   1              fwd_bit_count += Prepare_Addr(rx_buff[5]);
 749   1              SendForward(fwd_bit_count);
 750   1              maxCaptureTimeLow = maxTRead; 
 751   1          maxCaptureTimeHi = 0;
 752   1              ManchesterRead();
 753   1              if (check_stat==UART_MESSAGE_OK)
 754   1              {
 755   2                      tx_buff[0]=capture_data[0];     //数据
 756   2                      tx_buff[1]=capture_data[1];     //数据
 757   2                      tx_buff[2]=capture_data[2];     //数据
 758   2                      tx_buff[3]=capture_data[3];     //数据
 759   2                      trace(tx_buff,4);               //发送到PC 11个字节
 760   2              }
 761   1              else
 762   1              {
 763   2                      tx_buff[0]= check_stat; //数据
 764   2                      tx_buff[1]=0xee;        //数据
 765   2                      tx_buff[2]=0xee;        //数据
 766   2                      tx_buff[3]=0xee;        //数据
 767   2                      trace(tx_buff,4);               //发送到PC 11个字节
 768   2              }               
 769   1      }
 770          
 771          void WriteT5557_PWD(void)       //发送时序 Opcode + PassWord + Lock + Data + Addr
 772          {
 773   1              uchar fwd_bit_count;
 774   1              fwd_bit_count = Prepare_Cmd(0x01);
 775   1              fwd_bit_count += Prepare_Data(rx_buff);         
 776   1              fwd_bit_count += Prepare_Lock();        
 777   1              fwd_bit_count += Prepare_Data(rx_buff+4);       
 778   1              fwd_bit_count += Prepare_Addr(rx_buff[9]);
 779   1              SendForward(fwd_bit_count);
 780   1              maxCaptureTimeLow = maxTWrite;
 781   1              maxCaptureTimeHi = 0;   
 782   1              ManchesterWrite();
 783   1              if (check_stat==UART_MESSAGE_OK)
 784   1              {
 785   2                      tx_buff[0]=0xe0;        //数据
 786   2                      tx_buff[1]=0x00;        //数据
 787   2                      tx_buff[2]=0x00;        //数据
 788   2                      tx_buff[3]=0x00;        //数据
 789   2                      trace(tx_buff,4);               //发送到PC 11个字节
 790   2              }
 791   1              else
 792   1              {
 793   2                      tx_buff[0]= check_stat; //数据
 794   2                      tx_buff[1]=0xee;        //数据
 795   2                      tx_buff[2]=0xee;        //数据
 796   2                      tx_buff[3]=0xee;        //数据
 797   2                      trace(tx_buff,4);               //发送到PC 11个字节
C51 COMPILER V7.50   MAIN                                                                  09/17/2007 14:50:28 PAGE 14  

 798   2              }
 799   1      }
 800          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2940    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =    566      14
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      7       1
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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