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

📄 m500a.h

📁 一个rc531代码
💻 H
📖 第 1 页 / 共 3 页
字号:
//
//  FUNCTION: M500PcdReadRegister
//        IN: Reg      	Register address 
//       OUT: -
//    RETURN: value	value of register
//   COMMENT: This function read the value of the RC500 register
//                     
char M500PcdReadRegister(unsigned char Reg);

// _____________________________________________________________________________
//
//  FUNCTION: M500PiccRequest
//        IN: rq_code  can take the following values
//                     ALL   Request Code 52hex is sent out to get also a 
//                           response from cards in halt state.
//                     IDLE  Request Code 26hex is sent out to get a response 
//                           only from cards that are not in halt state.
//                     Note: Future cards will work also with other request 
//                           codes.
//       OUT: atq      16 bit ATQ (answer to request). 
//                     atq[0] .. LSByte
//                     atq[1] .. MSByte
//    RETURN: 
//   COMMENT: This function accesses the reader module and activates sending the
//            REQ code to the MIFARE card. After sending the command to the card 
//            the function waits for the card's answer.
//
//            Please note, that the actual work is done by the function
//            M500PiccCommonRequest, because of the interface behaviour between
//            Mifare and ISO 14443
//
//            The Card replies the ATQ.
//
//            ATQ:
//
//                    +----+----+----+----+----+----+----+----+
//            LSByte  | b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 |
//                    +----+----+----+----+----+----+----+----+
//                    |         |    |                        |
//                    | UID size| RFU|   bit-frame anticoll   |
//                    |         |    |                        |
//                    | 00..std |    |  (if any bit set .. Y, |
//                    | 01..dbl |    |             else .. N) |
//                    | 10..tpl |    |                        |
//
//
//
//                    +----+----+----+----+----+----+----+----+
//            MSByte  | b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 |
//                    +----+----+----+----+----+----+----+----+
//                    |                                       |
//                    |                 RFU                   |
//                    |                                       |
//
char M500PiccRequest(unsigned char req_code, 
                       unsigned char *atq);

// _____________________________________________________________________________
//
//  FUNCTION: M500PiccCommonRequest
//        IN: rq_code  can take the following values
//                     ALL   Request Code 52hex is sent out to get also a 
//                           response from cards in halt state.
//                     IDLE  Request Code 26hex is sent out to get a response 
//                           only from cards that are not in halt state.
//                     Note: Future cards will work also with other request 
//                           codes.
//       OUT: atq      16 bit ATQ (answer to request). 
//                     atq[0] .. LSByte
//                     atq[1] .. MSByte
//    RETURN: 
//   COMMENT: Please note, that this function does the actual work which is 
//            described in function M500PiccRequest.
//
char M500PiccCommonRequest(unsigned char req_code, 
                             unsigned char *atq);  

// _____________________________________________________________________________
//
//  FUNCTION: M500PiccActivateIdle
//        IN: br  
//       OUT: atq      16 bit ATQ (answer to request). 
//                     atq[0] .. LSByte
//                     atq[1] .. MSByte
//            *sak     1 byte select acknowledge
//		       xxxxx1xx: Cascade bit set: UID not complete
//		       xx1xx0xx: UID complete,
//		         	 PICC compliant with ISO/IEC 14443-4
//		       xx0xx0xx: UID complete,
//				 PICC not compliant with ISO/IEC 14443-4
//            *uid     4 bytes serial number, determined by the anticollision
//                     sequence
//	      *uid_len lenght of the uid received	
//    RETURN: 
//   COMMENT: This function performs a Request-Idle, Anticollision, Select 
//	      sequence to activate the PICC and change its state from IDLE 
//	      to ACTIVE state. Cascaded serialnumbers are handled correctly.
//
char M500PiccActivateIdle(unsigned char br,
                           unsigned char *atq, 
                           unsigned char *sak, 
                           unsigned char *uid, 
                           unsigned char *uid_len);

char M500PiccActivateAll(unsigned char br,
                           unsigned char *atq, 
                           unsigned char *sak, 
                           unsigned char *uid, 
                           unsigned char *uid_len);

// _____________________________________________________________________________
//
//  FUNCTION: M500PiccAnticoll
//        IN: bcnt       Number of snr-bits that are known (default value is 0)
//            *snr       4 bytes serial number (number of bits, which
//                       are known and indicated by "bcnt"
//       OUT: *snr       4 bytes serial number, determined by the anticollision
//                       sequence
//    RETURN: 
//   COMMENT: The actual anticollision loop is done by the function
//            "M500PiccCascAnticoll". Which is called with select_code 0x93.
//
char M500PiccAnticoll (unsigned char bcnt,
                         unsigned char *snr);

// _____________________________________________________________________________
//
//  FUNCTION: M500PiccCascAnticoll
//        IN: select_code    0x93  standard select code
//                           0x95  cascaded level 1
//                           0x97  cascaded level 2
//            bcnt       Number of snr-bits that are known (default value is 0)
//            *snr       4 bytes serial number (number of bits, which
//                       are known and indicated by "bcnt"
//       OUT: *snr       4 bytes serial number, determined by the anticollision
//                       sequence
//    RETURN: 
//   COMMENT: Corresponding to the specification in ISO 14443, this function
//            is able to handle extended serial numbers. Therefore more than
//            one select_code is possible. The function transmitts a 
//            select code and all ready tags are responding. The highest
//            serial number within all responding tags will be returned by 
//            this function.
//                     
char M500PiccCascAnticoll (unsigned char select_code,
                             unsigned char bcnt,
                             unsigned char *snr);                     

