nfc2  2.0.0.0
Main Page

NFC 2 Click

NFC 2 Click is a compact add-on board that contains a highly integrated NFC transceiver for contactless communication. This board features the PN7150, the best plug&play high-performance full NFC solution with integrated firmware and NCI interface designed for contactless communication at 13.56 MHz from NXP USA Inc.

Click Product page


Click library

  • Author : Stefan Ilic
  • Date : Aug 2021.
  • Type : I2C type

Software Support

We provide a library for the NFC2 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 NFC2 Click driver.

Standard key functions :

Example key functions :

Example Description

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

The demo application is composed of two sections :

Application Init

Initialization driver enables - I2C, hw reset, reseteting and initialize core, disabling standby mode, starting test procedure, set configuration and start discovery, also write log.

void application_init ( void ) {
log_cfg_t log_cfg;
nfc2_cfg_t nfc2_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
nfc2_cfg_setup( &nfc2_cfg );
NFC2_MAP_MIKROBUS( nfc2_cfg, MIKROBUS_1 );
err_t init_flag = nfc2_init( &nfc2, &nfc2_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" );
nfc2_hw_reset( &nfc2 );
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 ( nfc2_check_irq( &nfc2 ) == NFC2_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 );
nfc2_hw_reset( &nfc2 );
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 2 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 ( nfc2_check_irq( &nfc2 ) == NFC2_IRQ_STATE_HIGH ) {
}
while ( nfc2_check_irq( &nfc2 ) == NFC2_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.NFC2

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.


nfc2_test_antenna
void nfc2_test_antenna(nfc2_t *ctx, control_packet_t *ctrl_pck)
NFC 2 test antena function.
Definition: main.c:248
ctrl_pck_data
control_packet_t ctrl_pck_data
Definition: main.c:38
nfc2_cfg_setup
void nfc2_cfg_setup(nfc2_cfg_t *cfg)
NFC 2 configuration object setup function.
nfc2_cmd_card_disconnected
void nfc2_cmd_card_disconnected(nfc2_t *ctx)
Card disconnected command function.
NFC2_MAP_MIKROBUS
#define NFC2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: nfc2.h:260
nfc2_cfg_t
NFC 2 Click configuration object.
Definition: nfc2.h:294
nfc2_init
err_t nfc2_init(nfc2_t *ctx, nfc2_cfg_t *cfg)
NFC 2 initialization function.
nfc2_cmd_core_init
void nfc2_cmd_core_init(nfc2_t *ctx)
Core init command function.
nfc2_cmd_test_procedure
void nfc2_cmd_test_procedure(nfc2_t *ctx)
NFC test procedure command function.
nfc2_cmd_core_reset
void nfc2_cmd_core_reset(nfc2_t *ctx)
Core reset command function.
display_packet
void display_packet(control_packet_t *ctrl_pck)
NFC 2 display packet function.
Definition: main.c:185
nfc2_read_nfc_data
void nfc2_read_nfc_data(nfc2_t *ctx, control_packet_t *ctrl_pck)
NFC 2 read nfc data function.
Definition: main.c:215
NFC2_IRQ_STATE_LOW
#define NFC2_IRQ_STATE_LOW
NFC 2 IRQ state.
Definition: nfc2.h:201
nfc2_t
NFC 2 Click context object.
Definition: nfc2.h:274
application_task
void application_task(void)
Definition: main.c:157
nfc2_check_irq
uint8_t nfc2_check_irq(nfc2_t *ctx)
Check IRQ ststus function.
nfc2_default_cfg
void nfc2_default_cfg(nfc2_t *ctx, control_packet_t *ctrl_pck)
NFC 2 default configuration function.
nfc2_cmd_disable_standby_mode
void nfc2_cmd_disable_standby_mode(nfc2_t *ctx)
Disable standby mode command function.
nfc2_cmd_start_discovery
void nfc2_cmd_start_discovery(nfc2_t *ctx)
Start discovery command function.
application_init
void application_init(void)
Definition: main.c:64
nfc2_core_set_protocol_config
void nfc2_core_set_protocol_config(nfc2_t *ctx)
Set protocol configuration function.
nfc2_read_ctrl_packet_data
void nfc2_read_ctrl_packet_data(nfc2_t *ctx, control_packet_t *ctrl_pck)
Read control packet data function.
NFC2_IRQ_STATE_HIGH
#define NFC2_IRQ_STATE_HIGH
Definition: nfc2.h:202
nfc2_hw_reset
void nfc2_hw_reset(nfc2_t *ctx)
HW reset function.