NXP NFC Reader Library v4.040.05.011646

Modules | Macros | Functions
ISO/IEC 18092 Mode Target
Protocol Abstraction Layer

This Component implements the ISO/IEC ISO18092 Target mode contact-less protocol. More...

Collaboration diagram for ISO/IEC 18092 Mode Target:

## Modules
| Component : Software

## Macros
#define | PHPAL_I18092MT_DID_MAX 0x0EU
| The last valid DID. More...
#define | PHPAL_I18092MT_WT_MAX 0x0EU
| The maximum allowed WT value, NFCForum-TS-DigitalProtocol-1.0 section 14.11. More...
#define | PHPAL_I18092MT_FSL_MAX 0x03U
| The maximum allowed FSL value. More...
#define | PHPAL_I18092MT_NAD_MAX 0x0FU
| The maximum allowed NAD value. More...
#define | PHPAL_I18092MT_MASK_NAD_ENABLE 0xFF00U
| Mask used for NAD Enabled/Disabled. More...
#define | PHPAL_I18092MT_MASK_NAD_VALUE 0x00FFU
| Mask used for NAD value. More...

## Functions
phStatus_t | phpalI18092mT_ResetProtocol (void *pDataParams)
| Reset the ISO18092 protocol parameters. More...
phStatus_t | phpalI18092mT_Activate (void *pDataParams, uint8_t *pAtrReq, uint16_t wAtrReqLength, uint8_t *pAtrRes, uint16_t wAtrResLength, uint8_t **pGeneralDataBytes, uint16_t *wGeneralDataBytesLength)
| Handles ISO/IEC 18092 compliant activation sequence. More...
phStatus_t | phpalI18092mT_Receive (void *pDataParams, uint16_t wOption, uint8_t **ppTransportDataBytes, uint16_t *pTransportDataBytesLength)
| Receives ISO/IEC 18092 frame from Initiator. More...
phStatus_t | phpalI18092mT_Transmit (void *pDataParams, uint16_t wOption, uint8_t *pTransportDataBytes, uint16_t wTransportDataBytesLength)
| Sends a DEP_RES I-PDU to an ISO/IEC 18092 compliant Initiator. More...
phStatus_t | phpalI18092mT_Rtox (void *pDataParams)
| Transmits an RTOX PDU to extend waiting time and receives RTOX response from Initiator. More...
phStatus_t | phpalI18092mT_SetConfig (void *pDataParams, uint16_t wConfig, uint16_t wValue)
| Set configuration parameter. More...
phStatus_t | phpalI18092mT_GetConfig (void *pDataParams, uint16_t wConfig, uint16_t *pValue)
| Get configuration parameter. More...

## ISO18092 Target Mode Configuration Parameters
#define | PHPAL_I18092MT_CONFIG_RTOX 0x0000U
| Enable / Disable RTOX feature.
#define | PHPAL_I18092MT_CONFIG_RTOX_VALUE 0x0001U
| RTOX value.
#define | PHPAL_I18092MT_CONFIG_NAD 0x0002U
| Set / Get Node Address. More...
#define | PHPAL_I18092MT_CONFIG_DID 0x0003U
| Get DID value. More...
#define | PHPAL_I18092MT_CONFIG_FSL 0x0004U
| Get FSL value. More...
#define | PHPAL_I18092MT_CONFIG_TO 0x0005U
| Get Time Out (TO) value used by the Target to communicate FWT.

## ISO18092 Target Mode Parameters
#define | PHPAL_I18092MT_BIT_RATE_MASK 0xF0U
| Mask Bit Rates Supported by Initiator. More...
#define | PHPAL_I18092MT_SW_MAX_RTOX_VALUE 0x3BU
| RTOX max value.
#define | PHPAL_I18092MT_SW_MIN_RTOX_VALUE 0x01U
| RTOX min value.

## DRI/DSI (BRI/BSI) Values
#define | PHPAL_I18092MT_DATARATE_106 0x0000U
| DRT(I)/DST(I) value for 106 kBit/s. More...
#define | PHPAL_I18092MT_DATARATE_212 0x0001U
| DRT(T)/DST(T) value for 212 kBit/s. More...
#define | PHPAL_I18092MT_DATARATE_424 0x0002U
| DRI(T)/DSI(T) value for 424 kBit/s. More...

