2- In the file gpio_pins.h add 2 extra elements to the gpio enumeration. Also add extern declarations for the 2 pins defined in the previous step.
NOTE:In this example the selected pins are PTB16 as IRQ and PTB17 as VEN. The pins depend on your routing from the Kinetis MCU to the NFC Controller board.
kGpioLED1 =GPIO_MAKE_PIN(GPIOD_IDX,5),/* FRDM-KL43Z RBG LED Green LED */
kGpioLED2 =GPIO_MAKE_PIN(GPIOE_IDX,31),/* FRDM-KL43Z RBG LED Red LED */
kGpioSW1 =GPIO_MAKE_PIN(GPIOA_IDX,4),/* FRDM-KL43Z SW1 */
kGpioSW3 =GPIO_MAKE_PIN(GPIOC_IDX,3),/* FRDM-KL43Z SW3 */
kGpioNFCCirq =GPIO_MAKE_PIN(GPIOB_IDX,16),/* GPIO for NFCC IRQ pin */
kGpioNFCCven =GPIO_MAKE_PIN(GPIOB_IDX,17),/* GPIO for NFCC VEN pin */};extern gpio_input_pin_user_config_t NFCCirqPin;extern gpio_output_pin_user_config_t NFCCvenPin;
3- In the file pin_mux.c define a function to configure the MUX setting of the required GPIO and I2C pins to interface with the NFC controller.
NOTE:The configured pins must correspond to the routing from the Kinetis MCU to the NFC controller board. In this case PTB16/PTB17 are set as GPIOs while PTE0/PTE1 are configured for I2C functionality. For I2C pins also check the MUX number in the device's Reference Manual (e.g. PTE0/PTE1 in KL43 have the I2C function in ALT6.
4- Add the prototype of the function to header file pin_mux.h.
** Method : configure_nfcc_pins
** Set mux configuration for I2C and GPIO pins
** to interface with the NFC Controller.
5- Add the NfcLibrary and TML folders with all its subfolders and files to your project's tree, so the library is part of the build. Also add the include paths to your compiler for the inc folders. Below an example with Kinetis Design Studio:
- Now the project is ready to use the NFC controller library. The library uses the next conditional compilation macros, add or remove these symbols from the compiler's preprocessor settings as required:
CARDEMU_SUPPORT: The NFC Controller host (MCU) emulates a contactless card which can be accessed by an external Reader/Writter.
P2P_SUPPORT: The host MCU can establish a 2-way communication accesing to or sending information to an external Reader/Writter.
RW_SUPPORT: With this mode the host can access a remote contactless tag/card via the NFC Controller.
NCI_DEBUG: If defined, all information transfered between the host MCU and the NFC Controller Interface (commands, responses, notifications, data) is echoed to console for debug purposes.
The attached project is based on the application note AN11658 NXP-NCI NullOS integration example. So you can refer to the appnote for detailed information.
The project was developed with the next software versions:
- KSDK v1.3
- KDS v3.0.0
-The KSDK platform library for the KL43 must be built before the example project. Otherwise the build fails due to library file missing (libksdk_platform.a).
- Once the example project is imported please verify that the build variable PROJECT_KSDK_PATH is pointing to your KSDK v1.3 installation path.
- For the NFC part, I used the NFC Controller board from the OM5577, which is a demonstration kit for the PN7120 NFC controller Interface chip.
- To interface with the NFC Contoller I used a FRDM-KL43Z Freedom board.
How to use the demo
- Placing a tag with a single text, URI or vCard NDEF record next to the NFC reader. Examples:
- Bring an android phone with NFC enabled close to the NFC controller antenna and use the "beaming" feature. In the case below the NXP home page is "beamed" from the adroid phone's explorer:
CARD EMULATION mode
For this mode it is required to remove the P2P_SUPPORT macro and rebuild/reprogram the project.
- Bringing an android phone set to read a NFC tag close to the NFC controller board:
I hope you like this document. Any questions or doubts please let me know in the comments.