NXP NFC Reader Library v4.040.05.011646

Modules | Functions
MIFARE(R)
Protocol Abstraction Layer

These Components implement the MIFARE(R) Classic, MIFARE(R) Ultralight, MIFARE(R) DESFire and MIFARE(R) Plus products. More...

Collaboration diagram for MIFARE(R):

## Modules
| Component : Software
| PhpalMifare_Stub

## Functions
phStatus_t | phpalMifare_ExchangeL3 (void *pDataParams, uint16_t wOption, uint8_t *pTxBuffer, uint16_t wTxLength, uint8_t **ppRxBuffer, uint16_t *pRxLength)
| Perform ISO14443-3 Data Exchange with MIFARE Picc. More...
phStatus_t | phpalMifare_ExchangeL4 (void *pDataParams, uint16_t wOption, uint8_t *pTxBuffer, uint16_t wTxLength, uint8_t **ppRxBuffer, uint16_t *pRxLength)
| Perform ISO14443-4 Data Exchange with MIFARE Picc. More...
phStatus_t | phpalMifare_ExchangePc (void *pDataParams, uint16_t wOption, uint8_t *pTxBuffer, uint16_t wTxLength, uint8_t **ppRxBuffer, uint16_t *pRxLength)
| Perform Proximity-Check Data Exchange with MIFARE Picc. More...
phStatus_t | phpalMifare_ExchangeRaw (void *pDataParams, uint16_t wOption, uint8_t *pTxBuffer, uint16_t wTxLength, uint8_t bTxLastBits, uint8_t **ppRxBuffer, uint16_t *pRxLength, uint8_t *pRxLastBits)
| Perform Raw (No CRC, No Parity) Data Exchange with MIFARE Picc. More...
phStatus_t | phpalMifare_MfcAuthenticateKeyNo (void *pDataParams, uint8_t bBlockNo, uint8_t bKeyType, uint16_t wKeyNo, uint16_t wKeyVersion, uint8_t *pUid)
| Perform MIFARE(R) Authenticate command with Picc using a key number. More...
phStatus_t | phpalMifare_MfcAuthenticate (void *pDataParams, uint8_t bBlockNo, uint8_t bKeyType, uint8_t *pKey, uint8_t *pUid)
| Perform MIFARE(R) Authenticate command with Picc using a key. More...
phStatus_t | phpalMifare_SetMinFdtPc (void *pDataParams, uint16_t wValue)
| Perform Setting min FDT for Proximity check. More...

## Authenticate Options
#define | PHPAL_MIFARE_KEYA 0x0AU
| MIFARE Classic Key Type A. More...
#define | PHPAL_MIFARE_KEYB 0x0BU
| MIFARE Classic Key Type B. More...
#define | PHPAL_MIFARE_KEY_LENGTH 0x06U
| Length of a MIFARE Classic key (for completeness). More...

## Detailed Description

These Components implement the MIFARE(R) Classic, MIFARE(R) Ultralight, MIFARE(R) DESFire and MIFARE(R) Plus products.

## Macro Definition Documentation

## § PHPAL_MIFARE_KEYA

#define PHPAL_MIFARE_KEYA 0x0AU

MIFARE Classic Key Type A.

## § PHPAL_MIFARE_KEYB

#define PHPAL_MIFARE_KEYB 0x0BU

MIFARE Classic Key Type B.

## § PHPAL_MIFARE_KEY_LENGTH

#define PHPAL_MIFARE_KEY_LENGTH 0x06U

Length of a MIFARE Classic key (for completeness).

## Function Documentation

## § phpalMifare_ExchangeL3()

phStatus_t phpalMifare_ExchangeL3 | ( | void * | pDataParams,
|  | uint16_t | wOption,
|  | uint8_t * | pTxBuffer,
|  | uint16_t | wTxLength,
|  | uint8_t ** | ppRxBuffer,
|  | uint16_t * | pRxLength
| ) |  |

Perform ISO14443-3 Data Exchange with MIFARE Picc.

`wOption` can be one of:

- PH_EXCHANGE_DEFAULT
- PH_EXCHANGE_BUFFER_FIRST
- PH_EXCHANGE_BUFFER_CONT
- PH_EXCHANGE_BUFFER_LAST

Alternatively, the following bits can be combined:

- PH_EXCHANGE_BUFFERED_BIT
- PH_EXCHANGE_LEAVE_BUFFER_BIT

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  Other | Depending on implementation and underlying component.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | wOption | Option parameter.
  [in] | pTxBuffer | Data to transmit.
  [in] | wTxLength | Length of data to transmit.
  [out] | ppRxBuffer | Pointer to received data.
  [out] | pRxLength | number of received data bytes.

## § phpalMifare_ExchangeL4()

phStatus_t phpalMifare_ExchangeL4 | ( | void * | pDataParams,
|  | uint16_t | wOption,
|  | uint8_t * | pTxBuffer,
|  | uint16_t | wTxLength,
|  | uint8_t ** | ppRxBuffer,
|  | uint16_t * | pRxLength
| ) |  |

Perform ISO14443-4 Data Exchange with MIFARE Picc.

`wOption` can be one of:

- PH_EXCHANGE_DEFAULT
- PH_EXCHANGE_TXCHAINING
- PH_EXCHANGE_RXCHAINING
- PH_EXCHANGE_RXCHAINING_BUFSIZE

Additionally, the following options are also available:

