NFC Reader Library Porting FRDM_K64F

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

NFC Reader Library Porting FRDM_K64F

NFC Reader Library Porting FRDM_K64F

The NFC Reader Library is a complete software support library for NFC Frontend ICs. Designed to give developers a faster and simpler way to deliver NFC-enabled products. This multi-layer library, written in C, makes it easy to create NFC based applications.

The NFC Reader Library includes a package for K82F. This package can be download from this page. The version used is 05.22.01 - NFC Reader Library for FRDM F82K

HW Changes

The CLEV6630B board has the CLRC663 connected with LPC1760 MCU via SPI. The design of the CLEV6630B makes it very easy to use another MCU, which is what we need to do.

To have direct access from FRDM_K64F to CLRC663, this change is needed: the six resistors marked by red squares need to be removed to obtain proper decoupling of the LPC1769 MCU from the CLEV6630B board.

pastedImage_3.png

Connecting FRDM_K64F to CLEV6630B

These are the connections required for this porting:

FRDM_K64F pinConnectionCLEV6630B pin
J2-8 / PTD2MOSIMOSI
J2-10 / PTD3MISOMISO
J2-12 / PTD1SCKSCK
J2-6 / PTD0SSELSSEL
J1-2 / PTC16IFSEL0IF0
J1-4 / PTC17IFSEL1IF1
J1-11 / PTC0IRQIRQ
J1-5 / PTC1RESETCLRC_NRST
J2-14 / GNDGNDGND

pastedImage_1.png

Import into MCUXpresso

  • In the Quickstart Panel, click on Import project(s) from file system…
  • Browse the project archive (zip) from your file system.

pastedImage_4.png

  • Click Next to select the projects needed (In this example, is just imported the Basic Discovery Loop example).

pastedImage_5.png

  • Click on Finish to import the selected ones.

The imported projects will appear in the Project Explorer of the workspace.

pastedImage_6.png

SW Changes (FRDM_K64F)

Download and install the K64F SDK from the SDK Builder.

Import the hello_world_demo_apps example

  • Click on Import SDK example(s)...
  • Select the frdmk64f.

pastedImage_13.png

  • Import the hello_world example and click on Finish.

pastedImage_15.png

  • Then we rename the project to frdm_k64f_basic_discovery_loop.

pastedImage_17.png

Over this project we are going to apply the changes

pastedImage_21.png


Add the source code Basic Discovery Loop Example

Copy the NfcrdlibEx1_BasicDiscoveryLoop.c to our K64 project.

pastedImage_24.pngpastedImage_29.png

Also copy from the src folder the phApp_Init.c file from NfcrdlibEx1_BasicDiscoveryLoop to frdm_k64f_basic_discovery_loop source folder.

Link the NFC Reader Library

We add the DAL, NxpNfcRdLib, phOsal and intfs folders from NfcrdlibEx1_BasicDiscoveryLoop project to thefrdm_k64f_basic_discovery_loop project.

  • Right click on the frdm_k64f_basic_discovery_loop project, click on New>Folder:
  • Click on Advanced, and select Link to alternate location (Link Folder).

pastedImage_35.png

  • Click on Browse… browse to your workspace and choose the NxpNfcRdLib folder.

pastedImage_37.png

  • Click on Finish.

The same procedure has to be done with the DAL, phOsal and intfs folders.

The project should appear with the following structure:

pastedImage_33.png

Define FRDM_K64F SDK preprocessor symbols

We need to change the compiler preprocessor configuration.

  • Right click on the frdm_k64f_basic_discovery_loop Project.
  • Click on Properties..
  • Go to C/C++ Build>Settings>Tool Settings>MCU C Compiler>Preprocessor

The actual symbols are related with the board, but we need to add the related with the Reader Library.

pastedImage_43.png

  • These are the symbols we need to add:
    • PHDRIVER_FRDM_K64FRC663_BOARD
    • PH_OSAL_NULLOS
    • NXPBUILD_CUSTOMER_HEADER_INCLUDED

  • Then click on Apply and Close, and Yes.

pastedImage_47.png

Add include paths

After that we add the paths of the folders we recently linked:

  • Right click on the frdm_k64f_basic_discovery_loop Project.
  • Click on Properties..
  • Go to C/C++ Build>Settings>Tool Settings>MCU C Compiler>Includes

pastedImage_1.png

The Include paths should be listed like this:

pastedImage_52.png

Add folder to Source Location

Then we add the root folder to the Path and Symbols:

  • Right click on the frdm_k64f_basic_discovery_loop Project.
  • Click on Properties..
  • Go to C/C++ General>Path and Symbols>Source Location

pastedImage_55.png

Files Modifications

phDriver_KinetisSDK.c

We need to change some lines in the DAL>KinetisSDK>phDriver_KinetisSDK.c file:

pastedImage_59.png

GPIO_PortClearInterruptFlags((GPIO_Type *)pGpiosBaseAddr[bPortGpio], bPinNum);‍‍‍‍‍‍‍‍‍‍

pastedImage_61.png