## FSL/LRI Values
#define | PHPAL_I18092MT_FRAMESIZE_64 0x00U
| FSL value for max. More...
#define | PHPAL_I18092MT_FRAMESIZE_128 0x01U
| FSL value for max. More...
#define | PHPAL_I18092MT_FRAMESIZE_192 0x02U
| FSL value for max. More...
#define | PHPAL_I18092MT_FRAMESIZE_254 0x03U
| FSL value for max. More...

## Maximum Values
#define | PHPAL_I18092MT_MAX_GI_LENGTH 0x30U
| Maximum length of Gi data. More...

## Detailed Description

This Component implements the ISO/IEC ISO18092 Target mode contact-less protocol.

Using this component it is possible to communicate with an active/passive Initiator.

## Macro Definition Documentation

## § PHPAL_I18092MT_DID_MAX

#define PHPAL_I18092MT_DID_MAX 0x0EU

The last valid DID.

## § PHPAL_I18092MT_WT_MAX

#define PHPAL_I18092MT_WT_MAX 0x0EU

The maximum allowed WT value, NFCForum-TS-DigitalProtocol-1.0 section 14.11.

## § PHPAL_I18092MT_FSL_MAX

#define PHPAL_I18092MT_FSL_MAX 0x03U

The maximum allowed FSL value.

## § PHPAL_I18092MT_NAD_MAX

#define PHPAL_I18092MT_NAD_MAX 0x0FU

The maximum allowed NAD value.

## § PHPAL_I18092MT_MASK_NAD_ENABLE

#define PHPAL_I18092MT_MASK_NAD_ENABLE 0xFF00U

Mask used for NAD Enabled/Disabled.

## § PHPAL_I18092MT_MASK_NAD_VALUE

#define PHPAL_I18092MT_MASK_NAD_VALUE 0x00FFU

Mask used for NAD value.

## § PHPAL_I18092MT_CONFIG_NAD

#define PHPAL_I18092MT_CONFIG_NAD 0x0002U

Set / Get Node Address.

`wValue` is parsed as follows:

    * NadEnabled = (wValue & 0xFF00) ? 1 : 0;
    * Nad = (wValue & 0x000F);
    *

## § PHPAL_I18092MT_CONFIG_DID

#define PHPAL_I18092MT_CONFIG_DID 0x0003U

Get DID value.

Indicates if DID is used by the PAL.

## § PHPAL_I18092MT_CONFIG_FSL

#define PHPAL_I18092MT_CONFIG_FSL 0x0004U

Get FSL value.

Indicates either Lrt or Lri value whichever is lesser in case PSL is not exchanged. If PSL is exchanged then the agreed FSL value is returned.

## § PHPAL_I18092MT_BIT_RATE_MASK

#define PHPAL_I18092MT_BIT_RATE_MASK 0xF0U

Mask Bit Rates Supported by Initiator.

## § PHPAL_I18092MT_DATARATE_106

#define PHPAL_I18092MT_DATARATE_106 0x0000U

DRT(I)/DST(I) value for 106 kBit/s.

## § PHPAL_I18092MT_DATARATE_212

#define PHPAL_I18092MT_DATARATE_212 0x0001U

DRT(T)/DST(T) value for 212 kBit/s.

## § PHPAL_I18092MT_DATARATE_424

#define PHPAL_I18092MT_DATARATE_424 0x0002U

DRI(T)/DSI(T) value for 424 kBit/s.

## § PHPAL_I18092MT_FRAMESIZE_64

#define PHPAL_I18092MT_FRAMESIZE_64 0x00U

FSL value for max.

frame size of 64 Bytes.

## § PHPAL_I18092MT_FRAMESIZE_128

#define PHPAL_I18092MT_FRAMESIZE_128 0x01U

FSL value for max.

frame size of 128 Bytes.

## § PHPAL_I18092MT_FRAMESIZE_192

#define PHPAL_I18092MT_FRAMESIZE_192 0x02U

FSL value for max.

frame size of 192 Bytes.

## § PHPAL_I18092MT_FRAMESIZE_254

#define PHPAL_I18092MT_FRAMESIZE_254 0x03U

FSL value for max.

frame size of 254 Bytes.

## § PHPAL_I18092MT_MAX_GI_LENGTH

#define PHPAL_I18092MT_MAX_GI_LENGTH 0x30U

Maximum length of Gi data.

## Function Documentation

## § phpalI18092mT_ResetProtocol()

phStatus_t phpalI18092mT_ResetProtocol | ( | void * | pDataParams | ) |

Reset the ISO18092 protocol parameters.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.

## § phpalI18092mT_Activate()

phStatus_t phpalI18092mT_Activate | ( | void * | pDataParams,
|  | uint8_t * | pAtrReq,
|  | uint16_t | wAtrReqLength,
|  | uint8_t * | pAtrRes,
|  | uint16_t | wAtrResLength,
|  | uint8_t ** | pGeneralDataBytes,
|  | uint16_t * | wGeneralDataBytesLength
| ) |  |

Handles ISO/IEC 18092 compliant activation sequence.

This function takes the data returned by phhalHw_Autocoll as a parameter, along with the ATR_RES.
Validates the received ATR_REQ and sends the ATR_RES to PCD. If the ATR_REQ was received with error, then stays mute and waits for the valid ATR_REQ and then responds with ATR_RES.
If General information bytes are present in the ATR_REQ then it will be returned back to the caller.
ATR_RES format : byte 1-10:nfcid, byte 11:BSt, byte 12:BRt, byte13:TO, byte14:PPt, byte:15..n[Gt1..n].

Return values

  PH_ERR_SUCCESS | Operation successful, target activated.
  PH_ERR_PROTOCOL_ERROR | Received response is not ISO/IEC 18092 compliant.
  PH_ERR_EXT_RF_ERROR | RF Turned OFF in passive communication mode
  PH_ERR_INVALID_PARAMETER | Invalid parameter supplied.
  Others | from the underlying layer.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | pAtrReq | Data received from Autocoll. Pointer to ATR_REQ.
  [in] | wAtrReqLength | Length of ATR_REQ. Including GT byte.
  [in] | pAtrRes | Pointer to ATR_RES. Refer function description for the format.
  [in] | wAtrResLength | Length of ATR_RES.
  [out] | pGeneralDataBytes | Pointer to the general data bytes of ATR_REQ.
  [out] | wGeneralDataBytesLength | Number of received general data bytes of ATR_REQ.

## § phpalI18092mT_Receive()

phStatus_t phpalI18092mT_Receive | ( | void * | pDataParams,
|  | uint16_t | wOption,
|  | uint8_t ** | ppTransportDataBytes,
|  | uint16_t * | pTransportDataBytesLength
| ) |  |

Receives ISO/IEC 18092 frame from Initiator.

This will be the next call in sequence after the phpalI18092mT_Activate.
If the next frame is PSL_REQ it will be validated and handled in this function and this will send the PSL_RES else it will come out after validating the DEP_REQ received as the next frame.
If it is a chained frame and more data is expected and RxBuffer is sufficiently large to hold the next chained frame, sends an ACK to receive the next chained frame i.e., it will keep on getting the next chunk of data after sending ACKs to the PCD and adding the chunks to the RxBuffer making it a contiguous set of data.
If there is more data to be received but the RxBuffer cannot handle the next chained frame, returns to the caller with status PH_ERR_SUCCESS_CHAINING. In this case, the application or the higher layer has to copy the received buffer and call the phpalI18092_Receive again with wOption = PH_RECEIVE_CHAINING. In this case this function will send an ACK to the Initiator to start receiving the rest of the data. If the data received is DSL_REQ, then sends the DSL_RES and set the state to MIFARE Halted state in case of Type A in passive communication mode or else will remain in receive mode till a WUP_REQ is received in active communication mode.
This function will also handles the RLS_REQ and sends a RLS_RES In case of Active communication mode this function waits for WUP_REQ after DSL_REQ is received. If ISO 18092 RAW is activated, the RTOx timer will be started in this function before the data is handled over to the caller.

