NXP Reader Library  v17.1.0.2535

SAM commands used for MIFARE Classic card communication in X-Mode. More...

Collaboration diagram for MIFARE Classic in X-Mode:

Macros

#define PHHAL_HW_SAMAV2_CMD_MF_CHANGE_KEY_DATA_LENGTH   0x0D
 Data length of MF_ChangeKey command (with Diversification)
 
#define PHHAL_HW_SAMAV2_CMD_MF_CHANGE_KEY_DATA_NO_DIV_LENGTH   0x08
 Data length of MF_ChangeKey command (without Diversification)
 
#define PHHAL_HW_SAMAV2_CMD_MF_AUTH_READ_DATAHEADER_LENGTH   0x07
 Data header length of MF_AuthenticateRead command (without UID)
 
#define PHHAL_HW_SAMAV2_CMD_MF_AUTH_WRITE_DATAHEADER_LENGTH   0x08
 Data header length of MF_AuthenticateWrite command (without UID)
 

Functions

phStatus_t phhalHw_SamAV2_Cmd_MfAuthenticate (phhalHw_SamAV2_DataParams_t *pDataParams, uint8_t bOption, uint8_t *pUid, uint8_t bKeyNoM, uint8_t bKeyVM, uint8_t bKeyType, uint8_t bAuthBlockNo, uint8_t bDivBlockNo)
 Perform a MIFARE Authenticate command. More...
 
phStatus_t phhalHw_SamAV2_Cmd_MfRead (phhalHw_SamAV2_DataParams_t *pDataParams, uint8_t bOption, uint8_t *pBlocks, uint8_t bBlocksLength, uint8_t **ppData, uint16_t *pDataLength)
 Perform a MIFARE Read command. More...
 
phStatus_t phhalHw_SamAV2_Cmd_MfWrite (phhalHw_SamAV2_DataParams_t *pDataParams, uint16_t wOption, uint8_t *pData, uint8_t bDataLength)
 Perform a MIFARE Write command. More...
 
phStatus_t phhalHw_SamAV2_Cmd_MfValueWrite (phhalHw_SamAV2_DataParams_t *pDataParams, uint8_t *pBlocks, uint8_t bBlocksLength)
 Perform a MIFARE Write Value command. More...
 
phStatus_t phhalHw_SamAV2_Cmd_MfIncrement (phhalHw_SamAV2_DataParams_t *pDataParams, uint8_t *pBlocks, uint8_t bBlocksLength)
 Perform a MIFARE Increment command. More...
 
phStatus_t phhalHw_SamAV2_Cmd_MfDecrement (phhalHw_SamAV2_DataParams_t *pDataParams, uint8_t *pBlocks, uint8_t bBlocksLength)
 Perform a MIFARE Decrement command. More...
 
phStatus_t phhalHw_SamAV2_Cmd_MfRestore (phhalHw_SamAV2_DataParams_t *pDataParams, uint8_t *pBlocks, uint8_t bBlocksLength)
 Perform a MIFARE Restore command. More...
 
phStatus_t phhalHw_SamAV2_Cmd_MfAuthenticateRead (phhalHw_SamAV2_DataParams_t *pDataParams, uint16_t wOption, uint8_t *pUid, uint8_t bCmdSettings, uint8_t bKeyNoM, uint8_t bKeyVM, uint8_t bKeyType, uint8_t bAuthBlockNo, uint8_t bDivBlockNo, uint8_t *pBlocks, uint8_t bBlocksLength, uint8_t **ppData, uint16_t *pDataLength)
 Perform a MIFARE Authenticate followed by a MIFARE Read command. More...
 
phStatus_t phhalHw_SamAV2_Cmd_MfAuthenticateWrite (phhalHw_SamAV2_DataParams_t *pDataParams, uint16_t wOption, uint8_t *pUid, uint8_t bCmdSettings, uint8_t bKeyNoM, uint8_t bKeyVM, uint8_t bKeyType, uint8_t bAuthBlockNo, uint8_t bDivBlockNo, uint8_t *pBlocks, uint8_t bBlocksLength)
 Perform a MIFARE Authenticate followed by a MIFARE Write command. More...
 
phStatus_t phhalHw_SamAV2_Cmd_MfChangeKey (phhalHw_SamAV2_DataParams_t *pDataParams, uint8_t bKeyCompMeth, uint8_t bKeyNoM, uint8_t bKeyVMA, uint8_t bKeyVMB, uint8_t bBlockNo, uint8_t *pAccessConditions, uint8_t *pUid, uint8_t bDivBlockNo)
 Perform a change of a key in a MIFARE Card. More...
 