// _____________________________________________________________________________
//
//  FUNCTION: M500PiccSelect
//        IN: *snr      4 bytes serial number
//       OUT: *sak      1 byte select acknowledge
//			xxxxx1xx: Cascade bit set: UID not complete
//			xx1xx0xx: UID complete,
//				  PICC compliant with ISO/IEC 14443-4
//			xx0xx0xx: UID complete,
//				  PICC not compliant with ISO/IEC 14443-4
//    RETURN: 
//   COMMENT: The actual select procedure is done by the function
//            "M500PiccCascSelect". Which is called with select_code 0x93.
//             
char M500PiccSelect(unsigned char *snr, 
                      unsigned char *sak);

// _____________________________________________________________________________
//
//  FUNCTION: M500PiccCascSelect
//        IN: select_code 
//            *snr          4 bytes serial number
//       OUT: *sak          1 byte select acknowledge
//    RETURN: 
//   COMMENT: Selects a UID level, depending on select code.
//            Returns Select Acknowledge byte.
//
//            Corresponding to the specification in ISO 14443, this function
//            is able to handle extended serial numbers. Therefore more than
//            one select_code is possible.
//
//            Select codes:
//
//            +----+----+----+----+----+----+----+----+
//            | b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 |
//            +-|--+-|--+-|--+-|--+----+----+----+-|--+
//              |    |    |    |  |              | |
//                                |              |
//              1    0    0    1  | 001..std     | 1..bit frame anticoll
//                                | 010..double  |
//                                | 011..triple  |
//
//            SAK:
//
//            +----+----+----+----+----+----+----+----+
//            | b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 |
//            +-|--+-|--+-|--+-|--+-|--+-|--+-|--+-|--+
//              |    |    |    |    |    |    |    |
//                        |              |
//                RFU     |      RFU     |      RFU
//
//                        1              0 .. UID complete, ATS available
//                        0              0 .. UID complete, ATS not available
//                        X              1 .. UID not complete
//
char M500PiccCascSelect(unsigned char select_code, 
                            unsigned char *snr, 
                            unsigned char *sak); 

// _____________________________________________________________________________
//
//  FUNCTION: MfPiccAuth
//        IN: auth_mode PICC_AUTHENT1A or PICC_AUTHENT1B 
//                            selects master key A or master key B 
//                      KS0, KS1, KS2 selects one of the three master key sets.
//            *snr       4 byte serial number of the card, which should be 
//                       authenticated
//            key_sector spec. the key RAM address from which the data should be
//                      taken (0..15)
//            block     addresses the block address on the card, which shall be
//                      authenticated. For MIFARE standard cards, addr can take 
//                      a value from 0 to 63, for other card types please refer
//                      to the according product description.
//       OUT: -
//    RETURN: 
//   COMMENT: This function authenticates one card's sector (according to the 
//            block address addr) using the specified mode and master key, 
//            addressed with key_addr. After sending the command to the card the 
//            function waits for the card's answer.
//            This function is calling compatible (exept the serial number) with
//            older authentication functions. The keys are stored by the 
//            microcontroller, which is capable for the key management.
//
char M500PiccAuth(unsigned char auth_mode, 
                      unsigned char *snr,
                      unsigned char key_sector, 
                      unsigned char block);   
               
// _____________________________________________________________________________
//
//  FUNCTION: M500PiccAuthE2
//        IN: auth_mode PICC_AUTHENT1A or PICC_AUTHENT1B 
//                            selects master key A or master key B 
//            *snr       4 byte serial number of the card, which should be 
//                       authenticated
//            key_sector spec. the key E2PROM key number from which the data 
//                       should be taken (0..15)
//            sector    addresses the sector number on the card, which shall be
//                      authenticated. For MIFARE standard cards, addr can take 
//                      a value from 0 to 15, for other card types please refer
//                      to the according product description.
//       OUT: -
//    RETURN: 
//   COMMENT: This function authenticates one card's sector using the specified 
//            mode. After sending the command to the card the 
//            function waits for the card's answer.
//            The keys for authentication have to be stored in E2PROM in 
//            advance.
char M500PiccAuthE2( unsigned char auth_mode, 
                         unsigned char *snr,      
                         unsigned char key_sector,
                         unsigned char sector); 
                     
// _____________________________________________________________________________
//
//  FUNCTION: M500HostCodeKey
//        IN: uncoded   6 bytes master key for card authentication
//       OUT: coded     12 bytes master key for card authentication
//    RETURN: 
//   COMMENT: In order to authenticate a memory sector of a card, a 6 
//            bytes master key is necessary. This master key has to be passed
//            to the reader modul coded. The conversion between uncoded and 
//         	  coded keys is made by this function.
//                     
char M500HostCodeKey(unsigned char *uncoded, 
                         unsigned char *coded); 

// _____________________________________________________________________________
//
//  FUNCTION: M500PiccAuthKey
//        IN: auth_mode PICC_AUTHENT1A or PICC_AUTHENT1B 
//                            selects master key A or master key B 
//            *snr       4 byte serial number of the card, which should be 
//                       authenticated
//            *keys      12 bytes master key coded
//            sector    addresses the sector number on the card, which shall be
//                      authenticated. For MIFARE standard cards, addr can take 
//                      a value from 0 to 15, for other card types please refer
//                      to the according product description.
//       OUT: -
//    RETURN: 
//   COMMENT: The keys are first loaded to the reader module and used for

⌨️ 快捷键说明

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