X_NUCLEO_NFC02A1 library for M24LR

Dependencies:   ST_INTERFACES

Dependents:   HelloWorld_NFC02A1_mbedOS HelloWorld_NFC02A1laatste HelloWorld_NFC02A1

Fork of X_NUCLEO_NFC02A1 by ST Expansion SW Team

X-NUCLEO-NFC02A1 Dynamic NFC Tag Expansion Board Firmware Package

Introduction

This firmware package includes Components Device Drivers, Board Support Package and example applications for STMicroelectronics X-NUCLEO-NFC02A1 Dynamic NFC Tag Expansion Board based on M24LR.

Firmware Library

Class X_NUCLEO_NFC02A1 is intended to represent the Dynamic NFC Tag Expansion Board with the same name.
It provides an API to access to the M24LR component and to the three onboard LEDs.
It is intentionally implemented as a singleton because only one X_NUCLEO_NFC02A1 at a time might be deployed in a HW component stack.
The library also provides an implementation of the NDEF library API for M24LR, providing an simple way to read/write NDEF formatted messages from/to the M24LR dynamic NFC tag.

Example application

Hello World is a simple application to program and read an URI from the NFC tag.

Revision:
8:7c4cf671960b
Parent:
7:b876cdcf095a
--- a/m24lr/M24LR.cpp	Tue Jul 11 15:23:56 2017 +0000
+++ b/m24lr/M24LR.cpp	Wed Jul 12 12:34:12 2017 +0000
@@ -35,28 +35,25 @@
   ******************************************************************************
   */
 
-
-
 #include "M24LR.h"
 
 uint8_t M24LR::NfctagInitialized = 0; 
 
-
 /**
-  * @brief  This function activate Energy Harvesting mode
+  * @brief  Activate Energy Harvesting mode.
   */
 void M24LR::enable_energy_harvesting( void )
 {
   /* Initialise M24LR Board */
   
-    /* Enable Energy Harvesting */
-    i2c_set_EH( );
+  /* Enable Energy Harvesting */
+  i2c_set_EH( );
 
-    /* Store configuration in non Volatile Memory */
-    i2c_enable_EH_mode();
-    i2c_write_EH_cfg( M24LR_EH_Cfg_6MA );
-  
+  /* Store configuration in non Volatile Memory */
+  i2c_enable_EH_mode();
+  i2c_write_EH_cfg( M24LR_EH_Cfg_6MA );
 }
+
 /**
   * @brief  Set M24LR nfctag Initialization
   * @param  None
@@ -66,28 +63,22 @@
 { 
   uint8_t nfctag_id = 0;
   
-  if( NfctagInitialized == 0 )
-  {
-    
+  if ( NfctagInitialized == 0 ) {
     /* M24LR Init */
-   if( i2c_init() != NFCTAG_OK )
-    {
+    if ( i2c_init() != NFCTAG_OK ) {
       return NFCTAG_ERROR;
     }
-    
+      
     /* Check M24LR driver ID */
-   i2c_read_id(&nfctag_id);
-    if( (nfctag_id == I_AM_M24LR04) || (nfctag_id == I_AM_M24LR16) || (nfctag_id == I_AM_M24LR64) )
-    {
+    i2c_read_id(&nfctag_id);
+    if ( (nfctag_id == I_AM_M24LR04) || (nfctag_id == I_AM_M24LR16) || (nfctag_id == I_AM_M24LR64) ) {
       NfctagInitialized = 1;
-     // Nfctag_Drv = &M24lr_i2c_Drv;
-     // Nfctag_Drv->pData = &M24lr_i2c_ExtDrv;
-    }
-    else
-    {
+      // Nfctag_Drv = &M24lr_i2c_Drv;
+      // Nfctag_Drv->pData = &M24lr_i2c_ExtDrv;
+    } else {
       NfctagInitialized = 0;
-     // Nfctag_Drv = NULL;
-     // NfctagInitialized = 0;
+      // Nfctag_Drv = NULL;
+      // NfctagInitialized = 0;
       return NFCTAG_ERROR;
     }
   }
@@ -104,7 +95,7 @@
 {
   /* Configure the low level interface */
   return(NFCTAG_OK);
- // return mM24LR_IO.Init( );
+  //eturn mM24LR_IO.Init( );
 }
 
 /**
@@ -119,10 +110,11 @@
   /* Read ICRef on device */
   //return M24LR_i2c_read_register( pICRef, M24LR_ICREF_REG, 1 );
   /* Before calling this function M24LR must be ready, here is a check to detect an issue */
-   status = i2c_read_register(pBuffer, M24LR_ICREF_REG, 1);
+  status = i2c_read_register(pBuffer, M24LR_ICREF_REG, 1);
 
-  if (status  == 0)
+  if (status  == 0) {
     return NFCTAG_OK;
+  }
   return NFCTAG_TIMEOUT;
  
 }