Sam AV2 command code for MIFARE Classic X mode feature.

#define PHHAL_HW_SAMAV2_CMD_MF_AUTHENTICATE_EXCHANGE_INS   0x0C /** < Mifare Classic Authenticate command */
 
#define PHHAL_HW_SAMAV2_CMD_MF_READ_INS   0x30
 CMD Byte for MF_Read command.
 
#define PHHAL_HW_SAMAV2_CMD_MF_WRITE_INS   0xA0
 CMD Byte for MF_Write command.
 
#define PHHAL_HW_SAMAV2_CMD_MF_WRITE_VALUE_INS   0xA2
 CMD Byte for MF_WriteValue command.
 
#define PHHAL_HW_SAMAV2_CMD_MF_INCREMENT_INS   0xC3
 CMD Byte for MF_Increment command.
 
#define PHHAL_HW_SAMAV2_CMD_MF_DECREMENT_INS   0xC0
 CMD Byte for MF_Decrement command.
 
#define PHHAL_HW_SAMAV2_CMD_MF_RESTORE_INS   0xC2
 CMD Byte for MF_Restore command.
 
#define PHHAL_HW_SAMAV2_CMD_MF_AUTH_READ_INS   0x3A
 CMD Byte for MF_AuthenticateRead command.
 
#define PHHAL_HW_SAMAV2_CMD_MF_AUTH_WRITE_INS   0xAA
 CMD Byte for MF_AuthenticateWrite command.
 
#define PHHAL_HW_SAMAV2_CMD_MF_CHANGE_KEY_INS   0xA1
 CMD Byte for MF_ChangeKey command.
 

Option macros for Sam AV2 MIFARE Classic X Mode Authenticate command.

#define PHHAL_HW_SAMAV2_CMD_CHANGE_MFAUTHENTICATE_DEFAULT   0x00
 Default option mask for MFAuthenticate - no diversification.
 
#define PHHAL_HW_SAMAV2_CMD_CHANGE_MFAUTHENTICATE_DIVERSIFICATION   0x01
 Option mask for key diversification.
 
#define PHHAL_HW_SAMAV2_CMD_CHANGE_MFAUTHENTICATE_NODIVERSIFICATION   0x00
 Option mask for no key diversification.
 

Option macros for Sam AV2 MIFARE Classic X Mode Read command.

#define PHHAL_HW_SAMAV2_CMD_CHANGE_MFREAD_DEFAULT   0x00
 Default option mask for MFRead - single block read.
 
#define PHHAL_HW_SAMAV2_CMD_CHANGE_MFREAD_MULTIBLOCK   0x01
 Option mask for multiblock MFRead.
 
#define PHHAL_HW_SAMAV2_CMD_CHANGE_MFREAD_SINGLEBLOCK   0x00
 Option mask for singleblock MFRead.
 

Option macros for Sam AV2 MIFARE Classic X Mode Write command.

#define PHHAL_HW_SAMAV2_CMD_CHANGE_MFWRITE_TYPE_DEFAULT   0x00
 Default option mask for MFWrite - MIFARE Classic single block write.
 
#define PHHAL_HW_SAMAV2_CMD_CHANGE_MFWRITE_TYPE_MFULTRALIGTH   0x01
 Option mask for multiblock MIFARE Plus write.
 
#define PHHAL_HW_SAMAV2_CMD_CHANGE_MFWRITE_TYPE_MULTIBLOCK   0x02
 Option mask for singleblock MIFARE Ultraligth write.
 

Detailed Description

SAM commands used for MIFARE Classic card communication in X-Mode.

Function Documentation

◆ phhalHw_SamAV2_Cmd_MfAuthenticate()

phStatus_t phhalHw_SamAV2_Cmd_MfAuthenticate ( phhalHw_SamAV2_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t pUid,
uint8_t  bKeyNoM,
uint8_t  bKeyVM,
uint8_t  bKeyType,
uint8_t  bAuthBlockNo,
uint8_t  bDivBlockNo 
)

Perform a MIFARE Authenticate command.

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]bOption[In] Option mask for this command.
[in]pUid[In] MIFARE standard UID. This buffer has to be 4 bytes long.
[in]bKeyNoM[In] Key reference number of MIFARE key.
[in]bKeyVM[In] Key version of MIFARE key.
[in]bKeyType[In] Type of key : MF key A (0x0A) or MF key B (0xB).
[in]bAuthBlockNo[In] Block number to be authenticated within MIFARE PICC.
[in]bDivBlockNo[In] Block number to be used for diversification. Only used in case of diversification.