`wOption` can be one of:

- PH_RECEIVE_DEFAULT
- PH_RECEIVE_CHAINING
- PH_RECEIVE_CHAINING_BUFSIZE

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_SUCCESS_CHAINING | Rx chaining not complete.
  PH_ERR_SUCCESS_ACK | Received ACK for a previous Transmit and no valid data received in the OUT parameters.
  PH_ERR_SUCCESS_DESELECTED | PCD has sent DSL_REQ.
  PH_ERR_SUCCESS_RELEASED | PCD has sent RLS_REQ.
  PH_ERR_EXT_RF_ERROR | External RF turned OFF in passive communication mode.
  PH_ERR_BUFFER_OVERFLOW | Attempt to write beyond buffer size.
  Others | from the underlying layer.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | wOption | Option parameter.
  [out] | ppTransportDataBytes | Pointer to the received transport data bytes.
  [out] | pTransportDataBytesLength | Number of received transport data bytes.

## § phpalI18092mT_Transmit()

phStatus_t phpalI18092mT_Transmit | ( | void * | pDataParams,
|  | uint16_t | wOption,
|  | uint8_t * | pTransportDataBytes,
|  | uint16_t | wTransportDataBytesLength
| ) |  |

Sends a DEP_RES I-PDU to an ISO/IEC 18092 compliant Initiator.

This is to be called by the application or the reader library thread to transmit a response to the PCD.
This will internally call the HAL transmit API.
If the pTxData length is bigger than the ISO 18092 Tx buffer (HAL Tx buffer), then this function will fragment and send this data to the PCD.
In addition PH_TRANSMIT_TXCHAINING may be used to enable providing the TxData in chunks i.e., the application itself may have received the first chunk only from an external Host and it could receive more data from the Host in the next iteration. In such cases, this will be useful.

`wOption` can be one of:

- PH_TRANSMIT_DEFAULT
- PH_TRANSMIT_TXCHAINING

Additionally, the following options are also available:

- PH_TRANSMIT_BUFFER_FIRST
- PH_TRANSMIT_BUFFER_CONT
- PH_TRANSMIT_BUFFER_LAST

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_EXT_RF_ERROR | External RF turned OFF in passive communication mode.
  Others | from the underlying layer.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | wOption | Option parameter.
  [in] | pTransportDataBytes | Transport Data Bytes to be transmitted as part of an DEP_REQ I-PDU.
  [in] | wTransportDataBytesLength | Number of transport data bytes.

## § phpalI18092mT_Rtox()

phStatus_t phpalI18092mT_Rtox | ( | void * | pDataParams | ) |

Transmits an RTOX PDU to extend waiting time and receives RTOX response from Initiator.

This is the API that is called by the application on expire of the RTO timer.
This sends RTOx packet to the PCD and then waits for a valid response.
If the received data is a NACK, then the RTOx packet is re-transmitted.

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_EXT_RF_ERROR | RF Turned OFF in passive communication mode
  Others | from the underlying layer.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.

## § phpalI18092mT_SetConfig()

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

Set configuration parameter.

`wOption` can be one of:

- PHPAL_I18092MT_CONFIG_RTOX
- PHPAL_I18092MT_CONFIG_RTOX_VALUE
- PHPAL_I18092MT_CONFIG_NAD

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_INVALID_PARAMETER | Invalid parameter supplied.
  PH_ERR_UNSUPPORTED_PARAMETER | wrong wOption parameter supplied.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | wConfig | Configuration Identifier.
  [in] | wValue | Configuration Value.

## § phpalI18092mT_GetConfig()

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

Get configuration parameter.

`wOption` can be :

- PHPAL_I18092MT_CONFIG_RTOX
- PHPAL_I18092MT_CONFIG_NAD

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_UNSUPPORTED_PARAMETER | wrong wOption parameter supplied.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | wConfig | Configuration Identifier.
  [out] | pValue | Configuration Value.