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

📄 main.lst

📁 实现射频卡的读写
💻 LST
📖 第 1 页 / 共 5 页
字号:
 498      =1                        unsigned char *snr,
 499      =1                        unsigned char key_sector, 
 500      =1                        unsigned char block);   
 501      =1                 
 502      =1  // _____________________________________________________________________________
 503      =1  //
 504      =1  //  FUNCTION: M500PiccAuthE2
 505      =1  //        IN: auth_mode PICC_AUTHENT1A or PICC_AUTHENT1B 
 506      =1  //                            selects master key A or master key B 
 507      =1  //            *snr       4 byte serial number of the card, which should be 
 508      =1  //                       authenticated
 509      =1  //            key_sector spec. the key E2PROM key number from which the data 
 510      =1  //                       should be taken (0..15)
 511      =1  //            sector    addresses the sector number on the card, which shall be
 512      =1  //                      authenticated. For MIFARE standard cards, addr can take 
 513      =1  //                      a value from 0 to 15, for other card types please refer
 514      =1  //                      to the according product description.
 515      =1  //       OUT: -
 516      =1  //    RETURN: 
 517      =1  //   COMMENT: This function authenticates one card's sector using the specified 
 518      =1  //            mode. After sending the command to the card the 
 519      =1  //            function waits for the card's answer.
 520      =1  //            The keys for authentication have to be stored in E2PROM in 
 521      =1  //            advance.
 522      =1  char M500PiccAuthE2( unsigned char auth_mode, 
 523      =1                           unsigned char *snr,      
 524      =1                           unsigned char key_sector,
 525      =1                           unsigned char sector); 
 526      =1                       
 527      =1  // _____________________________________________________________________________
 528      =1  //
 529      =1  //  FUNCTION: M500HostCodeKey
 530      =1  //        IN: uncoded   6 bytes master key for card authentication
 531      =1  //       OUT: coded     12 bytes master key for card authentication
 532      =1  //    RETURN: 
 533      =1  //   COMMENT: In order to authenticate a memory sector of a card, a 6 
 534      =1  //            bytes master key is necessary. This master key has to be passed
 535      =1  //            to the reader modul coded. The conversion between uncoded and 
 536      =1  //         	  coded keys is made by this function.
 537      =1  //                     
 538      =1  char M500HostCodeKey(unsigned char *uncoded, 
 539      =1                           unsigned char *coded); 
 540      =1  
 541      =1  // _____________________________________________________________________________
C51 COMPILER V6.10  MAIN                                                                   01/19/2009 23:06:47 PAGE 17  

 542      =1  //
 543      =1  //  FUNCTION: M500PiccAuthKey
 544      =1  //        IN: auth_mode PICC_AUTHENT1A or PICC_AUTHENT1B 
 545      =1  //                            selects master key A or master key B 
 546      =1  //            *snr       4 byte serial number of the card, which should be 
 547      =1  //                       authenticated
 548      =1  //            *keys      12 bytes master key coded
 549      =1  //            sector    addresses the sector number on the card, which shall be
 550      =1  //                      authenticated. For MIFARE standard cards, addr can take 
 551      =1  //                      a value from 0 to 15, for other card types please refer
 552      =1  //                      to the according product description.
 553      =1  //       OUT: -
 554      =1  //    RETURN: 
 555      =1  //   COMMENT: The keys are first loaded to the reader module and used for
 556      =1  //            authentication of the secified sector. In order to get the 
 557      =1  //            required keys coded, the function M500HostCodeKey can be used.
 558      =1  //                     
 559      =1  char M500PiccAuthKey(unsigned char auth_mode,
 560      =1                           unsigned char *snr,   
 561      =1                           unsigned char *keys,  
 562      =1                           unsigned char sector);   
 563      =1                       
 564      =1                          
 565      =1  // _____________________________________________________________________________
 566      =1  //
 567      =1  //  FUNCTION: M500PiccRead
 568      =1  //        IN: addr    addresses -  the block on the card from which data shall 
 569      =1  //                    be read. For MIFARE standard cards, addr can take a value
 570      =1  //                    from 0 to 63 (255 for Mifare Pro), for other card types 
 571      =1  //                    please refer to the according product description.
 572      =1  //       OUT: data    is a pointer to the 16 byte data block read from the card.
 573      =1  //       OUT: 
 574      =1  //    RETURN: 
 575      =1  //   COMMENT: This function reads a 16 byte block from the specified card's block 
 576      =1  //            address addr. After sending the command to the card the function 
 577      =1  //            waits for the card's answer.
 578      =1  //                        
 579      =1  char M500PiccRead(unsigned char addr,  
 580      =1                    unsigned char *_data);
 581      =1                   
 582      =1  // _____________________________________________________________________________
 583      =1  //
 584      =1  //  FUNCTION: M500PiccWrite
 585      =1  //        IN: addr     address -  the block on the card from which data shall 
 586      =1  //                     be read. For MIFARE standard cards, addr can take a 
 587      =1  //                     value from 0 to 63 (255 for Mifare Pro), for other card 
 588      =1  //                     types please refer to the according product description.
 589      =1  //            data     is a pointer to the 16 byte data block that shall be 
 590      =1  //                     written to the card.
 591      =1  //       OUT: -
 592      =1  //    RETURN: 
 593      =1  //   COMMENT: This function writes a 16 byte block to the specified card's block 
 594      =1  //            address addr. After sending the command to the card the function
 595      =1  //            waits for the card's answer.
 596      =1  //                  
 597      =1  char M500PiccWrite(unsigned char addr,
 598      =1                         unsigned char *_data);
 599      =1                    
 600      =1  
 601      =1  // _____________________________________________________________________________
 602      =1  //
 603      =1  // FUNCTION: M500PiccValue