◆ phhalHw_SamAV2_Cmd_MfRead()

phStatus_t phhalHw_SamAV2_Cmd_MfRead ( phhalHw_SamAV2_DataParams_t pDataParams,
uint8_t  bOption,
uint8_t pBlocks,
uint8_t  bBlocksLength,
uint8_t **  ppData,
uint16_t pDataLength 
)

Perform a MIFARE Read command.

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]bOption[In] Option mask for this command.
[in]pBlocks[In] Pointer to the block numbers to be read.
  • In case of single block read -> BNR_1 | BNR_2 | BNR_3 ...
  • In case of multi block read -> BNR_1 | NumBlocks_1 | BNR_2 | NumBlocks_2 | BNR_3 | NumBlocks_3 ...
[in]bBlocksLength[In] Length of the pBlocks buffer.
[out]ppData[Out] Pointer to buffer containing the data read from the PICC.
[out]pDataLength[Out] Amount of valid bytes in the ppData buffer.

◆ phhalHw_SamAV2_Cmd_MfWrite()

phStatus_t phhalHw_SamAV2_Cmd_MfWrite ( phhalHw_SamAV2_DataParams_t pDataParams,
uint16_t  wOption,
uint8_t pData,
uint8_t  bDataLength 
)

Perform a MIFARE Write command.

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]wOption[In] Option mask for this command.
[in]pData[In] Pointer to the MF_Write data field.
  • In case of single block write -> BNR_1 | DATA_1 | BNR_2 | DATA_2 ...
  • In case of multi block write -> BNR_1 | NumBlocks_1 | DATA_1 | BNR_2 | NumBlocks_2 | DATA_2 ...
[in]bDataLength[In] Amount of valid bytes in the pData buffer.

◆ phhalHw_SamAV2_Cmd_MfValueWrite()

phStatus_t phhalHw_SamAV2_Cmd_MfValueWrite ( phhalHw_SamAV2_DataParams_t pDataParams,
uint8_t pBlocks,
uint8_t  bBlocksLength 
)

Perform a MIFARE Write Value command.

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]pBlocks[In] Pointer to the block numbers and data to be written. BNR || value[4] || address[4] ...
[in]bBlocksLength[In] Length of the pBlocks buffer.

◆ phhalHw_SamAV2_Cmd_MfIncrement()

phStatus_t phhalHw_SamAV2_Cmd_MfIncrement ( phhalHw_SamAV2_DataParams_t pDataParams,
uint8_t pBlocks,
uint8_t  bBlocksLength 
)

Perform a MIFARE Increment command.

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]pBlocks[In] Pointer to the block numbers and data to be written. src_BNR || dest_BNR || value[4] || ...
[in]bBlocksLength[In] Length of the pBlocks buffer.

◆ phhalHw_SamAV2_Cmd_MfDecrement()

phStatus_t phhalHw_SamAV2_Cmd_MfDecrement ( phhalHw_SamAV2_DataParams_t pDataParams,
uint8_t pBlocks,
uint8_t  bBlocksLength 
)

Perform a MIFARE Decrement command.

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]pBlocks[In] Pointer to the block numbers and data to be written. src_BNR || dest_BNR || value[4] || ...
[in]bBlocksLength[In] Length of the pBlocks buffer.

◆ phhalHw_SamAV2_Cmd_MfRestore()

phStatus_t phhalHw_SamAV2_Cmd_MfRestore ( phhalHw_SamAV2_DataParams_t pDataParams,
uint8_t pBlocks,
uint8_t  bBlocksLength 
)

Perform a MIFARE Restore command.

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]pBlocks[In] Pointer to the block numbers of source and destination. src_BNR || dest_BNR || ...
[in]bBlocksLength[In] Length of the pBlocks buffer.

◆ phhalHw_SamAV2_Cmd_MfAuthenticateRead()

phStatus_t phhalHw_SamAV2_Cmd_MfAuthenticateRead ( phhalHw_SamAV2_DataParams_t pDataParams,
uint16_t  wOption,
uint8_t pUid,
uint8_t  bCmdSettings,
uint8_t  bKeyNoM,
uint8_t  bKeyVM,
uint8_t  bKeyType,
uint8_t  bAuthBlockNo,
uint8_t  bDivBlockNo,
uint8_t pBlocks,
uint8_t  bBlocksLength,
uint8_t **  ppData,
uint16_t pDataLength 
)

