NXP NFC Reader Library v4.040.05.011646

Modules | Functions
Felica
Protocol Abstraction Layer

These Components implement the Felica (contactless) protocol. More...

Collaboration diagram for Felica:

## Modules
| Component : Software

## Functions
phStatus_t | phpalFelica_ReqC (void *pDataParams, uint8_t *pSystemCode, uint8_t bNumTimeSlots, uint8_t **ppRxBuffer, uint16_t *wLen)
| Perform the Felica ReqC command. More...
phStatus_t | phpalFelica_ActivateCard (void *pDataParams, uint8_t *pIDmPMm, uint8_t bIDmPMmLength, uint8_t *pSystemCode, uint8_t bNumTimeSlots, uint8_t *pRxBuffer, uint8_t *pRxLength, uint8_t *pMoreCardsAvailable)
| This command activates a Felica card. More...
phStatus_t | phpalFelica_Exchange (void *pDataParams, uint16_t wOption, uint16_t wN, uint8_t *pTxBuffer, uint16_t wTxLength, uint8_t **ppRxBuffer, uint16_t *pRxLength)
| Exchange data with the Picc. More...
phStatus_t | phpalFelica_SetConfig (void *pDataParams, uint16_t wConfig, uint16_t wValue)
| Set configuration parameter. More...
phStatus_t | phpalFelica_GetConfig (void *pDataParams, uint16_t wConfig, uint16_t *pValue)
| Get configuration parameter. More...
phStatus_t | phpalFelica_GetSerialNo (void *pDataParams, uint8_t *pUidOut, uint8_t *pLenUidOut)
| As the card receives the Get Serial Number command, it shall respond with that one. More...
phStatus_t | phpalFelica_GetFrameInfo (void *pDataParams, uint8_t bFrameNum, uint8_t *pResponseBuffer, uint16_t *pwStatus, uint8_t **pID, uint8_t *pLen)
| This function will provide information of given frame number(1 to N). More...
phStatus_t | phpalFelica_SetSerialNo (void *pDataParams, uint8_t *pIDmPMm)
| This function will update IDmPMm in this layer's parameter structure. More...

## Lengths
#define | PHPAL_FELICA_IDM_LENGTH 8U
| UID length in bytes. More...
#define | PHPAL_FELICA_PMM_LENGTH 8U
| PMm length in bytes. More...
#define | PHPAL_FELICA_BLOCK_LENGTH 4U
| Block length in bytes. More...
#define | PHPAL_FELICA_PAGE_LENGTH 16U
| Number of bytes per page. More...
#define | PHPAL_FELICA_ATQC_LENGTH 17U
| Length of ATQC. More...
#define | PHPAL_FELICA_RD_LENGTH 2U
| Length of Request Data (RD) in ATQC. More...
#define | PHPAL_FELICA_TXLENGTH_MAX 254U
| Maximum length of a transmission package. More...

## Definitions of the time slots for the ReqC command
#define | PHPAL_FELICA_NUMSLOTS_1 0x00
| Value for `bNumSlots` = 1. More...
#define | PHPAL_FELICA_NUMSLOTS_2 0x01
| Value for `bNumSlots` = 2. More...
#define | PHPAL_FELICA_NUMSLOTS_4 0x03
| Value for `bNumSlots` = 4. More...
#define | PHPAL_FELICA_NUMSLOTS_8 0x07
| Value for `bNumSlots` = 8. More...
#define | PHPAL_FELICA_NUMSLOTS_16 0x0F
| Value for `bNumSlots` = 16. More...
#define | PHPAL_FELICA_PREAMBLE_LEN_48BITS 0x00
| Lengths More...
#define | PHPAL_FELICA_PREAMBLE_LEN_56BITS 0x02
| Preamble of 56 Bits. More...
#define | PHPAL_FELICA_PREAMBLE_LEN_64BITS 0x03
| Preamble of 64 Bits. More...
#define | PHPAL_FELICA_PREAMBLE_LEN_72BITS 0x04
| Preamble of 72 Bits. More...

## System Code
#define | PHPAL_FELICA_SYSTEM_CODE_BYTE_0 0xFFU
#define | PHPAL_FELICA_SYSTEM_CODE_BYTE_1 0xFFU

## Felica Parameters
#define | PHPAL_FELICA_CONFIG_RC 0x0000U
| Set / Get Request Code (RC).
#define | PH_PALFELICA_CONFIG_NUM_RESPONSE_FRAMES 0x0001U
| Get total number of response frame received. More...
#define | PHPAL_FELICA_PREAMBLE_LENGTH 0x0002U
| Set / Get Preamble Length.

## Detailed Description

These Components implement the Felica (contactless) protocol.

## Macro Definition Documentation

## § PHPAL_FELICA_IDM_LENGTH

