NXP NFC Reader Library v4.040.05.011646

Modules
NXP NFC Library Top Level API
Simplified API Layer

NXP NFC Library Top Level API. More...

Collaboration diagram for NXP NFC Library Top Level API:

## Modules
| NXP NFC Library Definitions
| Common defines used within the API of NFC library.
| NXP NFC Library Configuration Tags
| These tags are used as `bConfigTag` parameter for phNfcLib_SetConfig_Value, phNfcLib_SetConfig and phNfcLib_GetConfig.
| NXP NFC Library Functions
| All Public Functions of the NFC Library.

## Detailed Description

NXP NFC Library Top Level API.

General
  This module provides an high level abstraction of the NXP NFC Reader Library stack, focusing on simplicity while featuring the mostly used functionality. It aims to write NXP NFC applications requiring as less code as possible. Still there is the possibility to use the legacy NXP NFC Reader Library stack API by calling phNfcLib_GetDataParams in order to retrieve the dataparams structure required when calling NXP NFC Reader Library stack functions.

Activation and Transmission Channel
  One of the main concepts of the NXP NFC Library module are the transmission channels. A transmission channel is a logical connection between the device running the library and a peer. Once a peer could be activated this logical channel gets established and subsequent calls to phNfcLib_Transmit and phNfcLib_Receive are performing transmissions over this channel. In fact this channel defines how data sent over the channel gets encapsulated. There are three different channels available:
  - NFC Forum Channel: This channel is used to transfer NDEF messages
  - EMVCo Channel: This channel is used to transfer ISO 7816 APDUs over the ISO14443-4 protocol, according to EMVCo L1 specification.
  - ISO Channel: General channel which performs raw data transfer on block/frame level as defined in the corresponding protocols.

See also
  For more information refer to phNfcLib_Transmit, phNfcLib_Receive and phNfcLib_Activate.

NXP Nfc Library EMVCo State Machine
  The NXP NFC Library module implements a state machine ensuring the API functions exposed are executed in the correct order and state.

NXP Nfc Library ISO State Machine
  The NXP NFC Library module implements a state machine ensuring the API functions exposed are executed in the correct order and state.
  Functions in this module are only allowed to be called in specific states, otherwise PH_NFCLIB_STATUS_INVALID_STATE an error is returned The API function description section provides information which state is required for each function to be called.

Example Code for EMVCo polling application. (Activation and one APDU data exchange)
  #include <ph_Status.h>
  #include <phNfcLib.h>
  phNfcLib_Status_t EMVCoPollingExample(uint8_t* pCApdu, uint16_t wCApduLength, uint8_t* pRApdu, uint16_t * pRApduLength)
  {
  uint16_t wRfTechnos = PH_NFCLIB_TECHNOLOGY_INITIATOR_ISO_14443_A | PH_NFCLIB_TECHNOLOGY_INITIATOR_ISO_14443_B;
  phNfcLib_Status_t status;
  phNfcLib_Init();
  // set EMVCo Profile
  phNfcLib_SetConfig_Value(PH_NFCLIB_CONFIG_ACTIVATION_PROFILE, PH_NFCLIB_ACTIVATION_PROFILE_EMVCO);
  // start activation. peerInfo set to NULL, we don't need detailed information
  status = phNfcLib_Activate(wRfTechnos, NULL, NULL);
  if (status == PH_NFCLIB_STATUS_PEER_ACTIVATION_DONE)
  {
  status = phNfcLib_Transmit(pCApdu, wCApduLength);
  status |= phNfcLib_Receive(pRApdu, pRApduLength, NULL);
  phNfcLib_Deactivate(PH_NFCLIB_DEACTIVATION_MODE_RELEASE, NULL);
  }
  else
  {
  // could either be PH_NFCLIB_STATUS_MULTIPLE_PEERS_DETECTED or PH_NFCLIB_STATUS_PEER_ACTIVATION_FAILED.
  // In any case, inform user about it by escalating the error to the caller
  }
  return status;
  }

Example Code for Reading an NDEF record.
  #include <ph_Status.h>
  #include <phNfcLib.h>
  phNfcLib_Status_t NdefActivateAndRead(uint8_t * aNdefMessage, uint16_t *pNdefMessageSize)
  {
  uint16_t wRfTechnos = (PH_NFCLIB_TECHNOLOGY_INITIATOR_ISO_14443_A | PH_NFCLIB_TECHNOLOGY_INITIATOR_ISO_14443_B |
  PH_NFCLIB_TECHNOLOGY_INITIATOR_ISO_15693);
  phNfcLib_Status_t status;
  phNfcLib_Init();
  // set NXP NFC Profile
  phNfcLib_SetConfig_Value(PH_NFCLIB_CONFIG_ACTIVATION_PROFILE, PH_NFCLIB_ACTIVATION_PROFILE_NFC);
  // start activation. peerInfo set to NULL, we don't need detailed information
  status = phNfcLib_Activate(wRfTechnos, NULL, NULL);
  if (status == PH_NFCLIB_STATUS_PEER_ACTIVATION_DONE)
  {
  // activation done, call phNfcLib_Receive to read the NDEF
  status = phNfcLib_Receive(aNdefMessage, pNdefMessageSize, NULL);
  phNfcLib_Deactivate(PH_NFCLIB_DEACTIVATION_MODE_RELEASE, NULL);
  }
  else
  {
  // could be PH_NFCLIB_STATUS_PEER_ACTIVATION_FAILED.
  // In any case, inform user about it by escalating the error to the caller
  }
  return status;
  }