nfc5  2.1.0.0
Main Page

NFC 5 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Stefan Filipovic
  • Date : Nov 2023.
  • Type : I2C/SPI type

Software Support

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

Standard key functions :

Example key functions :

  • nfc5_get_mifare_tag_uid This function reads the UID of a mifare tag.
    err_t nfc5_get_mifare_tag_uid ( nfc5_t *ctx, uint8_t *uid, uint8_t *uid_len );
  • nfc5_write_reg This function writes a desired data to the selected register.
    err_t nfc5_write_reg ( nfc5_t *ctx, uint8_t reg, uint8_t data_in );
  • nfc5_read_reg This function reads a desired data from the selected register.
    err_t nfc5_read_reg ( nfc5_t *ctx, uint8_t reg, uint8_t *data_out );

Example Description

This example demonstrates the use of NFC 4 Click board by reading MIFARE ISO/IEC 14443 type A tag UID.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
nfc5_cfg_t nfc5_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
nfc5_cfg_setup( &nfc5_cfg );
NFC5_MAP_MIKROBUS( nfc5_cfg, MIKROBUS_1 );
err_t init_flag = nfc5_init( &nfc5, &nfc5_cfg );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( NFC5_ERROR == nfc5_default_cfg ( &nfc5 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

If there's a tag detected, it reads its UID and displays it on the USB UART every 500ms.

void application_task ( void )
{
uint8_t tag_uid[ NFC5_NFCA_CASCADE_3_UID_LEN ] = { 0 };
uint8_t tag_uid_len = 0;
if ( NFC5_OK == nfc5_get_mifare_tag_uid( &nfc5, tag_uid, &tag_uid_len ) )
{
log_printf( &logger, " TAG UID: " );
for ( uint8_t cnt = 0; cnt < tag_uid_len; cnt++ )
{
log_printf( &logger, "0x%.2X ", ( uint16_t ) tag_uid[ cnt ] );
}
log_printf( &logger, "\r\n----------------------------------\r\n" );
Delay_ms( 500 );
}
}

Note

Only ISO14443-A type tags are compatible with this example.

We recommend MIKROE-1475 - an RFiD tag 13.56MHz compliant with ISO14443-A standard.

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.NFC5

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.


nfc5_cfg_t
NFC 5 Click configuration object.
Definition: nfc5.h:1123
nfc5_init
err_t nfc5_init(nfc5_t *ctx, nfc5_cfg_t *cfg)
NFC 5 initialization function.
NFC5_NFCA_CASCADE_3_UID_LEN
#define NFC5_NFCA_CASCADE_3_UID_LEN
Definition: nfc5.h:365
nfc5_default_cfg
err_t nfc5_default_cfg(nfc5_t *ctx)
NFC 5 default configuration function.
NFC5_ERROR
@ NFC5_ERROR
Definition: nfc5.h:1150
application_task
void application_task(void)
Definition: main.c:69
NFC5_MAP_MIKROBUS
#define NFC5_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: nfc5.h:812
nfc5_write_reg
err_t nfc5_write_reg(nfc5_t *ctx, uint8_t reg, uint8_t data_in)
NFC 5 write register function.
nfc5_s
NFC 5 Click context object.
Definition: nfc5.h:1097
NFC5_OK
@ NFC5_OK
Definition: nfc5.h:1149
nfc5_cfg_setup
void nfc5_cfg_setup(nfc5_cfg_t *cfg)
NFC 5 configuration object setup function.
nfc5_get_mifare_tag_uid
err_t nfc5_get_mifare_tag_uid(nfc5_t *ctx, uint8_t *uid, uint8_t *uid_len)
NFC 5 get mifare tag UID function.
application_init
void application_init(void)
Definition: main.c:32
nfc5_read_reg
err_t nfc5_read_reg(nfc5_t *ctx, uint8_t reg, uint8_t *data_out)
NFC 5 read register function.