#define PHPAL_FELICA_IDM_LENGTH 8U

UID length in bytes.

## § PHPAL_FELICA_PMM_LENGTH

#define PHPAL_FELICA_PMM_LENGTH 8U

PMm length in bytes.

## § PHPAL_FELICA_BLOCK_LENGTH

#define PHPAL_FELICA_BLOCK_LENGTH 4U

Block length in bytes.

## § PHPAL_FELICA_PAGE_LENGTH

#define PHPAL_FELICA_PAGE_LENGTH 16U

Number of bytes per page.

## § PHPAL_FELICA_ATQC_LENGTH

#define PHPAL_FELICA_ATQC_LENGTH 17U

Length of ATQC.

## § PHPAL_FELICA_RD_LENGTH

#define PHPAL_FELICA_RD_LENGTH 2U

Length of Request Data (RD) in ATQC.

## § PHPAL_FELICA_TXLENGTH_MAX

#define PHPAL_FELICA_TXLENGTH_MAX 254U

Maximum length of a transmission package.

## § PHPAL_FELICA_NUMSLOTS_1

#define PHPAL_FELICA_NUMSLOTS_1 0x00

Value for `bNumSlots` = 1.

## § PHPAL_FELICA_NUMSLOTS_2

#define PHPAL_FELICA_NUMSLOTS_2 0x01

Value for `bNumSlots` = 2.

## § PHPAL_FELICA_NUMSLOTS_4

#define PHPAL_FELICA_NUMSLOTS_4 0x03

Value for `bNumSlots` = 4.

## § PHPAL_FELICA_NUMSLOTS_8

#define PHPAL_FELICA_NUMSLOTS_8 0x07

Value for `bNumSlots` = 8.

## § PHPAL_FELICA_NUMSLOTS_16

#define PHPAL_FELICA_NUMSLOTS_16 0x0F

Value for `bNumSlots` = 16.

## § PHPAL_FELICA_PREAMBLE_LEN_48BITS

#define PHPAL_FELICA_PREAMBLE_LEN_48BITS 0x00

Lengths

Preamble of 48 Bits.

## § PHPAL_FELICA_PREAMBLE_LEN_56BITS

#define PHPAL_FELICA_PREAMBLE_LEN_56BITS 0x02

Preamble of 56 Bits.

## § PHPAL_FELICA_PREAMBLE_LEN_64BITS

#define PHPAL_FELICA_PREAMBLE_LEN_64BITS 0x03

Preamble of 64 Bits.

## § PHPAL_FELICA_PREAMBLE_LEN_72BITS

#define PHPAL_FELICA_PREAMBLE_LEN_72BITS 0x04

Preamble of 72 Bits.

## § PH_PALFELICA_CONFIG_NUM_RESPONSE_FRAMES

#define PH_PALFELICA_CONFIG_NUM_RESPONSE_FRAMES 0x0001U

Get total number of response frame received.

Invalid if phpalFelica_ReqC function called with slot number PHPAL_FELICA_NUMSLOTS_1

## Function Documentation

## § phpalFelica_ReqC()

phStatus_t phpalFelica_ReqC | ( | void * | pDataParams,
|  | uint8_t * | pSystemCode,
|  | uint8_t | bNumTimeSlots,
|  | uint8_t ** | ppRxBuffer,
|  | uint16_t * | wLen
| ) |  |

Perform the Felica ReqC command.

Note: This function waits until all cards in all time slots have had time to reply even though only the first response is returned.
The formula used is 1208us * (n-1) according to JIS X 6319-4:2005.

Response format when bNumTimeSlots greater than PHPAL_FELICA_NUMSLOTS_1

      0                                                                           28         31
      +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      |   LEN  |               PAYLOAD(MAX 19 BYTES)              |     PAD      |   STATUS   |
      +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Format of Status Byte.

      +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      |      |              |      |L|  |  |  |  |                                          |
      |      |              |      |e|Co|Pr|Da|CL|                                          |
      | RFU  |     LEN      | RFU  |n|ll|ot|ta|Er|                  RFU                     |
      | [7:5]|     [4:0]    | [7:5]|E|De|Er|Er|ro|                                          |
      |      |              |      |r|t |r |r |r |                                          |
      |      |              |      |r|  |  |  |  |                                          |
      +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      |<-------Byte 28----->|<------Byte 29----->|<------Byte 30----->|<------Byte 31------>|

Response format when bNumTimeSlots is PHPAL_FELICA_NUMSLOTS_1

      ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      |                   IDmPMm[16]                       |     RD[Optional]    |
      ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

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] | pSystemCode | System-Code; uint8_t[2].
  [in] | bNumTimeSlots | Number of time slots to use. Refer to e.g. PHPAL_FELICA_NUMSLOTS_1 for valid values.
  [out] | ppRxBuffer | Pointer to the HAL Rx buffer. 32bytes / slot information in case of multiple slots or else a single response containing IDmPMm.
  [out] | wLen | Length of the content in the buffer.