Perform a MIFARE Authenticate followed by a MIFARE Read command.

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]wOption[In] Option mask for this command.
  • On every call a single data cycle is buffered. A cycle is one sequence of CmdSettings | KeyNoM | KeyVM | KeyType | AuthBlockNo | ... | NumBlocks | Blocks.
  • If wOption is set to PH_EXCHANGE_BUFFER_LAST the buffered cycles are send to the PICC.
[in]pUid[In] MIFARE standard UID. This buffer has to be 4 bytes long. This buffer is only used if wOption is set to PH_EXCHANGE_BUFFER_FIRST.
[in]bCmdSettings[In] Command settings of the data cycle.
[in]bKeyNoM[In] Key reference number of MIFARE key.
[in]bKeyVM[In] Key version of MIFARE key.
[in]bKeyType[In] Type of key : MF key A (0x0A) or MF key B (0xB).
[in]bAuthBlockNo[In] Block number to be authenticated within MIFARE PICC.
[in]bDivBlockNo[In] Block number to be used for diversification.
[in]pBlocks[In] Pointer to the block numbers to be read.
[in]bBlocksLength[In] Length of the pBlocks buffer.
[out]ppData[Out] Pointer to buffer containing the data read from the PICC.
[out]pDataLength[Out] Amount of valid bytes in the ppData buffer.

◆ phhalHw_SamAV2_Cmd_MfAuthenticateWrite()

phStatus_t phhalHw_SamAV2_Cmd_MfAuthenticateWrite ( phhalHw_SamAV2_DataParams_t pDataParams,
uint16_t  wOption,
uint8_t pUid,
uint8_t  bCmdSettings,
uint8_t  bKeyNoM,
uint8_t  bKeyVM,
uint8_t  bKeyType,
uint8_t  bAuthBlockNo,
uint8_t  bDivBlockNo,
uint8_t pBlocks,
uint8_t  bBlocksLength 
)

Perform a MIFARE Authenticate followed by a MIFARE Write command.

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]wOption[In] Option mask for this command.
  • On every call a single data cycle is buffered. A cycle is one sequence of CmdSettings | KeyNoM | KeyVM | KeyType | AuthBlockNo | ... | NumBlocks | Blocks.
  • If wOption is set to PH_EXCHANGE_BUFFER_LAST the buffered cycles are send to the PICC.
[in]pUid[In] MIFARE standard UID. This buffer has to be 4 bytes long. This buffer is only used if wOption is set to PH_EXCHANGE_BUFFER_FIRST.
[in]bCmdSettings[In] Command settings of the data cycle.
[in]bKeyNoM[In] Key reference number of MIFARE key.
[in]bKeyVM[In] Key version of MIFARE key.
[in]bKeyType[In] Type of key : MF key A (0x0A) or MF key B (0xB).
[in]bAuthBlockNo[In] Block number to be authenticated within MIFARE PICC.
[in]bDivBlockNo[In] Block number to be used for diversification.
[in]pBlocks[In] Buffer containing the block number and the data to be written. The sequence is BNR_1 | Data_1 | BNR_2 | Data_2 ...
[in]bBlocksLength[In] Length of the pBlocks buffer.

◆ phhalHw_SamAV2_Cmd_MfChangeKey()

phStatus_t phhalHw_SamAV2_Cmd_MfChangeKey ( phhalHw_SamAV2_DataParams_t pDataParams,
uint8_t  bKeyCompMeth,
uint8_t  bKeyNoM,
uint8_t  bKeyVMA,
uint8_t  bKeyVMB,
uint8_t  bBlockNo,
uint8_t pAccessConditions,
uint8_t pUid,
uint8_t  bDivBlockNo 
)

Perform a change of a key in a MIFARE Card.

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]bKeyCompMeth[In] Bit mask determining the key compilation method.
[in]bKeyNoM[In] Key reference number of MIFARE key.
[in]bKeyVMA[In] Key version of MIFARE key A.
[in]bKeyVMB[In] Key version of MIFARE key B.
[in]bBlockNo[In] MIFARE block number (block to store the new key).
[in]pAccessConditions[In] Access Conditions to be stored. This buffer has to be 4 bytes long.
[in]pUid[In] UID of the card. Only needed if diversification is indicated by bKeyCompMeth. This buffer has to be 4 bytes long.
[in]bDivBlockNo[In] Block number used for diversification. Only needed if diversification is indicated by bKeyCompMeth.