bValue = (uint8_t)((GPIO_PortGetInterruptFlags((GPIO_Type *)pGpiosBaseAddr[bGpioNum]) >> bPinNum) & 0x01);

bValue = (uint8_t)GPIO_PinRead((GPIO_Type *)pGpiosBaseAddr[bGpioNum], bPinNum);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

pastedImage_63.png

GPIO_PinWrite((GPIO_Type *)pGpiosBaseAddr[bGpioNum], bPinNum, bValue);‍‍‍‍‍‍‍‍‍‍

pastedImage_65.png

GPIO_PortClearInterruptFlags((GPIO_Type *)pGpiosBaseAddr[bGpioNum], (1<<bPinNum));‍‍‍‍‍‍‍‍‍‍

These changes are related to the names of the functions in our SDK version (2.7.0).

We can erase the Linux, LPCOpen and PN74xxxx folders, we don’t need them for this migration. frdm_k64f_basic_discovery_loop>DAL>src

pastedImage_1.png

Also, to avoid multiple definitions issues, we erase the phOsal>src>NullOS>portalble>psOsal_Port_CM3.c file.

pastedImage_3.png

Board_FRDM_K64FRc663.h

The architecture of the NFC Reader Library makes it very simple to be able to use other MCU’s, since you only need to adapt the configuration of the peripheral drivers. To do this, there are some changes required in the DAL (Driver Abstraction Layer) of the Reader Library.


In frdm_k64f_basic_discovery_loop>DAL>boards folder, are some header files with the information of different MCU’s and Readers. We need to add our header file: Board_FRDM_K64FRc663.h


We can copy the Board_FRDM_K82FRc663.h, rename and make the needed modifications.

pastedImage_7.png

pastedImage_8.png

pastedImage_9.png

pastedImage_10.png

BoardSelection.h

Then we add the K64 option to the BoardSelection.h header.

pastedImage_16.png

#ifdef PHDRIVER_FRDM_K64FRC663_BOARD
# include <Board_FRDM_K64FRc663.h>
#endif‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


ph_NxpBuild_App.h

pastedImage_20.png

#if defined(PHDRIVER_LPC1769RC663_BOARD) \
 || defined(PHDRIVER_FRDM_K82FRC663_BOARD) \
 || defined(PHDRIVER_FRDM_K64FRC663_BOARD)
# define NXPBUILD__PHHAL_HW_RC663
#endif‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

phApp_Init.h

pastedImage_24.png

/* Check for K64 controller based boards. */
#if defined(PHDRIVER_FRDM_K64FRC663_BOARD)
#define PHDRIVER_KINETIS_K64
#endif‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

pastedImage_30.png

#ifdef PHDRIVER_KINETIS_K64
# include <fsl_debug_console.h>
# include <stdio.h>
#endif

 #ifdef DEBUG
 #if defined(PHDRIVER_KINETIS_K82) || defined (PHDRIVER_KINETIS_K64)
 #if SDK_DEBUGCONSOLE==1
 #define DEBUG_PRINTF DbgConsole_Printf
 #else
 #define DEBUG_PRINTF(...) printf(__VA_ARGS__);
 #endif
 #else /* PHDRIVER_KINETIS_K82 */
 #include <stdio.h>
 #define DEBUG_PRINTF(...) printf(__VA_ARGS__); fflush(stdout)
 #endif /* PHDRIVER_KINETIS_K82 */
#else /* DEBUG */
 #define DEBUG_PRINTF(...)
#endif /* DEBUG */‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

phApp_Init.c

Also we to add the FRDM_K64F CPU initialization in phApp_Init.c:

pastedImage_33.png

#ifdef PHDRIVER_KINETIS_K64
#include <fsl_port.h>
#include <fsl_pit.h>
#ifdef DEBUG
#include <fsl_clock.h>
#endif
#endif /* PHDRIVER_KINETIS_K64 */‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

pastedImage_34.png

#ifdef PHDRIVER_KINETIS_K64
static void phApp_K64_Init(void);
#endif /* PHDRIVER_KINETIS_K64 */‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

pastedImage_35.png

#ifdef PHDRIVER_KINETIS_K64
static void phApp_K64_Init(void)
{

 pit_config_t pitConfig;
 BOARD_BootClockRUN();
 SystemCoreClockUpdate();
 PIT_GetDefaultConfig(&pitConfig);
 PIT_Init(PIT, &pitConfig);
 BOARD_InitPins();
}
#endif /* PHDRIVER_KINETIS_K64 */‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

pastedImage_36.png

#elif defined(PHDRIVER_KINETIS_K64)
 phApp_K64_Init();‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

K64 Drivers

The hello_world example does not use SPI and PIT drivers, we need to add these drivers to our project:

  • Right click on the frdm_k64f_basic_discovery_loop Project.
  • Click on SDK Management>Manage SDK Components

pastedImage_1.png

  • And we add the dspi and pit drivers:

pastedImage_4.png

Demonstration

With all these changes, now we can run the Basic Discovery Loop with the FRDM_K64F and the CLRC663.

pastedImage_8.png

pastedImage_9.png

No ratings
Version history
Last update:
‎09-10-2020 02:37 AM
Updated by: