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

📄 m500a.h

📁 RC500的函数库
💻 H
📖 第 1 页 / 共 3 页
字号:
//            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
//            authentication of the secified sector. In order to get the 
//            required keys coded, the function M500HostCodeKey can be used.
//                     
char M500PiccAuthKey(unsigned char auth_mode,
                         unsigned char *snr,   
                         unsigned char *keys,  
                         unsigned char sector);   
                     
                        
// _____________________________________________________________________________
//
//  FUNCTION: M500PiccRead
//        IN: addr    addresses -  the block on the card from which data shall 
//                    be read. For MIFARE standard cards, addr can take a value
//                    from 0 to 63 (255 for Mifare Pro), for other card types 
//                    please refer to the according product description.
//       OUT: data    is a pointer to the 16 byte data block read from the card.
//       OUT: 
//    RETURN: 
//   COMMENT: This function reads a 16 byte block from the specified card's block 
//            address addr. After sending the command to the card the function 
//            waits for the card's answer.
//                        
char M500PiccRead(unsigned char addr,  
                  unsigned char *_data);
                 
// _____________________________________________________________________________
//
//  FUNCTION: M500PiccWrite
//        IN: addr     address -  the block on the card from which data shall 
//                     be read. For MIFARE standard cards, addr can take a 
//                     value from 0 to 63 (255 for Mifare Pro), for other card 
//                     types please refer to the according product description.
//            data     is a pointer to the 16 byte data block that shall be 
//                     written to the card.
//       OUT: -
//    RETURN: 
//   COMMENT: This function writes a 16 byte block to the specified card's block 
//            address addr. After sending the command to the card the function
//            waits for the card's answer.
//                  
char M500PiccWrite(unsigned char addr,
                       unsigned char *_data);
                  

// _____________________________________________________________________________
//
// FUNCTION: M500PiccValue
//	 IN: dd_mode	INCREMENT, DECREMENT or RESTORE
//	     addr	Block address for the command to be perform 0-63
//	     *value	4 bytes value, LSB first
//	     trans_addr Destination block address to be tranfer	
//	OUT: -
//  COMMENT:
// This function performs the INCREMENT, DECREMENT and RESTORE command. Precondition 
// for success is, that the data block is formatted as value block. 
//
// For INCREMENT and DECREMENT, the command doesn't write back the value to the memory 
// location directly, but loads the transfer buffer with the increased value,
// which could be transferred to any authenticated block by the TRANFER command.
//
// The RESTORE command loads the transfer buffer with the value stored at datablock 
// address, while the 
// given value is only a dummy value, which only have to be in valid range. 
// With a subsquent TRANSFER command a backup management for Value Blocks is 
// established.
//
// After sending the command to the card the function waits for the 
// card's answer. In case of an error <em>Mf500PiccValue()</em>
// generates a return code according to the MF RC's error flags, otherwise 
// the value is sent to the card and then it waits for a NACK. As an exception 
// in this protocol step 
// only a NACK is sent by the card in case of an error. Thus, the function 
// is successful, if a time out occurs. 
//
// After the calculation is done,  a TRANSFER is automatically
// performed to the block address trans_addr. After sending the command to
// the card the function waits for the card's answer 
// and generates a return code according to the MF RC's error flags. 
// A TRAN command is only possible directly after a RESTORE, INCREMENT or 
// DECREMENT command.
//
// The value inside a Value Block is four bytes wide and stored two times
// in normal and one time in bit-inverted manner for data security issues. 
// Additionally the initial address of the Value Block is stored two times 
// normal and two times bit-inverted. In case of a backup of a Value Block, 
// this addres contains the original address of the Value Block.
// Note: Only positive numbers are alowed for the parameter <em>value</em>.
//
char M500PiccValue(unsigned char dd_mode, 
                   unsigned char addr, 
                   unsigned char *value,
                   unsigned char trans_addr);

// _____________________________________________________________________________
//
// FUNCTION: M500PiccValueDebit
//	 IN: dd_mode	INCREMENT, DECREMENT or RESTORE
//	     addr	Block address for the command to be perform 0-63
//	     *value	4 bytes value, LSB first
//	OUT: -
//  COMMENT:
// This function executes calculations on value debit blocks with cards, that 
// support automatic transfer (MIFARE light, MIFARE PLUS, MIFARE PRO,
// MIFARE PROX, ...). 
//
// After sending the command 
// to the card the function waits for the card's answer. In case of an error 
// it generates a return code according 
// to the MF RC's error flags. 
//
char M500PiccValueDebit(unsigned char dd_mode, 
                        unsigned char addr, 
                        unsigned char *value);

// _____________________________________________________________________________
//
// FUNCTION: M500PiccExchangeBlock
//	 IN: *send_data	
//	     send_bytelen       Lenght include 2bytes CRC
//	     append_crc		1->append, 0->not append
//	     timeout		Set duration of timeout timer
//				1-> 1s
//				2-> 1.5s
//				3-> 6s
//				4-> 9.6s
//	OUT: *rec_data
//	     *rec_bytelen
//  COMMENT:
// This function exchanges data blocks between the <b>PCD</b> and <b>PICC</b>. 
//
// ATTENTION: if <em>append_crc</em> is enabled, two CRC bytes are included in 
// <em>send_bytelen</em> and <em>rec_bytelen</em>. The received CRC bytes in the
// receive buffer are always set to zero. 
//
char M500PiccExchangeBlock(unsigned char *send_data,
                           unsigned char send_bytelen,
                           unsigned char *rec_data,  
                           unsigned char *rec_bytelen,
                           unsigned char append_crc, 
                           unsigned char timeout);                  

// _____________________________________________________________________________
//
//  FUNCTION: M500PiccHalt
//        IN: -
//       OUT: -
//    RETURN: -
//   COMMENT: This function sets the MIFARE card into the halt state. After 
//            sending the command to the card the function waits for a cards 
//            response. As an exception, in this protocol step no ACK is sent by
//            the card, but only a NACK in case of an error. Thus, the function 
//            is successful, if a time out occurs.
//                  
char M500PiccHalt(void);

// _____________________________________________________________________________
//
//  FUNCTION: MfPcdRfReset
//        IN: msec     Duration of RF-field off in mseconds.
//                     If parameter msec is 0 => RF OFF forever
//       OUT: -
//    GLOBAL: -
//    RETURN: 
//   COMMENT: Turns off RF-field for a certain time in mseconds. The period
//            is specified in variable 'msec'. Subsequently RF-field is
//            turned on again (after about 1 msec). If value 0 is chosen, 
//            the RF-field is simply turned off. 
//
char M500PcdRfReset(unsigned char ms);                  

void idle_request(void);

#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

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