## § phpalFelica_ActivateCard()

phStatus_t phpalFelica_ActivateCard | ( | void * | pDataParams,
|  | uint8_t * | pIDmPMm,
|  | uint8_t | bIDmPMmLength,
|  | uint8_t * | pSystemCode,
|  | uint8_t | bNumTimeSlots,
|  | uint8_t * | pRxBuffer,
|  | uint8_t * | pRxLength,
|  | uint8_t * | pMoreCardsAvailable
| ) |  |

This command activates a Felica card.

Note: If an IDm is passed to this function, it is stored as the current IDm and no real activation is done.

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] | pIDmPMm | IDm followed by PMm; If supplied it is stored and no real activation is done.
  [in] | bIDmPMmLength | IDm length; 0 or 16.
  [in] | pSystemCode | System-Code; uint8_t[2].
  [in] | bNumTimeSlots | Number of timeslots to use. Refer to e.g. PHPAL_FELICA_NUMSLOTS_1 for valid values.
  [out] | pRxBuffer | 8 bytes NFCID2 + 8 bytes PAD; uint8_t[16].
  [out] | pRxLength | Length of received data. 0 or 16.
  [out] | pMoreCardsAvailable | Whether there are more cards in the field or not; uint8_t.

## § phpalFelica_Exchange()

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

Exchange data with the 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] | wN | N to calculate the response timeout.
  [in] | pTxBuffer | Data to transmit; Length and IDm is added automatically.
  [in] | wTxLength | Length of data to transmit.
  [out] | ppRxBuffer | Pointer to received data; Length, response code and IDm are removed automatically.
  [out] | pRxLength | number of received data bytes.

## § phpalFelica_SetConfig()

phStatus_t phpalFelica_SetConfig | ( | void * | pDataParams,
|  | uint16_t | wConfig,
|  | uint16_t | wValue
| ) |  |

Set configuration parameter.

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] | wConfig | Configuration Identifier.
  [in] | wValue | Configuration Value.

## § phpalFelica_GetConfig()

phStatus_t phpalFelica_GetConfig | ( | void * | pDataParams,
|  | uint16_t | wConfig,
|  | uint16_t * | pValue
| ) |  |

Get configuration parameter.

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] | wConfig | Configuration Identifier.
  [out] | pValue | Configuration Value.

## § phpalFelica_GetSerialNo()

phStatus_t phpalFelica_GetSerialNo | ( | void * | pDataParams,
|  | uint8_t * | pUidOut,
|  | uint8_t * | pLenUidOut
| ) |  |

As the card receives the Get Serial Number command, it shall respond with that one.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_USE_CONDITION | No Serial number available at the moment.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [out] | pUidOut | Last Uid (IDm + PMm); uint8_t[16].
  [out] | pLenUidOut | Length of Uid; 0 or 16.

## § phpalFelica_GetFrameInfo()

phStatus_t phpalFelica_GetFrameInfo | ( | void * | pDataParams,
|  | uint8_t | bFrameNum,
|  | uint8_t * | pResponseBuffer,
|  | uint16_t * | pwStatus,
|  | uint8_t ** | pID,
|  | uint8_t * | pLen
| ) |  |

This function will provide information of given frame number(1 to N).

It will provide pointer to IDmPMm if frame status is PH_ERR_SUCCESS. pwStatus can be one of:

- PH_ERR_SUCCESS
- PH_ERR_PROTOCOL_ERROR
- PH_ERR_COLLISION_ERROR
- PH_ERR_INTEGRITY_ERROR
- PH_ERR_LENGTH_ERROR

Note: This function is only valid when function phpalFelica_ReqC is called with slot number greater than PHPAL_FELICA_NUMSLOTS_1.

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] | bFrameNum | Frame number. Frame number 0 is invalid.
  [in] | pResponseBuffer | The pointer to the entire Felica response as obtained from ReqC API.
  [out] | pwStatus | Frame status. Status will be Success, or one of collision, length, integrity, protocol errors.
  [out] | pID | Pointer to IDmPMm in case of wStatus being success.
  [out] | pLen | Length of IDmPMm data. 2 Request Data (RD) bytes are optional. This will indicate exact length.

## § phpalFelica_SetSerialNo()

phStatus_t phpalFelica_SetSerialNo | ( | void * | pDataParams,
|  | uint8_t * | pIDmPMm
| ) |  |

This function will update IDmPMm in this layer's parameter structure.

This function must be call after card or device is activated.

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] | pIDmPMm | 16 byte IDmPMm.