NXP Reader Library  v17.1.0.2535
MIFARE(R) Classic

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

Collaboration diagram for MIFARE(R) Classic:

Modules

 Component : Software
 
 Component : Sam_X
 

Macros

#define PHAL_MFC_VERSION_LENGTH   0x08
 Length of a Version MIFARE(R) Classic data block.
 

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...
 

Key section to be used for Authentication form Sectop Trailer.

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

Block definitions.

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

UID Type definitions.

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

Status Codes of MIFARE(R) Classic PICC.

#define PHAL_MFC_RESP_ACK   0x0A
 MIFARE Classic ACK response code.
 
#define PHAL_MFC_RESP_NAK0   0x00
 MIFARE Classic NAK0 response code.
 
#define PHAL_MFC_RESP_NAK1   0x01
 MIFARE Classic NAK1 response code.
 
#define PHAL_MFC_RESP_NAK4   0x04
 MIFARE Classic NAK4 response code.
 
#define PHAL_MFC_RESP_NAK5   0x05
 MIFARE Classic NAK5 response code.
 

Command Codes of MIFARE(R) Classic PICC.

#define PHAL_MFC_CMD_RESTORE   0xC2
 MIFARE Classic Restore command byte.
 
#define PHAL_MFC_CMD_INCREMENT   0xC1
 MIFARE Classic Increment command byte.
 
#define PHAL_MFC_CMD_DECREMENT   0xC0
 MIFARE Classic Decrement command byte.
 
#define PHAL_MFC_CMD_TRANSFER   0xB0
 MIFARE Classic Transfer command byte.
 
#define PHAL_MFC_CMD_READ   0x30
 MIFARE Classic Read command byte.
 
#define PHAL_MFC_CMD_WRITE   0xA0
 MIFARE Classic Write command byte.
 
#define PHAL_MFC_CMD_AUTHA   0x60
 MIFARE Classic Authenticate A command byte.
 
#define PHAL_MFC_CMD_AUTHB   0x61
 MIFARE Classic Authenticate B command byte.
 
#define PHAL_MFC_CMD_PERSOUID   0x40
 MIFARE Classic Personalize UID command.
 
#define PHAL_MFC_CMD_GETVERSION   0x62
 MIFARE Classic GET VERSION command.
 

Detailed Description

These Functions implement the MIFARE(R) Classic commands.

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.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bBlockNo[In] Blocknumber on card to authenticate to.
[in]bKeyType[In] The type of key to be used for Authentication.
[in]wKeyNumber[In] Key number to be used in authentication.
[in]wKeyVersion[In] Key version to be used in authentication.
[in]pUid[In] Complete serial number; uint8_t[4/7/10].
[in]bUidLength[In] Length 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.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bBlockNo[In] Block number to be read.
[out]pBlockData[Out] pBlockData[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
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bBlockNo[In] Block number to be read.
[out]pValue[Out] pValue[4] containing value (LSB first) read from the MIFARE(R) card
[out]pAddrData[Out] pAddrData 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.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bBlockNo[In] Block number to be written.
[in]pBlockData[In] pBlockData[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.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bBlockNo[In] Block number to be written.
[in]pValue[In] pValue[4] containing value (LSB first) to be written to the MIFARE(R) card
[in]bAddrData[In] bAddrData 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.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bBlockNo[In] Block number to be incremented.
[in]pValue[In] pValue[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.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bBlockNo[In] Block number to be decremented.
[in]pValue[In] pValue[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.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bBlockNo[In] Block 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.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bBlockNo[In] Block 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.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bSrcBlockNo[In] Block number to be incremented.
[in]bDstBlockNo[In] Block number to be transferred to.
[in]pValue[In] pValue[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.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bSrcBlockNo[In] Block number to be decremented.
[in]bDstBlockNo[In] Block number to be transferred to.
[in]pValue[In] pValue[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.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bSrcBlockNo[In] block number to be decremented.
[in]bDstBlockNo[In] block 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.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]bUidType[In] UID type. One of the below Types.

◆ 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 return Status code

Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlaying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[out]pVersion[Out] Version returned by PICC.