C51 COMPILER V6.10  MAIN                                                                   01/19/2009 23:06:47 PAGE 18  

 604      =1  //	 IN: dd_mode	INCREMENT, DECREMENT or RESTORE
 605      =1  //	     addr	Block address for the command to be perform 0-63
 606      =1  //	     *value	4 bytes value, LSB first
 607      =1  //	     trans_addr Destination block address to be tranfer	
 608      =1  //	OUT: -
 609      =1  //  COMMENT:
 610      =1  // This function performs the INCREMENT, DECREMENT and RESTORE command. Precondition 
 611      =1  // for success is, that the data block is formatted as value block. 
 612      =1  //
 613      =1  // For INCREMENT and DECREMENT, the command doesn't write back the value to the memory 
 614      =1  // location directly, but loads the transfer buffer with the increased value,
 615      =1  // which could be transferred to any authenticated block by the TRANFER command.
 616      =1  //
 617      =1  // The RESTORE command loads the transfer buffer with the value stored at datablock 
 618      =1  // address, while the 
 619      =1  // given value is only a dummy value, which only have to be in valid range. 
 620      =1  // With a subsquent TRANSFER command a backup management for Value Blocks is 
 621      =1  // established.
 622      =1  //
 623      =1  // After sending the command to the card the function waits for the 
 624      =1  // card's answer. In case of an error <em>Mf500PiccValue()</em>
 625      =1  // generates a return code according to the MF RC's error flags, otherwise 
 626      =1  // the value is sent to the card and then it waits for a NACK. As an exception 
 627      =1  // in this protocol step 
 628      =1  // only a NACK is sent by the card in case of an error. Thus, the function 
 629      =1  // is successful, if a time out occurs. 
 630      =1  //
 631      =1  // After the calculation is done,  a TRANSFER is automatically
 632      =1  // performed to the block address trans_addr. After sending the command to
 633      =1  // the card the function waits for the card's answer 
 634      =1  // and generates a return code according to the MF RC's error flags. 
 635      =1  // A TRAN command is only possible directly after a RESTORE, INCREMENT or 
 636      =1  // DECREMENT command.
 637      =1  //
 638      =1  // The value inside a Value Block is four bytes wide and stored two times
 639      =1  // in normal and one time in bit-inverted manner for data security issues. 
 640      =1  // Additionally the initial address of the Value Block is stored two times 
 641      =1  // normal and two times bit-inverted. In case of a backup of a Value Block, 
 642      =1  // this addres contains the original address of the Value Block.
 643      =1  // Note: Only positive numbers are alowed for the parameter <em>value</em>.
 644      =1  //
 645      =1  char M500PiccValue(unsigned char dd_mode, 
 646      =1                     unsigned char addr, 
 647      =1                     unsigned char *value,
 648      =1                     unsigned char trans_addr);
 649      =1  
 650      =1  // _____________________________________________________________________________
 651      =1  //
 652      =1  // FUNCTION: M500PiccValueDebit
 653      =1  //	 IN: dd_mode	INCREMENT, DECREMENT or RESTORE
 654      =1  //	     addr	Block address for the command to be perform 0-63
 655      =1  //	     *value	4 bytes value, LSB first
 656      =1  //	OUT: -
 657      =1  //  COMMENT:
 658      =1  // This function executes calculations on value debit blocks with cards, that 
 659      =1  // support automatic transfer (MIFARE light, MIFARE PLUS, MIFARE PRO,
 660      =1  // MIFARE PROX, ...). 
 661      =1  //
 662      =1  // After sending the command 
 663      =1  // to the card the function waits for the card's answer. In case of an error 
 664      =1  // it generates a return code according 
 665      =1  // to the MF RC's error flags. 
C51 COMPILER V6.10  MAIN                                                                   01/19/2009 23:06:47 PAGE 19  

 666      =1  //
 667      =1  char M500PiccValueDebit(unsigned char dd_mode, 
 668      =1                          unsigned char addr, 
 669      =1                          unsigned char *value);
 670      =1  
 671      =1  // _____________________________________________________________________________
 672      =1  //
 673      =1  // FUNCTION: M500PiccExchangeBlock
 674      =1  //	 IN: *send_data	
 675      =1  //	     send_bytelen       Lenght include 2bytes CRC
 676      =1  //	     append_crc		1->append, 0->not append
 677      =1  //	     timeout		Set duration of timeout timer
 678      =1  //				1-> 1s
 679      =1  //				2-> 1.5s
 680      =1  //				3-> 6s
 681      =1  //				4-> 9.6s
 682      =1  //	OUT: *rec_data
 683      =1  //	     *rec_bytelen
 684      =1  //  COMMENT:
 685      =1  // This function exchanges data blocks between the <b>PCD</b> and <b>PICC</b>. 
 686      =1  //
 687      =1  // ATTENTION: if <em>append_crc</em> is enabled, two CRC bytes are included in 
 688      =1  // <em>send_bytelen</em> and <em>rec_bytelen</em>. The received CRC bytes in the
 689      =1  // receive buffer are always set to zero. 
 690      =1  //
 691      =1  char M500PiccExchangeBlock(unsigned char *send_data,
 692      =1                             unsigned char send_bytelen,
 693      =1                             unsigned char *rec_data,  
 694      =1                             unsigned char *rec_bytelen,
 695      =1                             unsigned char append_crc, 
 696      =1                             unsigned char timeout);                  
 697      =1  
 698      =1  // _____________________________________________________________________________
 699      =1  //
 700      =1  //  FUNCTION: M500PiccHalt
 701      =1  //        IN: -
 702      =1  //       OUT: -
 703      =1  //    RETURN: -
 704      =1  //   COMMENT: This function sets the MIFARE card into the halt state. After 
 705      =1  //            sending the command to the card the function waits for a cards 
 706      =1  //            response. As an exception, in this protocol step no ACK is sent by
 707      =1  //            the card, but only a NACK in case of an error. Thus, the function 
 708      =1  //            is successful, if a time out occurs.
 709      =1  //                  
 710      =1  char M500PiccHalt(void);
 711      =1  
 712      =1  // _____________________________________________________________________________
 713      =1  //
 714      =1  //  FUNCTION: MfPcdRfReset
 715      =1  //        IN: msec     Duration of RF-field off in mseconds.
 716      =1  //                     If parameter msec is 0 => RF OFF forever
 717      =1  //       OUT: -
 718      =1  //    GLOBAL: -
 719      =1  //    RETURN: 
 720      =1  //   COMMENT: Turns off RF-field for a certain time in mseconds. The period
 721      =1  //            is specified in variable 'msec'. Subsequently RF-field is
 722      =1  //            turned on again (after about 1 msec). If value 0 is chosen, 
 723      =1  //            the RF-field is simply turned off. 
 724      =1  //
 725      =1  char M500PcdRfReset(unsigned char ms);                  
 726      =1  
 727      =1  void idle_request(void);
C51 COMPILER V6.10  MAIN                                                                   01/19/2009 23:06:47 PAGE 20  

 728      =1  
 729      =1  #ifdef __cplusplus
           =1 }
           =1 #endif
 732      =1  

⌨️ 快捷键说明

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