PN7160 NXP-NCI MCUxpresso for VS Code Example Project for MCXA156
PN7160 NXP-NCI MCUxpresso for VS Code Example Project for MCXA156
Introduction
This document provides a guide on how to integrate the FRDM-MCXA156 as a host for the PN7160 using the examples provided in the “PN7160 NXP-NCI MCUXpresso Example Project” package. The hardware required to follow this guide is:
PN7160 NXP-NCI MCUXpresso Example Project version: 1.2
MCXN947 SDK version: 26.06
PN7160 version: 12.50.11.
Hardware connections.
When using OM27160B1 (SPI Host Interface):
The FRDM-MCXA156 schematic document is available on this page.
In the case of SPI connections, to use PN7160 directly with the Arduino headers a rework is needed for the FRDM because SDO(MOSI) and SS (Chip select) are not connected as default (as shown in the next figure). You should move R59 and R60 from pad 2 to pad 3 to enable these connections.
Note: You can connect the SPI pins available in Mikro bus header with jumpers, but in this example, the signals are routed through the pins enabled by the rework configuration.
Once clarified this, these are the pins used in this example.
Name
PORT
I2C0_SDA
P0_16
I2C0_SCL
P0_17
LPSPI1_SDI
P2_16
LPSPI1_SDO
P2_13
LPSPI1_SCK
P2_12
LPSPI1_SS
P2_6
IRQ
P1_15
VEN
P1_14
REQ
P3_16
Software Changes
This section describes the software changes required to run an “NXP-NCI2.0” example with the MCXA156, which consists in a detection loop that displays in a terminal information (like UID, SAK, and Product Type for MIFARE product-based cards) about any tag detected by the PN7160.
To begin the integration, we first need to import a hello_world project from the FRDM-MCXA156 SDK (v26.06.00) into MCUXpresso IDE for VS Code. For this purpose, download and install the FRDM-MCXA156 repository (version 26.06) using the extension available in the Quickstart panel by selecting Import Repository. For more information about this process, you can consult the corresponding guide.
Importing NCI2.0 examples
Download the “PN7160 NXP-NCI MCUXpresso Example Project” zip from the product page and extract in a known folder. This will be useful for later use.
Importing base project
1. In the Quick Start panel click on “Import Example from Repository” in VS code.
2. Select “FRDM-MCXA156” in board setting.
3. In the template will search for the “hello_world” example, select Freestanding Applications, chose the location and click on “import”.
Importing SDK drivers
Once the project is added to the workspace we will need to add the required drivers, which are the SPI driver in case the OM27160B1HN is being used, or the I2C driver if the OM27160A1HN is being used. For this we need to add the following code in the prj.cfg file.
Add the example source code to the newly created MCXA156 project
Delete the hello_world.c of the project files folder of the MCXA156 project. From the “NXP-NCI2.0_iMXRT1170_examples” extracted just drag and drop in the project files folder the following files and folders.
When you drag and drop a file into VS code a window will appear asking whether you want to link the file or copy it. Please select “Copy files.”
The project folder should look like this:
After dragging and dropping all the files, the CMakeLists.txt file is automatically updated to include all the copied .c files. An example of this is shown below:
However, .h files are not automatically linked, so they must be added manually. Please copy and paste the following includes into the CMakeLists.txt file:
mcux_add_macro(
CC "BOARD_NXPNCI_INTERFACE_I2C=1\
REMOVE_P2P_SUPPORT=1")
Note: The following sections are exemplified using the SPI interface (BOARD_NXPNCI_INTERFACE_SPI macro).
After making the modifications described below, the interface used by the example can be changed simply by setting the macro to BOARD_NXPNCI_INTERFACE_I2C.
Board definitions
In the board.h file we will add the following definitions in order to refer to the different peripherals and clocks to be used, you can find this file in the following path:
Code modifications for ports, pins and clocks initialization
In the file “hardware_init.c” in the board folder of the project, write the following function as shown, in order to add port and clock peripheral initializations.