nfctag5  2.0.0.0
Main Page

NFC Tag 5 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Stefan Filipovic
  • Date : Jun 2022.
  • Type : I2C type

Software Support

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

Standard key functions :

Example key functions :

  • nfctag5_write_ndef_uri_record This function writes specific NDEF URI record to the memory address specified with NTAG5LINK_NDEF_MESSAGE_START_ADDRESS macro.
    err_t nfctag5_write_ndef_uri_record ( nfctag5_t *ctx, uint8_t uri_prefix, uint8_t *uri_data, uint8_t data_len );
  • nfctag5_write_message_to_memory This function writes specified number of data bytes to the user memory starting from block_addr.
    err_t nfctag5_write_message_to_memory ( nfctag5_t *ctx, uint16_t block_addr, uint8_t *message, uint16_t message_len );
  • nfctag5_read_message_from_memory This function reads specified number of data bytes from the user memory starting from block_addr.
    err_t nfctag5_read_message_from_memory ( nfctag5_t *ctx, uint16_t block_addr, uint8_t *message, uint16_t message_len );

Example Description

This example demonstrates the use of NFC Tag 5 click board by programming the specified NDEF URI record to the memory, and showing the memory read/write feature.

The demo application is composed of two sections :

Application Init

Initializes the driver and logger and performs the click default configuration which formats its user memory. After that it programs the specified NDEF URI record to the memory.

void application_init ( void )
{
log_cfg_t log_cfg;
nfctag5_cfg_t nfctag5_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
nfctag5_cfg_setup( &nfctag5_cfg );
NFCTAG5_MAP_MIKROBUS( nfctag5_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == nfctag5_init( &nfctag5, &nfctag5_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( NFCTAG5_ERROR == nfctag5_default_cfg ( &nfctag5 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
URI_DATA, strlen ( URI_DATA ) ) )
{
log_printf( &logger, " NDEF URI record \"https://%s\" has been written\r\n", ( char * ) URI_DATA );
}
log_info( &logger, " Application Task " );
}

Application Task

Writes a desired number of data bytes to the memory and verifies that it is written correctly by reading from the same memory location and displaying the memory content

on the USB UART approximately every 5 seconds.

void application_task ( void )
{
uint8_t message_buf[ 100 ] = { 0 };
strlen ( TEXT_MESSAGE ) ) )
{
log_printf( &logger, " \"%s\" has been written to memory address 0x%.4X \r\n",
( char * ) TEXT_MESSAGE, ( uint16_t ) TEXT_MESSAGE_ADDRESS );
}
message_buf,
strlen ( TEXT_MESSAGE ) ) )
{
log_printf( &logger, " \"%s\" has been read from memory address 0x%.4X \r\n\n",
message_buf, ( uint16_t ) TEXT_MESSAGE_ADDRESS );
}
Delay_ms( 5000 );
}

Note

Trying to write/read in RF mode (for example, processing NDEF URI record with a smartphone) while writing to memory over I2C is in progress can interrupt and block the I2C communication.

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

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.


NFCTAG5_ERROR
@ NFCTAG5_ERROR
Definition: nfctag5.h:265
NFCTAG5_OK
@ NFCTAG5_OK
Definition: nfctag5.h:264
nfctag5_write_ndef_uri_record
err_t nfctag5_write_ndef_uri_record(nfctag5_t *ctx, uint8_t uri_prefix, uint8_t *uri_data, uint8_t data_len)
NFC Tag 5 write NDEF URI record function.
nfctag5_read_message_from_memory
err_t nfctag5_read_message_from_memory(nfctag5_t *ctx, uint16_t block_addr, uint8_t *message, uint16_t message_len)
NFC Tag 5 read message from memory function.
NFCTAG5_URI_PREFIX_4
#define NFCTAG5_URI_PREFIX_4
Definition: nfctag5.h:121
nfctag5_cfg_setup
void nfctag5_cfg_setup(nfctag5_cfg_t *cfg)
NFC Tag 5 configuration object setup function.
nfctag5_write_message_to_memory
err_t nfctag5_write_message_to_memory(nfctag5_t *ctx, uint16_t block_addr, uint8_t *message, uint16_t message_len)
NFC Tag 5 write message to memory function.
URI_DATA
#define URI_DATA
Definition: main.c:35
application_task
void application_task(void)
Definition: main.c:94
nfctag5_t
NFC Tag 5 Click context object.
Definition: nfctag5.h:226
nfctag5_init
err_t nfctag5_init(nfctag5_t *ctx, nfctag5_cfg_t *cfg)
NFC Tag 5 initialization function.
nfctag5_default_cfg
err_t nfctag5_default_cfg(nfctag5_t *ctx)
NFC Tag 5 default configuration function.
nfctag5_cfg_t
NFC Tag 5 Click configuration object.
Definition: nfctag5.h:244
TEXT_MESSAGE
#define TEXT_MESSAGE
Definition: main.c:47
NFCTAG5_MAP_MIKROBUS
#define NFCTAG5_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: nfctag5.h:202
application_init
void application_init(void)
Definition: main.c:52
TEXT_MESSAGE_ADDRESS
#define TEXT_MESSAGE_ADDRESS
Definition: main.c:42