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

📄 rc500_m500a.h

📁 门禁_c 存储过程 门禁_c 存储过程
💻 H
📖 第 1 页 / 共 2 页
字号:
///////////////////////////////////////////////////////////////////////////////
//    Copyright (c), Philips Semiconductors Gratkorn
//
//                     (C)PHILIPS Electronics N.V. 2000
//       All rights are reserved. Reproduction in whole or in part is 
//      prohibited without the written consent of the copyright owner.
//  Philips reserves the right to make changes without notice at any time.
// Philips makes no warranty, expressed, implied or statutory, including but
// not limited to any implied warranty of merchantibility or fitness for any
//particular purpose, or that the use will not infringe any third party patent,
// copyright or trademark. Philips must not be liable for any loss or damage
//                          arising from its use.
///////////////////////////////////////////////////////////////////////////////
//
// Projekt         : M500
// Files           : M500A.h M500A.c
// Created         : 01.04.00
//
// COMMENT: 
//	         This header file can be used either for a uC environment or for 
//           Win32 DLL. Therefore the header MfOsDefs.h is included. Depending 
//           on the environment different definitions are used for "FCT_PREF". 
//           For the microcontroller system, all functions have the return type
//          "char". For the Win32 DLL the return types are changed to "long". 
//           Further more the DLL functions need to be exported, so the 
//           corresponding declarations are made. 
// MODIFICATIONS:
// 01.04.00  HB  first issue
///////////////////////////////////////////////////////////////////////////////
#ifndef M500A_H
#define M500A_H

#ifdef __cplusplus
extern "C"
{
#endif

// General Include File for serveral defines concerning conditional library
// compilation and microcontroller usage
//#include <MfOsDefs.h>


// P I C C - C O M M A N D S
// commands which are handled by the tag
// Each tag command is written to the reader IC and transfered via RF
#define PICC_REQSTD        0x26			// request idle
#define PICC_REQALL        0x52			// request all
#define PICC_ANTICOLL1     0x93			// anticollision level 1
#define PICC_ANTICOLL2     0x95			// anticollision level 2
#define PICC_ANTICOLL3     0x97			// anticollision level 3
#define PICC_AUTHENT1A     0x60			// authentication step 1
#define PICC_AUTHENT1B     0x61			// authentication step 2
#define PICC_READ          0x30			// read block
#define PICC_WRITE         0xA0			// write block
#define PICC_DECREMENT     0xC0         	// decrement value
#define PICC_INCREMENT     0xC1         	// increment value
#define PICC_RESTORE       0xC2         	// restore command code
#define PICC_TRANSFER      0xB0         	// transfer command code
#define PICC_HALT          0x50			// halt

// Mifare Error Codes
// Each function returns a status value, which corresponds to the
// mifare error codes. 
#define MI_OK                           0
#define MI_CHK_OK                       0
#define MI_CRC_ZERO                     0

#define MI_CRC_NOTZERO                  1

#define MI_NOTAGERR                     (-1)
#define MI_CHK_FAILED                   (-1)
#define MI_CRCERR                       (-2)
#define MI_CHK_COMPERR                  (-2)
#define MI_EMPTY                        (-3)
#define MI_AUTHERR                      (-4)
#define MI_PARITYERR                    (-5)
#define MI_CODEERR                      (-6)

#define MI_SERNRERR                     (-8)
#define MI_KEYERR                       (-9)
#define MI_NOTAUTHERR                   (-10)
#define MI_BITCOUNTERR                  (-11)
#define MI_BYTECOUNTERR                 (-12)
#define MI_IDLE                         (-13)
#define MI_TRANSERR                     (-14)
#define MI_WRITEERR                     (-15)
#define MI_INCRERR                      (-16)
#define MI_DECRERR                      (-17)
#define MI_READERR                      (-18)
#define MI_OVFLERR                      (-19)
#define MI_POLLING                      (-20)
#define MI_FRAMINGERR                   (-21)
#define MI_ACCESSERR                    (-22)
#define MI_UNKNOWN_COMMAND              (-23)
#define MI_COLLERR                      (-24)
#define MI_RESETERR                     (-25)
#define MI_INITERR                      (-25)
#define MI_INTERFACEERR                 (-26)
#define MI_ACCESSTIMEOUT                (-27)
#define MI_NOBITWISEANTICOLL            (-28)
#define MI_QUIT                         (-30)

#define MI_RECBUF_OVERFLOW              (-50) 
#define MI_SENDBYTENR                   (-51)
	
#define MI_SENDBUF_OVERFLOW             (-53)
#define MI_BAUDRATE_NOT_SUPPORTED       (-54)
#define MI_SAME_BAUDRATE_REQUIRED       (-55)

#define MI_WRONG_PARAMETER_VALUE        (-60)

#define MI_BREAK                        (-99)
#define MI_NY_IMPLEMENTED               (-100)
#define MI_NO_MFRC                      (-101)
#define MI_MFRC_NOTAUTH                 (-102)
#define MI_WRONG_DES_MODE               (-103)
#define MI_HOST_AUTH_FAILED             (-104)

#define MI_WRONG_LOAD_MODE              (-106)
#define MI_WRONG_DESKEY                 (-107)
#define MI_MKLOAD_FAILED                (-108)
#define MI_FIFOERR                      (-109)
#define MI_WRONG_ADDR                   (-110)
#define MI_DESKEYLOAD_FAILED            (-111)

#define MI_WRONG_SEL_CNT                (-114)

#define MI_WRONG_TEST_MODE              (-117)
#define MI_TEST_FAILED                  (-118)
#define MI_TOC_ERROR                    (-119)
#define MI_COMM_ABORT                   (-120)
#define MI_INVALID_BASE                 (-121)
#define MI_MFRC_RESET                   (-122)
#define MI_WRONG_VALUE                  (-123)
#define MI_VALERR                       (-124)

// _____________________________________________________________________________
//
//  FUNCTION: M500PcdConfig
//        IN: -
//       OUT: -
//    RETURN: MI_OK
//            MI_RESETERR
//            MI_INTERFACEERR
//   COMMENT: Configuration of the reader IC. This function has to be called
//            before the first data is written to the reader. A reset 
//            is initiated and several registers are set.
//
char M500PcdConfig(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);






// _____________________________________________________________________________
//
//  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: 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); 

⌨️ 快捷键说明

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