NXP Reader Library is a software written in C language enabling the customers to create their own software stack for their contactless reader. The reader library supports the reader frontend ICs namely PN5180, CLRC663, PN5190 and reader NFC controllers namely PN7462AU, PN7640.
This document describes the structure on NFC reader library. After that, two examples are given on how to modify the software to match read and write NDEF messages. The description is based on NXP NFC Reader Library version 07.09.00, on PNEV7642A board.
1 NFC reader library introduction
NXP Reader Library is classified into following layer, each layer is independent from the other layers, each layer is used as an entry point for immediate upper layer.
Application layer (AL)
Protocol abstraction layer (PAL)
Hardware abstraction layer (HAL)
Bus abstraction layer (BAL)
Below is a full picture of the NFC reader library
The reader library source code structure is as below picture shows,
Comps – components, source files of all included components (abstraction layers)
Intfs - interfaces . header files of all included components.
Types - Types. Global macros for general use as well as configuration.
1.1 Application layer (AL)
This layer contains application specific implementations for various contactless cards, includes MIFARE DESFire, MIFARE DESFIRE EV2, MIFARE Plus, MIFARE Plus EV1, MIFARE Classic etc.
The application layer contains four main packages:
-Card command sets and the NFC Forum Tag Type Operations
---MIFARE Classic Ultralight, DESFire, Felica, Jewel, ICode
---phalTop provides an API to complete NDEF related operations on top of the four NFC Forum Type Tags
-NFC Activity:
---Discovery Loop
-Host Card Emulation:
---Type 4A Tag
-P2P Package:
---LLCP
---SNEP
1.2 Protocol abstraction layer (PAL)
The protocol abstraction layer implements the activation and exchange operations regarding the protocol of the contactless communication.
The NXP Reader Library supports following ISO standards protocols
ISO/IEC14443-3A, ISO/IEC1443-3B, ISO/IEC14443-4, ISO/IEC14443-4A, MIFARE, ISO/IEC15693, ISO18000-3M1, ISO/IEC18000-3M3, ISO/IEC18092, Felica,
1.3 Hardware abstraction layer (HAL)
The hardware abstraction layer implements the hardware specific elements of the reader chip, and abstract them to a generic interface.
1.4 Bus abstraction layer (BAL)
The bus abstraction layer ensures correct communication interface between the master device and the reader chip, includes SPI, I2C, I3C, UART…
2 Reader Library customization
2.1 port to other MCU
Layer structure of the NXP Reader Library is modular and multi-layered architecture. If you want to port the reader library to other MCU, what you need to do is change the phDriver.
phDriver is the abstraction of the board, of the MCU.
phDriver includes GPIO, Timer Abstraction Layer and BAL (Bus Abstraction Layer).
GPIO: it is for IRQ, Reset or other control signals.
Timer: it is crucial for any timing relevant tasks, RTOS user timers, they care about everything, so porting timers is very important.
BAL: interface between MCU and NFC Front-End (SPI, I2C, I3C, UART…), we have to initialize SPI or I2C.
2.2 Read NDEF handling
Exercise 1: Read the NDEF message of your ICODE DNA tag
Process:
check if the found Tag is technology V
config the TOP AL to T5T
check if a NDEF container is present
check if I can read the message
read the NDEF message
please see the attached source code for more details
2.3 write NDEF handling
Exercise 2: Write the same message onto one MIFARE DESFire tag.
Process:
1 check if the found tag is Type-A
2 check if it is a T4AT by masking the SAK
3 set TOP AL config to T4T
4 check if it is NDEF formatted
5 write NDEF message
View full article