@@ -135,18 +127,18 @@
 NFCTAG_StatusTypeDef M24LR::i2c_is_device_ready( const uint32_t Trials )
 {
   /* Test i2c with M24LR */
- // return mM24LR_IO.IsDeviceReady( M24LR_ADDR_DATA_I2C, Trials );
+  //return mM24LR_IO.IsDeviceReady( M24LR_ADDR_DATA_I2C, Trials );
   uint8_t status = 1;
   char buffer;
   while (status != 0) {
     /* for device is ready address in M24Lr is M24LR_ADDR_DATA_I2C */
-    status = dev_I2C->read(i2c_address_data, &buffer, 1, false);
+    status = dev_I2C.read(i2c_address_data, &buffer, 1, false);
   }
-  if ( status == 0 )
+  if ( status == 0 ) {
     return NFCTAG_OK;
-  else
+  } else {
     return NFCTAG_TIMEOUT;
-  
+  }
 }
 
 /**
@@ -159,12 +151,9 @@
   NFCTAG_StatusTypeDef status = NFCTAG_ERROR;
   
   /* Configure GPO function on M24LR */
-  if( (ITConf & M24LR_IT_BUSY_MASK) == M24LR_IT_BUSY_MASK )
-  {
+  if ( (ITConf & M24LR_IT_BUSY_MASK) == M24LR_IT_BUSY_MASK ) {
     status = i2c_setRF_Busy( );
-  }
-  else if( (ITConf & M24LR_IT_WIP_MASK) == M24LR_IT_WIP_MASK )
-  {
+  } else if ( (ITConf & M24LR_IT_WIP_MASK) == M24LR_IT_WIP_MASK ) {
     status = i2c_set_RF_WIP( );
   }
   return status;
@@ -181,9 +170,7 @@
   NFCTAG_StatusTypeDef status;
   status = i2c_read_register(&reg_value, M24LR_CFG_REG, 1);
   
-
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
@@ -194,7 +181,6 @@
   return i2c_write_register( &reg_value, M24LR_CFG_REG, 1 );
 }
 