- PH_EXCHANGE_BUFFER_FIRST
- PH_EXCHANGE_BUFFER_CONT
- PH_EXCHANGE_BUFFER_LAST

Alternatively to the FIRST/CONT/LAST options, the following bits can be combined:

- PH_EXCHANGE_BUFFERED_BIT
- PH_EXCHANGE_LEAVE_BUFFER_BIT

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  Other | Depending on implementation and underlying component.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | wOption | Option parameter.
  [in] | pTxBuffer | Data to transmit.
  [in] | wTxLength | Length of data to transmit.
  [out] | ppRxBuffer | Pointer to received data.
  [out] | pRxLength | number of received data bytes.

## § phpalMifare_ExchangePc()

phStatus_t phpalMifare_ExchangePc | ( | void * | pDataParams,
|  | uint16_t | wOption,
|  | uint8_t * | pTxBuffer,
|  | uint16_t | wTxLength,
|  | uint8_t ** | ppRxBuffer,
|  | uint16_t * | pRxLength
| ) |  |

Perform Proximity-Check Data Exchange with MIFARE Picc.

Note: The `wOption` parameter is currently RFU.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  Other | Depending on implementation and underlying component.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | wOption | Option parameter.
  [in] | pTxBuffer | Data to transmit.
  [in] | wTxLength | Length of data to transmit.
  [out] | ppRxBuffer | Pointer to received data.
  [out] | pRxLength | number of received data bytes.

## § phpalMifare_ExchangeRaw()

phStatus_t phpalMifare_ExchangeRaw | ( | void * | pDataParams,
|  | uint16_t | wOption,
|  | uint8_t * | pTxBuffer,
|  | uint16_t | wTxLength,
|  | uint8_t | bTxLastBits,
|  | uint8_t ** | ppRxBuffer,
|  | uint16_t * | pRxLength,
|  | uint8_t * | pRxLastBits
| ) |  |

Perform Raw (No CRC, No Parity) Data Exchange with MIFARE Picc.

`wOption` can be one of:

- PH_EXCHANGE_DEFAULT
- PH_EXCHANGE_BUFFER_FIRST
- PH_EXCHANGE_BUFFER_CONT
- PH_EXCHANGE_BUFFER_LAST

Alternatively, the following bits can be combined:

- PH_EXCHANGE_BUFFERED_BIT
- PH_EXCHANGE_LEAVE_BUFFER_BIT

In Sam non X configuration, wOption can be combined with the following options to instruct Sam to not do enciphering and/or deciphering.

- #PHHAL_HW_SAMAV2_EXCHANGE_NO_ENCIPHERING_BIT
- #PHHAL_HW_SAMAV2_EXCHANGE_NO_DECIPHERING_BIT

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  Other | Depending on implementation and underlying component.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | wOption | Option parameter.
  [in] | pTxBuffer | Data to transmit.
  [in] | wTxLength | Length of input data.
  [in] | bTxLastBits | Number of valid bits of last byte (Tx).
  [out] | ppRxBuffer | Pointer to received data.
  [out] | pRxLength | Number of received data bytes including incomplete byte.
  [out] | pRxLastBits | Number of valid bits of last byte (Rx).

## § phpalMifare_MfcAuthenticateKeyNo()

phStatus_t phpalMifare_MfcAuthenticateKeyNo | ( | void * | pDataParams,
|  | uint8_t | bBlockNo,
|  | uint8_t | bKeyType,
|  | uint16_t | wKeyNo,
|  | uint16_t | wKeyVersion,
|  | uint8_t * | pUid
| ) |  |

Perform MIFARE(R) Authenticate command with Picc using a key number.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_IO_TIMEOUT | Error in authentication.
  PH_ERR_AUTH_ERROR | Error in authentication.
  Other | Depending on implementation and underlying component.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | bBlockNo | Block-Number on card to authenticate to.
  [in] | bKeyType | Either PHPAL_MIFARE_KEYA or PHPAL_MIFARE_KEYB
  [in] | wKeyNo | Key number to be used in authentication.
  [in] | wKeyVersion | Key version to be used in authentication.
  [in] | pUid | Serial number of current cascade level; uint8_t[4].

## § phpalMifare_MfcAuthenticate()

phStatus_t phpalMifare_MfcAuthenticate | ( | void * | pDataParams,
|  | uint8_t | bBlockNo,
|  | uint8_t | bKeyType,
|  | uint8_t * | pKey,
|  | uint8_t * | pUid
| ) |  |

Perform MIFARE(R) Authenticate command with Picc using a key.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_IO_TIMEOUT | Error in authentication.
  PH_ERR_AUTH_ERROR | Error in authentication.
  Other | Depending on implementation and underlying component.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | bBlockNo | Block-Number on card to authenticate to.
  [in] | bKeyType | Either PHPAL_MIFARE_KEYA or PHPAL_MIFARE_KEYB
  [in] | pKey | Key to be used in authentication.
  [in] | pUid | Serial number of current cascade level; uint8_t[4].

## § phpalMifare_SetMinFdtPc()

phStatus_t phpalMifare_SetMinFdtPc | ( | void * | pDataParams,
|  | uint16_t | wValue
| ) |  |

Perform Setting min FDT for Proximity check.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_IO_TIMEOUT | Error in authentication.
  PH_ERR_AUTH_ERROR | Error in authentication.
  Other | Depending on implementation and underlying component.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | wValue | Option parameter. '1' for setting '0' for resetting