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

📄 m500a.h

📁 Philps MF500完整设计资料大全
💻 H
📖 第 1 页 / 共 3 页
字号:
///////////////////////////////////////////////////////////////////////////////
//    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: M500PcdReset
//        IN: -
//       OUT: -
//    RETURN: MI_OK
//            MI_RESETERR
//            MI_INTERFACEERR
//   COMMENT: This function initiates a reset of the reader IC. Note, that
//            the reset pin of the reader has to be connected to the 
//            expected port pin of the microcontroller.
//
char M500PcdReset(void);

// _____________________________________________________________________________
//
//  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: M500PcdInOutSlaveConfig
//        IN: -
//       OUT: -
//    RETURN: MI_OK
//            MI_UNKNOWN_COMMAND
//            MI_ACCESSTIMEOUT
//   COMMENT: The reader IC is able to communicate with another reader IC
//            via the digital "mifare in" and "mifare out" interface. Therefore
//            one reader acts as a master and sends commands via "mifare out".
//            The other reader ic acts as a slave and receives data via
//            "mifare in" interface. The slave module can not be initialised
//            by the microcontroller because only the "mifare in/out"
//            interface is connected.For this reason, the slave module has 
//            to be initialised once. For that the appropriate parameter 
//            settings are written to 
//            the E2PROM. After POR (power on reset) the IC reads these settings
//            and initialises automatically as slave.
//
char M500PcdInOutSlaveConfig(void);

// _____________________________________________________________________________
//
//  FUNCTION: M500PcdInOutMasterConfig
//        IN: -
//       OUT: -
//    RETURN: MI_OK
//   COMMENT: Corresponding to the slave configuration routine. This function
//            initialises the master reader IC. The function is additional
//            to the standard configuration "M500PcdConfig".
//
char M500PcdInOutMasterConfig(void);

// _____________________________________________________________________________
//
//  FUNCTION: MfPcdLoadMk
//        IN: kl_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.
//            key_addr    spec. the key RAM address to which the data shall be 
//                        written (0..15)
//            mk          pointer to a 6 byte authentication key
//       OUT: -
//    RETURN: MI_OK
//   COMMENT: In order to be "calling compatibel" to former libraries, this 
//            function enables to store all keys in the microcontroller.
//            When calling the authentication function "M500PiccAuth", 
//            these keys can be used.
//            Note: This concept supports backward compatibility for the 
//            application software, but does not fulfill the same security 
//            level because keys are in this case stored autside the secure key 
//            memory of the MF RC500.
//
char M500PcdLoadMk(unsigned char  kl_mode, 
                   unsigned char  key_addr, 
                   unsigned char  *mk);
 
// _____________________________________________________________________________
//
//  FUNCTION: M500PcdLoadKeyE2
//        IN: key_type      PICC_AUTHENT1A or PICC_AUTHENT1B 
//            sector        key sector number, on which the key should be stored
//                          values from 0 to 15 are valid
//            uncoded_keys  6 bytes key 
//       OUT: -
//    RETURN: 
//   COMMENT: This function stores the keys in the reader internal E2PROM.
//            These keys are available for the function M500PiccAuthE2.
//                     
char M500PcdLoadKeyE2(unsigned char key_type,
                      unsigned char sector,
                      unsigned char *uncoded_keys); 

// _____________________________________________________________________________
//
//  FUNCTION: PcdReadE2
//        IN: startaddr     2 bytes of starting address of the E2PROM 
//            length        number of byte of data to be read
//       OUT: *_data        buffer for the read bytes 
//    RETURN: 

⌨️ 快捷键说明

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