nfc  2.1.0.0
Main Page

NFC click

NFC click is a mikroBUS™ add-on board with a versatile near field communications controller from NXP — the PN7120 IC. NFC devices are used in contactless payment systems, electronic ticketing, smartcards, but also in retail and advertising — inexpensive NFC tags can be embedded into packaging labels, flyers or posters.

click Product page


Click library

  • Author : Stefan Ilic
  • Date : Mar 2023.
  • Type : I2C type

Software Support

We provide a library for the NFC Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for NFC Click driver.

Standard key functions :

Example key functions :

Example Description

This is an example which demonstrates the usage of NFC Click board.

The demo application is composed of two sections :

Application Init

Initializes driver and logger, then performs hardware reset, puts the device in operating mode by

disabling standby mode, performs test procedure, and configures the device to start discovery.

void application_init ( void )
{
log_cfg_t log_cfg;
nfc_cfg_t nfc_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
nfc_cfg_setup( &nfc_cfg );
NFC_MAP_MIKROBUS( nfc_cfg, MIKROBUS_1 );
err_t init_flag = nfc_init( &nfc, &nfc_cfg );
if ( I2C_MASTER_ERROR == init_flag )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
log_printf( &logger, " HW Reset \r\n" );
nfc_hw_reset( &nfc );
Delay_ms ( 100 );
log_printf( &logger, "-----------------------\r\n" );
log_printf( &logger, " Reset and Init. Core \r\n" );
Delay_ms ( 100 );
Delay_ms ( 100 );
Delay_ms ( 100 );
Delay_ms ( 100 );
while ( nfc_check_irq( &nfc ) == NFC_IRQ_STATE_HIGH );
log_printf( &logger, "-----------------------\r\n" );
log_printf( &logger, " Disabling Standby Mode \r\n" );
Delay_ms ( 100 );
Delay_ms ( 100 );
log_printf( &logger, "-----------------------\r\n" );
log_printf( &logger, "Starting Test Procedure\r\n" );
Delay_ms ( 100 );
Delay_ms ( 100 );
nfc_hw_reset( &nfc );
Delay_ms ( 100 );
log_printf( &logger, "-----------------------\r\n" );
log_printf( &logger, " NFC Config. \r\n" );
log_printf( &logger, "-----------------------\r\n" );
log_printf( &logger, " Discovery Start \r\n" );
Delay_ms ( 100 );
Delay_ms ( 100 );
log_printf( &logger, "-----------------------\r\n" );
log_printf( &logger, "-------- START --------\r\n" );
log_printf( &logger, "-----------------------\r\n" );
Delay_ms ( 500 );
log_info( &logger, " Application Task " );
}

Application Task

NFC Click board can be used for detection of RFiD tag

and displays it's value via USART terminal. All data logs write on USB uart changes for every 1 sec.

void application_task ( void )
{
while ( nfc_check_irq( &nfc ) == NFC_IRQ_STATE_HIGH )
{
}
while ( nfc_check_irq( &nfc ) == NFC_IRQ_STATE_LOW );
log_printf( &logger, "-----------------------\r\n" );
Delay_ms ( 1000 );
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.NFC

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


nfc_default_cfg
void nfc_default_cfg(nfc_t *ctx, control_packet_t *ctrl_pck)
NFC default configuration function.
ctrl_pck_data
control_packet_t ctrl_pck_data
Definition: main.c:37
nfc_check_irq
uint8_t nfc_check_irq(nfc_t *ctx)
Check IRQ ststus function.
nfc_hw_reset
void nfc_hw_reset(nfc_t *ctx)
HW reset function.
nfc_cfg_setup
void nfc_cfg_setup(nfc_cfg_t *cfg)
NFC configuration object setup function.
nfc_test_antenna
void nfc_test_antenna(nfc_t *ctx, control_packet_t *ctrl_pck)
NFC test antena function.
Definition: main.c:276
display_packet
void display_packet(control_packet_t *ctrl_pck)
NFC display packet function.
Definition: main.c:194
application_task
void application_task(void)
Definition: main.c:164
nfc_read_nfc_data
void nfc_read_nfc_data(nfc_t *ctx, control_packet_t *ctrl_pck)
NFC read nfc data function.
Definition: main.c:241
nfc_read_ctrl_packet_data
void nfc_read_ctrl_packet_data(nfc_t *ctx, control_packet_t *ctrl_pck)
Read control packet data function.
NFC_MAP_MIKROBUS
#define NFC_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: nfc.h:258
nfc_cmd_core_reset
void nfc_cmd_core_reset(nfc_t *ctx)
Core reset command function.
nfc_get_data
uint8_t nfc_get_data(nfc_t *ctx, uint8_t *p_rx_data)
Get data function.
nfc_init
err_t nfc_init(nfc_t *ctx, nfc_cfg_t *cfg)
NFC initialization function.
nfc_cmd_start_discovery
void nfc_cmd_start_discovery(nfc_t *ctx)
Start discovery command function.
NFC_IRQ_STATE_HIGH
#define NFC_IRQ_STATE_HIGH
Definition: nfc.h:202
nfc_cmd_test_procedure
void nfc_cmd_test_procedure(nfc_t *ctx)
NFC test procedure command function.
NFC_IRQ_STATE_LOW
#define NFC_IRQ_STATE_LOW
NFC IRQ state.
Definition: nfc.h:201
nfc_t
NFC Click context object.
Definition: nfc.h:272
nfc_cmd_disable_standby_mode
void nfc_cmd_disable_standby_mode(nfc_t *ctx)
Disable standby mode command function.
application_init
void application_init(void)
Definition: main.c:69
nfc_cfg_t
NFC Click configuration object.
Definition: nfc.h:292
nfc_cmd_core_init
void nfc_cmd_core_init(nfc_t *ctx)
Core init command function.