NXP NFC Reader Library  v4.040.05.011646
MIFARE(R) Classic

These Functions implement the MIFARE(R) Classic commands. More...

Collaboration diagram for MIFARE(R) Classic:

Modules

 Component : Software
 

Functions

phStatus_t phalMfc_Authenticate (void *pDataParams, uint8_t bBlockNo, uint8_t bKeyType, uint16_t wKeyNumber, uint16_t wKeyVersion, uint8_t *pUid, uint8_t bUidLength)
 Perform MIFARE(R) Authenticate command with MIFARE Picc. More...
 
phStatus_t phalMfc_Read (void *pDataParams, uint8_t bBlockNo, uint8_t *pBlockData)
 Perform MIFARE(R) Read command with MIFARE Picc. More...
 
phStatus_t phalMfc_ReadValue (void *pDataParams, uint8_t bBlockNo, uint8_t *pValue, uint8_t *pAddrData)
 Perform MIFARE(R) Read Value command with MIFARE Picc. More...
 
phStatus_t phalMfc_Write (void *pDataParams, uint8_t bBlockNo, uint8_t *pBlockData)
 Perform MIFARE(R) Write command with MIFARE Picc. More...
 
phStatus_t phalMfc_WriteValue (void *pDataParams, uint8_t bBlockNo, uint8_t *pValue, uint8_t bAddrData)
 Perform MIFARE(R) Write Value command with MIFARE Picc. More...
 
phStatus_t phalMfc_Increment (void *pDataParams, uint8_t bBlockNo, uint8_t *pValue)
 Perform MIFARE(R) Increment command with MIFARE Picc. More...
 
phStatus_t phalMfc_Decrement (void *pDataParams, uint8_t bBlockNo, uint8_t *pValue)
 Perform MIFARE(R) Decrement command with MIFARE Picc. More...
 
phStatus_t phalMfc_Transfer (void *pDataParams, uint8_t bBlockNo)
 Perform MIFARE(R) Transfer command with MIFARE Picc. More...
 
phStatus_t phalMfc_Restore (void *pDataParams, uint8_t bBlockNo)
 Perform MIFARE(R) Restore command with MIFARE Picc. More...
 
phStatus_t phalMfc_IncrementTransfer (void *pDataParams, uint8_t bSrcBlockNo, uint8_t bDstBlockNo, uint8_t *pValue)
 Perform MIFARE(R) Increment Transfer command sequence with MIFARE Picc. More...
 
phStatus_t phalMfc_DecrementTransfer (void *pDataParams, uint8_t bSrcBlockNo, uint8_t bDstBlockNo, uint8_t *pValue)
 Perform MIFARE(R) Decrement Transfer command sequence with MIFARE Picc. More...
 
phStatus_t phalMfc_RestoreTransfer (void *pDataParams, uint8_t bSrcBlockNo, uint8_t bDstBlockNo)
 Perform MIFARE(R) Restore Transfer command sequence with MIFARE Picc. More...
 
phStatus_t phalMfc_PersonalizeUid (void *pDataParams, uint8_t bUidType)
 Perform MIFARE(R) Personalize UID usage command sequence with MIFARE Picc. More...
 
phStatus_t phalMfc_GetVersion (void *pDataParams, uint8_t *pVersion)
 Perform MIFARE(R) GET VERSION usage command sequence with MIFARE Picc. More...
 

Authentication Parameters

#define PHAL_MFC_KEYA   0x0AU
 MIFARE(R) Key A. More...
 
#define PHAL_MFC_KEYB   0x0BU
 MIFARE(R) Key B. More...
 

Block definitions

#define PHAL_MFC_DATA_BLOCK_LENGTH   16U
 Length of a MIFARE(R) Classic data block. More...
 
#define PHAL_MFC_VALUE_BLOCK_LENGTH   4U
 Length of a MIFARE(R) Classic value block. More...
 

UID Type definitions

#define PHAL_MFC_UID_TYPE_UIDF0   0x00U
 MIFARE(R) Classic UID type UIDF0. More...
 
#define PHAL_MFC_UID_TYPE_UIDF1   0x40U
 MIFARE(R) Classic UID type UIDF1. More...
 
#define PHAL_MFC_UID_TYPE_UIDF2   0x20U
 MIFARE(R) Classic UID type UIDF2. More...
 
#define PHAL_MFC_UID_TYPE_UIDF3   0x60U
 MIFARE(R) Classic UID type UIDF3. More...
 

Detailed Description

These Functions implement the MIFARE(R) Classic commands.

Macro Definition Documentation

§ PHAL_MFC_KEYA

#define PHAL_MFC_KEYA   0x0AU

MIFARE(R) Key A.

§ PHAL_MFC_KEYB

#define PHAL_MFC_KEYB   0x0BU

MIFARE(R) Key B.

§ PHAL_MFC_DATA_BLOCK_LENGTH

#define PHAL_MFC_DATA_BLOCK_LENGTH   16U

Length of a MIFARE(R) Classic data block.

§ PHAL_MFC_VALUE_BLOCK_LENGTH

#define PHAL_MFC_VALUE_BLOCK_LENGTH   4U

Length of a MIFARE(R) Classic value block.

§ PHAL_MFC_UID_TYPE_UIDF0

#define PHAL_MFC_UID_TYPE_UIDF0   0x00U

MIFARE(R) Classic UID type UIDF0.

§ PHAL_MFC_UID_TYPE_UIDF1

#define PHAL_MFC_UID_TYPE_UIDF1   0x40U

MIFARE(R) Classic UID type UIDF1.

§ PHAL_MFC_UID_TYPE_UIDF2

#define PHAL_MFC_UID_TYPE_UIDF2   0x20U

MIFARE(R) Classic UID type UIDF2.

§ PHAL_MFC_UID_TYPE_UIDF3

#define PHAL_MFC_UID_TYPE_UIDF3   0x60U

MIFARE(R) Classic UID type UIDF3.

Function Documentation

§ phalMfc_Authenticate()

phStatus_t phalMfc_Authenticate ( void *  pDataParams,
uint8_t  bBlockNo,
uint8_t  bKeyType,
uint16_t  wKeyNumber,
uint16_t  wKeyVersion,
uint8_t pUid,
uint8_t  bUidLength 
)

Perform MIFARE(R) Authenticate command with MIFARE Picc.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[in]bBlockNoBlocknumber on card to authenticate to.
[in]bKeyTypeEither PHAL_MFC_KEYA or PHAL_MFC_KEYB.
[in]wKeyNumberKey number to be used in authentication.
[in]wKeyVersionKey version to be used in authentication.
[in]pUidComplete serial number; uint8_t[4/7/10].
[in]bUidLengthLength of provided serial number (4/7/10).

§ phalMfc_Read()

phStatus_t phalMfc_Read ( void *  pDataParams,
uint8_t  bBlockNo,
uint8_t pBlockData 
)

Perform MIFARE(R) Read command with MIFARE Picc.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[in]bBlockNoblock number to be read.
[out]pBlockDatapBlockData[16] containing block read from the MIFARE(R) card

§ phalMfc_ReadValue()

phStatus_t phalMfc_ReadValue ( void *  pDataParams,
uint8_t  bBlockNo,
uint8_t pValue,
uint8_t pAddrData 
)

Perform MIFARE(R) Read Value command with MIFARE Picc.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful
Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[in]bBlockNoblock number to be read.
[out]pValuepValue[4] containing value (LSB first) read from the MIFARE(R) card
[out]pAddrDatapAddrData containing address read from the MIFARE(R) card value block

§ phalMfc_Write()

phStatus_t phalMfc_Write ( void *  pDataParams,
uint8_t  bBlockNo,
uint8_t pBlockData 
)

Perform MIFARE(R) Write command with MIFARE Picc.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[in]bBlockNoblock number to be written.
[in]pBlockDatapBlockData[16] containing block to be written to the MIFARE(R) card

§ phalMfc_WriteValue()

phStatus_t phalMfc_WriteValue ( void *  pDataParams,
uint8_t  bBlockNo,
uint8_t pValue,
uint8_t  bAddrData 
)

Perform MIFARE(R) Write Value command with MIFARE Picc.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[in]bBlockNoblock number to be written.
[in]pValuepValue[4] containing value (LSB first) to be written to the MIFARE(R) card
[in]bAddrDatabAddrData containing address written to the MIFARE(R) card value block

§ phalMfc_Increment()

phStatus_t phalMfc_Increment ( void *  pDataParams,
uint8_t  bBlockNo,
uint8_t pValue 
)

Perform MIFARE(R) Increment command with MIFARE Picc.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[in]bBlockNoblock number to be incremented.
[in]pValuepValue[4] containing value (LSB first) to be incremented on the MIFARE(R) card

§ phalMfc_Decrement()

phStatus_t phalMfc_Decrement ( void *  pDataParams,
uint8_t  bBlockNo,
uint8_t pValue 
)

Perform MIFARE(R) Decrement command with MIFARE Picc.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[in]bBlockNoblock number to be decremented.
[in]pValuepValue[4] containing value (LSB first) to be decremented on the MIFARE(R) card

§ phalMfc_Transfer()

phStatus_t phalMfc_Transfer ( void *  pDataParams,
uint8_t  bBlockNo 
)

Perform MIFARE(R) Transfer command with MIFARE Picc.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[in]bBlockNoblock number the transfer buffer shall be transferred to.

§ phalMfc_Restore()

phStatus_t phalMfc_Restore ( void *  pDataParams,
uint8_t  bBlockNo 
)

Perform MIFARE(R) Restore command with MIFARE Picc.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[in]bBlockNoblock number the transfer buffer shall be restored from.

§ phalMfc_IncrementTransfer()

phStatus_t phalMfc_IncrementTransfer ( void *  pDataParams,
uint8_t  bSrcBlockNo,
uint8_t  bDstBlockNo,
uint8_t pValue 
)

Perform MIFARE(R) Increment Transfer command sequence with MIFARE Picc.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[in]bSrcBlockNoblock number to be incremented.
[in]bDstBlockNoblock number to be transferred to.
[in]pValuepValue[4] containing value (LSB first) to be incremented on the MIFARE(R) card

§ phalMfc_DecrementTransfer()

phStatus_t phalMfc_DecrementTransfer ( void *  pDataParams,
uint8_t  bSrcBlockNo,
uint8_t  bDstBlockNo,
uint8_t pValue 
)

Perform MIFARE(R) Decrement Transfer command sequence with MIFARE Picc.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[in]bSrcBlockNoblock number to be decremented.
[in]bDstBlockNoblock number to be transferred to.
[in]pValuepValue[4] containing value (LSB first) to be decremented on the MIFARE(R) card

§ phalMfc_RestoreTransfer()

phStatus_t phalMfc_RestoreTransfer ( void *  pDataParams,
uint8_t  bSrcBlockNo,
uint8_t  bDstBlockNo 
)

Perform MIFARE(R) Restore Transfer command sequence with MIFARE Picc.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[in]bSrcBlockNoblock number to be decremented.
[in]bDstBlockNoblock number to be transferred to.

§ phalMfc_PersonalizeUid()

phStatus_t phalMfc_PersonalizeUid ( void *  pDataParams,
uint8_t  bUidType 
)

Perform MIFARE(R) Personalize UID usage command sequence with MIFARE Picc.

UID type can be one of

Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[in]bUidTypeUID type.

§ phalMfc_GetVersion()

phStatus_t phalMfc_GetVersion ( void *  pDataParams,
uint8_t pVersion 
)

Perform MIFARE(R) GET VERSION usage command sequence with MIFARE Picc.

GET_VERSION command is used to retrieve information about the NTAG family, the product version, storage size and other product data required to identify the specific NTAG-I2C

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_PROTOCOL_ERRORwrong Lenght byte received.
Parameters
[in]pDataParamsPointer to this layer's parameter structure.
[out]pVersionVersion no It should be PHAL_MFC_VERSION_LENGTH