-
 /**
   * @brief  Get Configuration of M24LR GPO
   * @param  GPOStatus : 0x01 = RFBUSY, 0x02 = RFWIP
@@ -207,18 +193,14 @@
   
   /* Read actual value of CFG register */
   status = i2c_read_register( &reg_value, M24LR_CFG_REG, 1 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
   /* Extract RF WIP/BUSY information */
-  if( (reg_value & M24LR_CFG_WIPBUSY_MASK) == M24LR_CFG_WIPBUSY_MASK )
-  {
+  if ( (reg_value & M24LR_CFG_WIPBUSY_MASK) == M24LR_CFG_WIPBUSY_MASK ) {
     *pGPOStatus = M24LR_IT_WIP_MASK;
-  }
-  else
-  {
+  } else {
     *pGPOStatus = M24LR_IT_BUSY_MASK;
   }
   
@@ -236,17 +218,17 @@
 {  
   int status;
   /* Before calling this function M24LR must be ready, here is a check to detect an issue */
-  if( i2c_is_device_ready( 1 ) != NFCTAG_OK )
-  {
+  if ( i2c_is_device_ready( 1 ) != NFCTAG_OK ) {
     return NFCTAG_TIMEOUT;
   }
-  /* Rosarium : To check M24LR_ADDR_DATA_I2C is this case */
- /* return M24lr_IO_MemRead( pData, M24LR_ADDR_DATA_I2C, TarAddr, NbByte ); */
-   status = dev_I2C->i2c_read(pData, i2c_address_data, TarAddr, NbByte);
-    if ( status == 0 )
+  /* Rosarium: To check M24LR_ADDR_DATA_I2C is this case */
+  /* return M24lr_IO_MemRead( pData, M24LR_ADDR_DATA_I2C, TarAddr, NbByte ); */
+  status = dev_I2C.i2c_read(pData, i2c_address_data, TarAddr, NbByte);
+  if ( status == 0 ) {
     return NFCTAG_OK;
-  else
+  } else {
     return NFCTAG_TIMEOUT;
+  }
 }
 
 /**
@@ -267,43 +249,42 @@
   uint8_t *pdata_index = (uint8_t *)pData;
   
   /* Before calling this function M24LR must be ready, here is a check to detect an issue */
-  if( i2c_is_device_ready( 1 ) != NFCTAG_OK )
-  {
+  if ( i2c_is_device_ready( 1 ) != NFCTAG_OK ) {
     return NFCTAG_TIMEOUT;
   }
   
   /* M24LR can write a maximum of 4 bytes in EEPROM per i2c communication */
-  do
-  {
+  do {
     /* To write data in M24LR, data must be aligned on the same row in memory */
     /* align_mem_offset is used to copy only Bytes that are on the same row  in memory */
-    if( bytes_to_write > M24LR_PAGEWRITE_NBBYTE )
-    {
+    if ( bytes_to_write > M24LR_PAGEWRITE_NBBYTE ) {
       /* DataSize higher than max page write, copy data by page */
       align_mem_offset = M24LR_PAGEWRITE_NBBYTE - (mem_addr % M24LR_PAGEWRITE_NBBYTE);
-    }
-    else
-    {
+    } else {
       /* DataSize lower or equal to max page write, copy only last bytes */
       align_mem_offset = bytes_to_write;
     }
+
     /* Write align_mem_offset bytes in memory */
-    /* Rosarium to Check as the address here is 0xA6 rather than 0xAE */
-    /* Rosarium dev_I2C.i2c_write(pdata_index, M24LR_ADDR_DATA_I2C, mem_addr, align_mem_offset); */
-    status = dev_I2C->i2c_write(pdata_index, i2c_address_data, mem_addr, align_mem_offset);
+    /* Rosarium: to Check as the address here is 0xA6 rather than 0xAE */
+    /* dev_I2C.i2c_write(pdata_index, M24LR_ADDR_DATA_I2C, mem_addr, align_mem_offset); */
+    status = dev_I2C.i2c_write(pdata_index, i2c_address_data, mem_addr, align_mem_offset);
     
     /* update index, dest address, size for next write */
     pdata_index += align_mem_offset;
     mem_addr += align_mem_offset;
     bytes_to_write -= align_mem_offset;
+
     /* Poll until EEPROM is available */
-    while( i2c_is_device_ready( 1 ) != NFCTAG_OK ) {};
+    while ( i2c_is_device_ready( 1 ) != NFCTAG_OK ) {};
   }
-  while( ( bytes_to_write > 0 ) && ( status == NFCTAG_OK ) );
-  if ( status == 0 )
+  while ( ( bytes_to_write > 0 ) && ( status == NFCTAG_OK ) );
+  if ( status == 0 ) {
     return NFCTAG_OK;
-  else
+  }
+  else {
     return NFCTAG_ERROR;
+  }
 }
 
 /**
@@ -319,17 +300,18 @@
   int status;
   
   /* Before calling any read function M24LR must be ready, here is a check to detect an issue */
-  if( i2c_is_device_ready( 1 ) != NFCTAG_OK )
-  {
+  if ( i2c_is_device_ready( 1 ) != NFCTAG_OK ) {
     return NFCTAG_TIMEOUT;
   }
-   /* Read actual value of register */
-  status = dev_I2C->i2c_read(pData, i2c_address_syst, TarAddr, NbByte);
+  
+  /* Read actual value of register */
+  status = dev_I2C.i2c_read(pData, i2c_address_syst, TarAddr, NbByte);
   
-    if ( status == 0 )
+  if ( status == 0 ) {
     return NFCTAG_OK;
-  else
+  } else {
     return NFCTAG_TIMEOUT;
+  }
 }
 
 /**
@@ -348,42 +330,41 @@
   uint8_t *pdata_index = (uint8_t *)pData;
   
   /* Before calling this function M24LR must be ready, here is a check to detect an issue */
-  if( i2c_is_device_ready( 1 ) != NFCTAG_OK )
-  {
+  if ( i2c_is_device_ready( 1 ) != NFCTAG_OK ) {
     return NFCTAG_TIMEOUT;
   }
   
   /* M24LR can write a maximum of 4 bytes in EEPROM per i2c communication */
-  do
-  {
+  do {
     /* To write data in M24LR, data must be aligned on the same row in memory */
     /* align_mem_offset is used to copy only Bytes that are on the same row  in memory */
-    if( bytes_to_write > M24LR_PAGEWRITE_NBBYTE )
-    {
+    if ( bytes_to_write > M24LR_PAGEWRITE_NBBYTE ) {
       /* DataSize higher than max page write, copy data by page */
       align_mem_offset = M24LR_PAGEWRITE_NBBYTE - (mem_addr % M24LR_PAGEWRITE_NBBYTE);
-    }
-    else
-    {
+    } else {
       /* DataSize lower or equal to max page write, copy only last bytes */
       align_mem_offset = bytes_to_write;
     }
+    
     /* Write align_mem_offset bytes in register */
-   // status = M24lr_IO_MemWrite( pdata_index, M24LR_ADDR_SYST_I2C, mem_addr, align_mem_offset );
-    status = dev_I2C->i2c_write(pdata_index, i2c_address_syst, mem_addr, align_mem_offset);
+    // status = M24lr_IO_MemWrite( pdata_index, M24LR_ADDR_SYST_I2C, mem_addr, align_mem_offset );
+    status = dev_I2C.i2c_write(pdata_index, i2c_address_syst, mem_addr, align_mem_offset);
+    
     /* update index, dest address, size for next write */
     pdata_index += align_mem_offset;
     mem_addr += align_mem_offset;
     bytes_to_write -= align_mem_offset;
+    
     /* Poll until EEPROM is available */
-    while( i2c_is_device_ready( 1 ) != NFCTAG_OK ) {};
+    while ( i2c_is_device_ready( 1 ) != NFCTAG_OK ) {};
   }
-  while( ( bytes_to_write > 0 ) && ( status == NFCTAG_OK ) );
+  while ( ( bytes_to_write > 0 ) && ( status == NFCTAG_OK ) );
   
-    if ( status == 0 )
+  if ( status == 0 ) {
     return NFCTAG_OK;
-  else
+  } else {
     return NFCTAG_ERROR;
+  }
 }
 
 /**
@@ -399,23 +380,20 @@
   
   /* Read actual value of UID registers */
   status = i2c_read_register( areg_value, M24LR_UID_REG, 8 );
-  if( status != NFCTAG_OK )
-  {
+
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
   /* Store information in 2 WORD */
   pUid->MSB_UID = 0;
   
-  for( i = 0; i < 4; i++ )
-  {
+  for ( i = 0; i < 4; i++ ) {
     pUid->MSB_UID = (pUid->MSB_UID << 8) | areg_value[7 - i];
   }
-  
   pUid->LSB_UID = 0;
   
-  for( i = 0; i < 4; i++ )
-  {
+  for ( i = 0; i < 4; i++ ) {
     pUid->LSB_UID = (pUid->LSB_UID << 8) | areg_value[3 - i];
   }
   
@@ -456,8 +434,7 @@
 
   /* Read actual value of I2c Write Lock registers */
   status = i2c_read_register( areg_value, M24LR_LOCK_REG, 8 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
@@ -491,8 +468,7 @@
   
   /* Read actual WriteLockStatus */
   status = i2c_read_register( &reg_value, sector_write_lock_addr, 1 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
@@ -520,8 +496,7 @@
   
   /* Read actual WriteLockStatus */
   status = i2c_read_register( &reg_value, sector_write_lock_addr, 1 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
@@ -545,8 +520,7 @@
   /* Build I2C Message with Password + Validation code 0x09 + Password */
   ai2c_message[4] = 0x09;
   i = 0;
-  while( i < 4 )
-  {
+  while ( i < 4 ) {
     ai2c_message[i] = ( PassWord >> (i * 8) ) & 0xFF;
     ai2c_message[i + 5] = ( PassWord >> (i * 8) ) & 0xFF;
     i++;
@@ -570,8 +544,7 @@
   /* Build I2C Message with Password + Validation code 0x07 + Password */
   ai2c_message[4] = 0x07;
   i = 0;
-  while( i < 4 ) 
-  {
+  while ( i < 4 ) {
     ai2c_message[i] = ( PassWord >> (i * 8) ) & 0xFF;
     ai2c_message[i + 5] = ( PassWord >> (i * 8) ) & 0xFF;
     i++;
@@ -598,8 +571,7 @@
   
   /* Read actual value of SectorSecurityStatus register */
   status = i2c_read_register( &reg_value, sector_security_addr, 1 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
@@ -647,8 +619,7 @@
   
   /* Read actual value of Mem_Size register */
   status = i2c_read_register( areg_value, M24LR_MEMSIZE_REG, 3 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
@@ -672,18 +643,14 @@
   
   /* Read actual value of CFG register */
   status = i2c_read_register( &reg_value, M24LR_CFG_REG, 1 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
   /* Extract RF WIP/BUSY information */
-  if( (reg_value & M24LR_CFG_WIPBUSY_MASK) == M24LR_CFG_WIPBUSY_MASK )
-  {
+  if ( (reg_value & M24LR_CFG_WIPBUSY_MASK) == M24LR_CFG_WIPBUSY_MASK ) {
     *pRf_Wip_Busy = M24LR_GPO_WIP;
-  }
-  else
-  {
+  } else {
     *pRf_Wip_Busy = M24LR_GPO_BUSY;
   }
 
@@ -701,9 +668,8 @@
   int status;
   
   /* Read actual value of CFG register */
-  status = dev_I2C->i2c_read( &reg_value, i2c_address_syst, (uint16_t)M24LR_CFG_REG, 1 );
-  if( status != 0 )
-  {
+  status = dev_I2C.i2c_read( &reg_value, i2c_address_syst, (uint16_t)M24LR_CFG_REG, 1 );
+  if ( status != 0 ) {
     return NFCTAG_TIMEOUT;
   }
   
@@ -712,13 +678,13 @@
   
   /* Write CFG register */
   status = i2c_write_register( &reg_value, M24LR_CFG_REG, 1 );
-  if ( status == 0 )
+  if ( status == 0 ) {
     return NFCTAG_OK;
-  else
+  } else {
     return NFCTAG_TIMEOUT;
+  }
 }
 
-
 /**
   * @brief  Get Energy harvesting mode status
   * @param  EH_mode : M24LR_EH_MODE_STATUS pointer of the data to store
@@ -731,18 +697,14 @@
   
   /* Read actual value of CFG register */
   status = i2c_read_register( &reg_value, M24LR_CFG_REG, 1 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
   /* Extract EH_mode configuration */
-  if( (reg_value & M24LR_CFG_EHMODE_MASK) == M24LR_CFG_EHMODE_MASK )
-  {
+  if ( (reg_value & M24LR_CFG_EHMODE_MASK) == M24LR_CFG_EHMODE_MASK ) {
     *pEH_mode = M24LR_EH_MODE_DISABLE;
-  }
-  else
-  {
+  } else {
     *pEH_mode = M24LR_EH_MODE_ENABLE;
   }
   
@@ -761,8 +723,7 @@
   
   /* Read actual value of CFG register */
   status = i2c_read_register( &reg_value, M24LR_CFG_REG, 1 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
@@ -785,8 +746,7 @@
   
   /* Read actual value of CFG register */
   status = i2c_read_register( &reg_value, M24LR_CFG_REG, 1 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
@@ -809,30 +769,32 @@
   
   /* Read actual value of CFG register */
   status = i2c_read_register( &reg_value, M24LR_CFG_REG, 1 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
   /* Extract Vout configuration for EH information */
   reg_value &= (M24LR_CFG_EHCFG1_MASK | M24LR_CFG_EHCFG0_MASK);
-  switch( reg_value )
-  {
-    case 0:
+  switch ( reg_value ) {
+    case 0: {
       *pEH_Cfg = M24LR_EH_Cfg_6MA;
       break;
-    case 1:
+    }
+    case 1: {
       *pEH_Cfg = M24LR_EH_Cfg_3MA;
       break;
-    case 2:
+    }
+    case 2: {
       *pEH_Cfg = M24LR_EH_Cfg_1MA;
       break;
-    case 3:
+    }
+    case 3: {
       *pEH_Cfg = M24LR_EH_Cfg_300UA;
       break;
-    
-    default:
+    }
+    default: {
       *pEH_Cfg = M24LR_EH_Cfg_6MA;
+    }
   } 
   
   return NFCTAG_OK;
@@ -850,8 +812,7 @@
   
   /* Read actual value of CFG register */
   status = i2c_read_register( &reg_value, M24LR_CFG_REG, 1 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
@@ -875,18 +836,14 @@
   
   /* Read actual value of CTRL register */
   status = i2c_read_register( &reg_value, M24LR_CTRL_REG, 1 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
   /* Extract EH information */
-  if( (reg_value & M24LR_CTRL_EHEN_MASK) == M24LR_CTRL_EHEN_MASK )
-  {
+  if ( (reg_value & M24LR_CTRL_EHEN_MASK) == M24LR_CTRL_EHEN_MASK ) {
     *pEH_Val = M24LR_EH_ENABLE;
-  }
-  else
-  {
+  } else {
     *pEH_Val = M24LR_EH_DISABLE;
   }
   
@@ -905,8 +862,7 @@
   
   /* Read actual value of CTRL register */
   status = i2c_read_register( &reg_value, M24LR_CTRL_REG, 1 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
@@ -929,8 +885,7 @@
   
   /* Read actual value of CTRL register */
   status = i2c_read_register( &reg_value, M24LR_CTRL_REG, 1 );
-  if( status != NFCTAG_OK )
-  {
+  if ( status != NFCTAG_OK ) {
     return status;
   }
   
@@ -950,19 +905,15 @@
 {
   NFCTAG_StatusTypeDef status;
   uint8_t reg_value = 0;
-  
+
   /* Read actual value of CTRL register */
   status = i2c_read_register( &reg_value, M24LR_CTRL_REG, 1 );
   
   /* Extract RF Field information */
-  if( status == NFCTAG_OK )
-  {
-    if( (reg_value & M24LR_CTRL_FIELD_MASK) == M24LR_CTRL_FIELD_MASK )
-    {
+  if ( status == NFCTAG_OK ) {
+    if ( (reg_value & M24LR_CTRL_FIELD_MASK) == M24LR_CTRL_FIELD_MASK ) {
       *pRF_Field = M24LR_FIELD_ON;
-    }
-    else
-    {
+    } else {
       *pRF_Field = M24LR_FIELD_OFF;
     }
     
@@ -986,37 +937,18 @@
   status = i2c_read_register( &reg_value, M24LR_CTRL_REG, 1 );
   
   /* Extract T-Prog information */
-  if( status == NFCTAG_OK )
-  {
-    if( (reg_value & M24LR_CTRL_TPROG_MASK) == M24LR_CTRL_TPROG_MASK )
-    {
+  if ( status == NFCTAG_OK ) {
+    if ( (reg_value & M24LR_CTRL_TPROG_MASK) == M24LR_CTRL_TPROG_MASK ) {
       *pT_Prog = M24LR_T_PROG_OK;
-    }
-    else
-    {
+    } else {
       *pT_Prog = M24LR_T_PROG_NO;
     }
 
     return NFCTAG_OK;
+  } else {
+    return status;
   }
-  else
-    return status;
 }
 
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
 
 /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/