NXP NTAG® 5 switch Reference guide

Type
Reference guide

This manual is also suitable for

RM00221
NTAG 5 - Android application development
Rev. 1.1 — 7 May 2020 Reference manual
531811 COMPANY PUBLIC
Document information
Information Content
Keywords NTAG 5, Android, ISO/IEC 15693, NFC, Pass-Through, PWM, GPIO, I2C
Master
Abstract This application note describes the usage of the Android application
developed to interact with the NTAG 5. There are four different use cases
defined to explore some of the new features added in this product.
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 2 / 41
Revision history
Rev Date Description
v.1.1 20200507 Figures updated
Editorial changes
v.1.0 20200109 First official released version
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 3 / 41
1 Introduction
1.1 Objective
This document aims to describe the main functionalities of the Android application that
demonstrates several features of the NTAG 5 tag.
The Android application is divided in four use cases. This document describes each use
case in detail, presenting the most important parts of the code snippets.
1.2 Target audience
This document is intended for Android developers who are working with the NTAG 5.
NXP has created a reference Android Application to demonstrate four different use cases
of the new tag. Thus, an Android and Java background is needed in order to have a
complete understanding of the document.
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 4 / 41
2 NTAG 5 overview
2.1 General description
NTAG 5 is ISO/IEC 15693 and NFC Forum Type 5 Tag compliant IC with an EEPROM,
SRAM and I
2
C host interface. This ensures information exchange with all NFC Forum
devices with a tap. With this ability, the tag offers a long-reading range and privacy due to
close proximity with mobile devices.
2.2 Features and applications
NTAG 5 is equipped with a reliable and robust memory. It has a 2048-byte EEPROM for
the user memory and a 256-byte SRAM for frequently changing data and Pass-Through
mode.
Regarding security there are several ways to protect the IC:
32-bit password to access the memory from NFC and I
2
C interfaces.
Optional 64-bit password only to read/write the tag from NFC perspective.
128-bit AES mutual authentication from NFC perspective before doing memory
operations.
The NTAG 5 has a configurable contact interface with an I
2
C standard slave mode (with
100 kHz and fast 400 kHz operating frequencies) and a transparent I
2
C master channel.
Other interesting features in the contact interface are the configurable event detection
pin, two GPIO channels, two PWM channels and energy harvesting for low-power budget
applications.
Apart from these features, NTAG 5 has several innovative features such as Active Load
Modulation, NFC and I
2
C Disable, Privacy mode and DESTROY command.
Taking into account the IC features, it can be used in quite different applications:
Lighting, Smart home, Consumer, Industrial, Gaming or Smart metering.
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 5 / 41
3 NTAG 5 – Use cases definition in Android App
3.1 Use cases definition
3.1.1 I
2
C master channel use case
This use case aims to show the I
2
C master channel feature of the NTAG 5. Using I
2
C
Master interface, I²C slave devices like sensors or memories can be connected to the
NTAG 5 without an external microcontroller. Using energy harvesting capability, an I²C
device can be powered by NTAG 5.
The response from the I
2
C slave to the commands will be stored in the SRAM and can be
read afterwards from NFC perspective.
In this use case, the I
2
C Master channel will be used to retrieve different data from the
combo sensor (FXOS8700CQ) included in the FRDM-KW41Z board. Since the MCU
is not used to retrieve the data from the sensor, this use case will not have a KW41Z
counterpart, only the Android application use case.
A sequence diagram of the use case can be seen in Figure 1.
It is important to remark that there are several I
2
C commands pre-defined to
communicate with the combo sensor (like sensor configuration, get accelerometer or get
magnetometer data). But there will also be the possibility to write custom commands to
retrieve other data from the sensor. The corresponding code snippet section will explain
the way these commands are formed.
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 6 / 41
aaa-033486
NTAG5 I
2
C Active
NFC ON
Write in the SRAM the data
retrieved from sensor
Select NTAG
ACK
Config tag as I
2
C Master
(USE_CASE_CONFIG = 01b)
in TAG_CONFIG_1 (37h)
ACK
Configure FRDM-KW41Z
combosensor (set standby mode,
set hybrid mode and
finally active mode)
ACK
Send a predefined or custom
command to the combosensor
Send an I
2
C command addressing a
particular register in the sensor
Read SRAM
Android App KW41Z
Figure 1. I
2
C Master channel sequence diagram
3.1.2 GPIO use case
This use case aims to demonstrate the GPIO feature of the NTAG 5. In this feature, it is
possible to use the I
2
C lines as general-purpose input/output lines. The NTAG 5 has the
I
2
C lines (SCL/SDA) multiplexed with two GPIO/PWM lines.
These GPIO lines are managed via configuration/session registers. In the input mode,
the status of the pad will be available in the corresponding session bit. In the output
mode, the status can be written in the corresponding session bit.
There are two different channels available to be configured as GPIO. In this use case,
the channel 0 is configured as GPIO output to show the capabilities of the NTAG in this
mode and channel 1 is configured as GPIO input.
For a better understanding of the use case, a sequence diagram is shown in Figure 2.
First of all, the tag needs to be configured in GPIO/PWM mode. This is necessary
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 7 / 41
because the I
2
C lines and the GPIO/PWM lines are multiplexed and the tag needs
to select one of them. Once the IC is correctly configured, it is possible to read the
configuration for the two GPIO channels.
aaa-033487
NTAG5 I
2
C Active
NFC ON
Update GPIO_PAD1_IN_STATUS pin
Select NTAG
ACK
Config tag as GPIO/PWM
(USE_CASE_CONFIG = 10b)
in TAG_CONFIG_1 (37h)
ACK
Read Configuration (A3h, 37h)
GPIO Configuration (A3h, 37h)
Write Configuration (A3h, 37h)
ACK
Set GPIO_SCL_PAD_OUT_STATUS (A3h)
Read GPIO_PAD1_IN_STATUS (A0h)
Clear GPIO_SCL_PAD_OUT_STATUS (A3h)
Turn off LED4
Read PTC3 pin status
Turn on LED4
Update image according to pin status
Android App KW41Z
(OUTPUT use case)
(INPUT use case)
Figure 2. GPIO use case sequence diagram
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 8 / 41
3.1.2.1 GPIO output
In the GPIO output, the idea is to use the KW41Z board with the Android application.
First, it is necessary to flash the FRDM-KW41Z board with the corresponding binary
file. Then select the GPIO use case in the Android app menu. As previously stated, the
GPIO output is configured in channel 0 (this line is multiplexed with the SCL line of the
I
2
C interface).
In the Android app: there is a bulb image at the left side of the screen. This image is
clickable. Pushing the bulb image sets the output session register of the NTAG and then
LED4 in the FRDM-KW41Z board should be turned on. When clicking on ‘Clear GPIO
output’ button, the value in the session register will be cleared and both LED4 in the
board and bulb image in the apps will turn off.
Configuration: Channel 0 has the possibility to configure the slew rate of the signal. The
slew rate is the speed a signal goes from high to low (and the opposite way). At a higher
slew rate, it is possible to have some noise or distortion in the signal. At the frequency
the NTAG is operating, there is not a large impact regarding noise or distortion in the
signal. So it is recommended to configure the tag with High speed in the slew rate.
In the FRDM-KW41Z: the PTC2 pin is configured as an input pin and will trigger an
interrupt at rising and falling edges of the pin. When there is a rising edge (i.e. the output
session register in the NTAG is set to 1), the LED 3 will be illuminating in the KW41Z
board. At a falling edge, the register will be set to 0 and the LED 3 will be turned off.
3.1.2.2 GPIO input
As previously stated for the GPIO output use case, it is necessary to flash the FRDM-
KW41Z board with the GPIO binary file. Also select the GPIO use case in the Android
app menu.
The GPIO input use case has the opposite behavior of the GPIO output. In this case, the
Channel 1 is configured as input (SDA line of the I
2
C interface). In the Android app, it
will be necessary to configure the PAD and slew rate; the possible configurations will be
explained later.
In the Android app: There is a button image at the left side of the screen. This button is
not clickable. This button represents the status of the SW3 button on the FRDM-KW41Z
board. Each time the SW3 button on the FRDM-KW41Z board is pushed, the session
register of the NTAG is set to 1 and then the button of the Android app will also be
displayed as pushed. On the other hand, when releasing the SW3 button in the FRDM-
KW41Z board, the session register is cleared and the Android app will release the button
of the image.
Configuration: Channel 1 has the possibility to configure the slew rate of the signal
(the same recommendation as in Section 4.2.1 applies here) and the PAD configuration.
Regarding the PAD configuration, there are four options. The first option ‘Receiver
disabled’ will disable the GPIO pin in the tag and the GPIO communication with the
FRDM-KW41Z board will not be possible so this configuration should only be used in
case the user wants to disable GPIO input communication. The configurations ‘Plain
input with weak pull-up’ and ‘Plain input with weak pull-down’ are used when no external
resistor is connected to the board and to avoid a floating pin. In case of having an
external resistor connected to the board, it is recommended to use the ‘Plain input’
configuration and avoid weak pull-up/pull-down.
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 9 / 41
In the FRDM-KW41Z: the PTC3 pin is configured as an output pin. Each time the SW3
button is pushed, the PTC3 pin will set the corresponding session register of the NTAG.
When SW3 button is released, the value of session register is cleared.
3.1.3 PWM use case
This use case aims to demonstrate the PWM generation capabilities of the NTAG 5.
PWM signals can be used to control electrical devices. In this case, the PWM generated
by the NTAG 5 will be used to control the brightness of two LEDs in the FRDM-KW41Z
board.
There are two different PWM lines available in the NTAG 5, as previously mentioned.
These PWM lines are multiplexed with the I
2
C and GPIO lines.
Before running this use case, it is necessary to flash the FRDM-KW41Z board with the
corresponding PWM binary file. In the Android app menu, the PWM use case option has
to be selected.
In the Android app: in this use case, the screen displays both PWM channels with the
same configuration options. As is shown in the sequence diagram in Figure 5, at first
it is necessary to configure the IC with GPIO/PWM use case. Once the tag is correctly
configured, it is possible to read the PWM configuration registers to check the existing
data. It is also possible to write these registers again to set new parameters to the PWM
channels.
The explanation of how the NTAG 5 configures a PWM signal can be found in section
8.3.4 in the product data sheet [Datasheet] and [Application Note].
In the FRDM-KW41Z: PTC2 and PTC3 pins are configured as PWM channel 0 and
channel 1 respectively. Both pins also have an interrupt to turn on/off LED3 and LED4
according to the input value of the corresponding pin.
A sequence diagram of the use case can be found in Figure 3.
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 10 / 41
aaa-033489
NTAG5 I
2
C Active
NFC ON
Select NTAG
ACK
Config tag as GPIO/PWM
(USE_CASE_CONFIG = 10b)
in TAG_CONFIG_1 (37h)
ACK
ACK
Read Configuration (A3h, A4h, A5h)
PWM Configuration
Write Configuration (A3h, A4h, A5h)
Send PWM signal (LED3 and LED4
brightness will change accordingly)
Android App KW41Z
Figure 3. PWM use case sequence diagram
3.1.4 Pass-Through mode use case
This use case aims to show the Pass-Through mode functionality of the NTAG 5. The
Pass-Through mode allows a faster data transfer between RF and I
2
C interfaces using
the 256-byte SRAM.
The Pass-Through mode allows data transfer in two directions: from RF to I
2
C interface
and from I
2
C to RF interface. The NTAG 5 IC has an arbitration mechanism; this arbiter
locks the interface that has to communicate with the tag according to the Pass-Through
direction and SRAM_DATA_READY register. This mode uses the Event Detection pin of
the NTAG 5 to detect SRAM events.
Since the SRAM is activated in this use case, it is mandatory to connect the board to the
Vcc power supply.
More information about Pass-Through mode can be found in sections 8.1.4.1, 8.1.5 and
8.4.5 of [link Datasheet, boost Datasheet].
The use case is started in the Android app by clicking the ‘Start Demo’ button in the
Pass-Through view.
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 11 / 41
The main functionality of this use case is to write the SRAM five times in a Pass-Through
direction, then configure it again to write five times in the opposite Pass-Through
direction and repeat this process until the ‘Stop Demo’ button is pushed in the Android
application.
The Pass-Through direction is automatically changed in the FRDM-KW41Z board each
time the Pass-Through mode has done five operations in the corresponding direction.
The default Pass-Through direction is RF->I
2
C. This direction is indicated with a blue
color in the LED4 in the FRDM-KW41Z board. When the tag is configured with I
2
C->RF
direction the LED4 will illuminate in green.
In the Android app: the usage of the Android app is straightforward in this use case. To
start using the demo, it is necessary to click the ‘Start Demo’ button in the Android view.
This will start writing in the RF->I
2
C direction; after a loop of five operations, the FRDM-
KW41Z board will toggle the direction to I
2
C->RF and the Android app will automatically
switch to this mode as well. The application will be looping between both Pass-Through
directions until the ‘Stop Demo’ button is clicked in the application.
Important: To run this use case correctly, it is necessary to connect the Event Detection
wire to the PTC17 pin in FRDM-KW41Z board.
3.1.4.1 RF→ I
2
C direction
This is the default direction of the Pass-Through mode for the FRDM-KW41Z board.
When the board is flashed with the corresponding binary file, a blue LED is turned on;
this blue LED indicates the Pass-Through direction.
At startup, the FRDM-KW41Z is waiting for a valid NFC connection. When the phone
taps the antenna, an event is triggered in the FRDM-KW41Z and the Pass-Through
configuration is written in the IC. In this direction, the SRAM is written via RF and read via
I
2
C.
When the tag is configured, the arbiter locks the RF interface. When the RF interface is
locked the SRAM can only be written via RF. When the last byte of the SRAM has been
written, the arbiter releases the RF interface and locks the I
2
C interface, then the data
can be read via I
2
C.
This use case is illustrated in Figure 4.
In the FRDM-KW41Z: The Pass-Through configuration sets the following data in
the TAG_CONFIG_1_REG: ARBITER_MODE = 10b, SRAM_MAPPING = 1b and
PT_TRANSFER_DIR = 1b. More information about the Pass-Through configuration can
be found in the product [link Datasheet, boost Datasheet].
In this Pass-Through direction, the FRDM-KW41Z board configures the
‘LAST_BYTE_WRITTEN_BY_RF’ event; this event is triggered when the last byte of the
SRAM has been written by RF. When this happens, the I
2
C interface is locked and the
SRAM_DATA_READY bit is set. This means that the SRAM is ready to be read via I
2
C.
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 12 / 41
aaa-033488
ED_CONFIG = 0001b
(NFC Field present)
SRAM_DATA_READY
== 0b? OK!!
SRAM_DATA_READY
== 0b?
NTAG5 I
2
C Active
VCC_SUPPLY_OK == 1?
NFC_FIELD_OK ==1?
Write TAG_CONFIG_REG byte 1:
ARBITER_MODE = 10b,
SRAM_MAPPING = 1b,
PT_TRANSFER_DIR = 1b,
ED_CONFIG_REG = 0100b
NFC ON
ED pin LOW
ED pin HIGH
ACK
I
2
C Read (2000h - 203Fh)
ED pin LOW
ED pin LOW
Read tag status (10A0h)
WRITE_SRAM (D3h)
ACK
READ_STATUS_REG (A0h)
Tag status response
READ_STATUS_REG (A0h)
Tag status response
Android App KW41Z
RF LOCKED = 1b
I
2
C LOCKED = 0b
SRAM_DATA_READY = 0b
RF LOCKED = 0b
I
2
C LOCKED = 1b
SRAM_DATA_READY = 1b
RF LOCKED = 1b
Figure 4. Pass-Through RF→ I
2
C direction diagram
3.1.4.2 I
2
C → RF direction
When this direction is set in the FRDM-KW41Z board, a green light is turned on in LED4.
This use case is illustrated in Figure 5.
In the FRDM-KW41Z: The Pass-Through configuration sets in the
TAG_CONFIG_1_REG the following data: ARBITER_MODE = 10b, SRAM_MAPPING
= 1b and PT_TRANSFER_DIR = 0b. More information about the Pass-Through
configuration can be found in the product [Data sheet] and [Application note].
In this case, the firmware configures the ‘LAST_BYTE_READ_BY_RF’ event; this event
is triggered when the last byte of the SRAM has been read by RF. When this happens,
the I
2
C interface is locked and the SRAM_DATA_READY bit is cleared. This means that
the SRAM is ready to be written via I
2
C.
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 13 / 41
aaa-033490
ED_CONFIG = 0001b
(NFC Field present)
SRAM_DATA_READY
== 1b? OK!!
SRAM_DATA_READY
== 1b?
NTAG5 I
2
C Active
VCC_SUPPLY_OK == 1?
NFC_FIELD_OK ==1?
Write TAG_CONFIG_REG byte 1:
ARBITER_MODE = 10b,
SRAM_MAPPING = 1b,
PT_TRANSFER_DIR = 0b,
ED_CONFIG_REG = 0011b
ED pin LOW
ED pin HIGH
ACK
I
2
C Write (2000h - 203Fh)
ED pin LOW
Read tag status (10A0h)
READ_SRAM (D2h)
SRAM data (256 bytes)
READ_STATUS_REG (A0h)
Tag status response
READ_STATUS_REG (A0h)
Tag status response
Android App KW41Z
RF LOCKED = 0b
I
2
C LOCKED = 1b
SRAM_DATA_READY = 0b
RF LOCKED = 1b
I
2
C LOCKED = 0b
SRAM_DATA_READY = 1b
NFC ON
Figure 5. Pass-Through I
2
C → RF direction diagram
3.1.5 ALM use case
The Active load Modulation use case is intended to show the capabilities of the NTAG
5 to change the ALM parameters through the FRDM-KW41Z and read the updated
configuration using the Android App. The parameters that can be configured are listed in
[Data sheet]. Figure 8 shows the diagram of this use case.
The configuration of ALM parameters is carried out using the Peek and Poke tool. Refer
to Section 6 for instructions on how to run the use case from this tool.
In Peek and Poke: Run the ALM use case and start by clicking the “Write configuration”
button. This will save the default values in the NTAG. Then, configure the parameters
using the text boxes and menus available and click on “Write Configuration” so the NTAG
can be configured.
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 14 / 41
In Android App: Go to the ALM use case menu and click on the “Read ALM
Configuration”. The parameters will update accordingly to what has been configured in
Peek and Poke.
You can use the “Read Configuration” button of the ALM menu in Peek and Poke to
check that the configuration read matches the one in the Android App.
aaa-033491
NTAG5 I
2
C Active
Select NTAG
ACK
Config tag as I
2
C slave
ACK
Read ALM configuration
ALM configuration
Write Bytes @ ADDR 0x1040
Android App KW41Z Peek and Poke
Write ALM configuration
NFC ON
Figure 6. ALM use case sequence diagram.
3.2 User guide – NTAG 5 configuration
The NTAG 5 is configured in a different way depending on the use case to be
demonstrated. All the different configurations can be found in Table 1.
Table 1. NTAG 5 – NTAG 5 configurations
Use case
Configuration
Bits 5 and 4 in
TAG_CONFIG_1
NDEF message I
2
C Slave 00b
GPIO GPIO/PWM 10b
PWM GPIO/PWM 10b
I
2
C Master channel I
2
C Master 01b
Pass-Through mode I
2
C Slave 00b
More information about the tag configuration is illustrated in section 8.1.3.13 of the
product data sheet [Datasheet].
The Android application includes several options in the action bar regarding the tag
configuration. This action bar menu can be observed in Figure 7. There is one option to
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 15 / 41
read the current configuration in the tag and also another three options to configure the
tag in I
2
C slave, I
2
C master and GPIO/PWM modes.
Every time the tag is configured in a different mode it is necessary to reset the IC so
that the configuration takes place. The tag can be reset by removing its actual power
source (RF field or wired connection) and then reconnected.
Figure 7. Android app - Tag configuration
3.3 User guide – NFC connection with board
Before using the application, it is necessary to activate the NFC capabilities in the
smartphone (it is mandatory to have NFC capabilities in the phone).
Once the NFC communication is activated in the phone, the first step is to tap the phone
to the NTAG 5 board. When the connection is correctly established, a pop-up will be
displayed at the bottom of the screen saying that the connection has been successful
and the NTAG 5 board is ready to be used.
More details about how to use each use case can be found in the corresponding use
case explanation in Section 3.1.
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 16 / 41
4 NTAG 5 – Use cases code snippets
4.1 General information and project structure
The main objective of this reference application is to clearly organize each use case to
ease code migration to other projects.
The Android Application has been created in Android Studio 3.0.1 with target SDK
version 27.
As mentioned above, it is structured in four separated modules. Each module is
developed in a separate Activity accessible from the main menu. In Figure 8, you can find
the project structure from Android Studio.
Figure 8. Android Studio project structure
The application has been designed following a layered structure: one layer for the NFC
communication (contained in BaseActivity class), another layer to operate with the action
bar (class BaseActionBarActivity) and finally the application logic and UI which are
contained in the different activities for each use case (PassThroughMode, GPIOActivity,
I
2
CMasterActivity and PWMActivity).
The class ‘RFCommand’ has been created in the package called ‘nfc’. This class
contains all the necessary RAW commands (following ISO/IEC 15693 spec) to
communicate with the tag. Also it has been necessary to develop a Parser class to get
and set all the tag parameters at a bit level. In the future, it is planned to have TapLinx
support for the NTAG 5. In the meantime, it is necessary to communicate with the tag by
using RAW commands.
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 17 / 41
4.1.1 BaseActivity
As previously stated, BaseActivity is in charge of managing the NFC communication. At
first, when the application is opened, it is necessary to check if the NFC is enabled in the
phone; otherwise, the application warns the user to turn it on.
The application is restricted to work with ISO/IEC 15693 ICs. Hence, in case another IC
type is read, it will detect that it is not a vicinity IC and the application will not be able to
operate. In Figure 8 you can check how the IC is detected and selected.
Figure 9. Tag detection in BaseActivity
As commented in the code snippet in Figure 9, ISO/IEC 15693 ICs can work in two
different modes: addressed and selected.
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 18 / 41
In the selected mode, it is necessary to first select the IC using the desired UID. Once the
IC is selected, it is not necessary to include the UID in the subsequent commands.
In the addressed mode, the IC is not selected at the beginning and each command has
to include the UID of the desired IC.
This Android application works in selected mode.
BaseActivity class contains just one method to communicate with the IC using the
transceive’ method from the NFC API in Android. You can see this method in Figure 10.
Calling the ‘transceive’ method will return the IC response to the command. This
response is stored and returned each time the ‘sendCommand’ method is called.
Figure 10. Send command method in BaseActivity
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 19 / 41
4.1.2 BaseActionBarActivity
This activity will extend from BaseActivity and will only take care of the action bar.
In this application, the action bar has several options to configure the tag. It can be
configured to the different use cases: I
2
C Slave, I
2
C Master and GPIO/PWM. It can also
retrieve the current configuration in case the user does not remember the configuration
that was previously set.
4.1.3 MainActivity
This activity is very simple; it will contain a menu view to navigate through the different
use cases. As this activity extends from BaseActionBarActivity (which extends from
BaseActivity) it will be the link between the UI and NFC communication. Therefore, all the
particular activities for each use case will extend from this activity to have the possibility
to send NFC commands and update the UI in a simple way.
Figure 11 shows a screenshot of the main menu.
Figure 11. Android App Main menu
NXP Semiconductors
RM00221
NTAG 5 - Android application development
RM00221 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
Reference manual Rev. 1.1 — 7 May 2020
COMPANY PUBLIC 531811 20 / 41
4.2 Use cases
4.2.1 I
2
C Master channel
The I
2
C Master Channel screen view is displayed in Figure 12. To use this feature, it is
necessary to configure the IC in I
2
C Master Mode. This configuration can be easily done
in the Android app by using the corresponding option in the Action bar.
Once the tag is correctly configured, there are two different ways to send I
2
C commands
to the tag: using a pre-defined command or writing a custom command. Each option will
be explained in a special section.
Figure 12. I
2
C Master Configuration view
4.2.1.1 I
2
C Master channel communication sequence
NTAG 5 has two commands to communicate in this mode: Write I
2
C and Read I
2
C.
These commands will be explored in more detail in section 8.2.4.9 in the product [Data
sheet].
The I
2
C Address of the FXOS8700CQ combo sensor is 0x1F. This information will be
needed to form the Write and Read I
2
C Commands in the application.
The I
2
C Master communication has to follow the sequence explained below:
1. Send Write I
2
C Command (D4h): in the ‘I
2
C param’ byte. It is necessary to set
the ‘Disable Stop condition’ because right after a write I
2
C command, a read I
2
C
command will be sent. Finally, the register to be read from the combo sensor (Section
14 in the FXOS8700CQ [Data sheet]) has to be included in the ‘Data’ byte. More
information about this command can be found in section 8.2.4.9.1 in the NTAG 5
[Data sheet].
  • Page 1 1
  • Page 2 2
  • Page 3 3
  • Page 4 4
  • Page 5 5
  • Page 6 6
  • Page 7 7
  • Page 8 8
  • Page 9 9
  • Page 10 10
  • Page 11 11
  • Page 12 12
  • Page 13 13
  • Page 14 14
  • Page 15 15
  • Page 16 16
  • Page 17 17
  • Page 18 18
  • Page 19 19
  • Page 20 20
  • Page 21 21
  • Page 22 22
  • Page 23 23
  • Page 24 24
  • Page 25 25
  • Page 26 26
  • Page 27 27
  • Page 28 28
  • Page 29 29
  • Page 30 30
  • Page 31 31
  • Page 32 32
  • Page 33 33
  • Page 34 34
  • Page 35 35
  • Page 36 36
  • Page 37 37
  • Page 38 38
  • Page 39 39
  • Page 40 40
  • Page 41 41

NXP NTAG® 5 switch Reference guide

Type
Reference guide
This manual is also suitable for

Ask a question and I''ll find the answer in the document

Finding information in a document is now easier with AI