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.

Committer:
Davidroid
Date:
Wed Jul 12 12:34:12 2017 +0000
Revision:
8:7c4cf671960b
Parent:
7:b876cdcf095a
Updated to fit ARM mbed coding style.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
giovannivisentini 6:8c1eca41b3a9 1 /**
giovannivisentini 6:8c1eca41b3a9 2 ******************************************************************************
giovannivisentini 6:8c1eca41b3a9 3 * @file m24lr.h
giovannivisentini 6:8c1eca41b3a9 4 * @author AMG Central Lab
giovannivisentini 6:8c1eca41b3a9 5 * @version V2.0.0
giovannivisentini 6:8c1eca41b3a9 6 * @date 19 May 2017
giovannivisentini 6:8c1eca41b3a9 7 * @brief header file for M24LR driver .
giovannivisentini 6:8c1eca41b3a9 8 ******************************************************************************
giovannivisentini 6:8c1eca41b3a9 9 * @attention
giovannivisentini 6:8c1eca41b3a9 10 *
giovannivisentini 6:8c1eca41b3a9 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
giovannivisentini 6:8c1eca41b3a9 12 *
giovannivisentini 6:8c1eca41b3a9 13 * Redistribution and use in source and binary forms, with or without modification,
giovannivisentini 6:8c1eca41b3a9 14 * are permitted provided that the following conditions are met:
giovannivisentini 6:8c1eca41b3a9 15 * 1. Redistributions of source code must retain the above copyright notice,
giovannivisentini 6:8c1eca41b3a9 16 * this list of conditions and the following disclaimer.
giovannivisentini 6:8c1eca41b3a9 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
giovannivisentini 6:8c1eca41b3a9 18 * this list of conditions and the following disclaimer in the documentation
giovannivisentini 6:8c1eca41b3a9 19 * and/or other materials provided with the distribution.
giovannivisentini 6:8c1eca41b3a9 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
giovannivisentini 6:8c1eca41b3a9 21 * may be used to endorse or promote products derived from this software
giovannivisentini 6:8c1eca41b3a9 22 * without specific prior written permission.
giovannivisentini 6:8c1eca41b3a9 23 *
giovannivisentini 6:8c1eca41b3a9 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
giovannivisentini 6:8c1eca41b3a9 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
giovannivisentini 6:8c1eca41b3a9 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
giovannivisentini 6:8c1eca41b3a9 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
giovannivisentini 6:8c1eca41b3a9 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
giovannivisentini 6:8c1eca41b3a9 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
giovannivisentini 6:8c1eca41b3a9 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
giovannivisentini 6:8c1eca41b3a9 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
giovannivisentini 6:8c1eca41b3a9 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
giovannivisentini 6:8c1eca41b3a9 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
giovannivisentini 6:8c1eca41b3a9 34 *
giovannivisentini 6:8c1eca41b3a9 35 ******************************************************************************
giovannivisentini 6:8c1eca41b3a9 36 */
giovannivisentini 6:8c1eca41b3a9 37
giovannivisentini 6:8c1eca41b3a9 38
giovannivisentini 6:8c1eca41b3a9 39 #ifndef __M24LR_H
giovannivisentini 6:8c1eca41b3a9 40 #define __M24LR_H
giovannivisentini 6:8c1eca41b3a9 41
giovannivisentini 6:8c1eca41b3a9 42 #include "DevI2C.h"
giovannivisentini 6:8c1eca41b3a9 43 #include "Nfc.h"
giovannivisentini 6:8c1eca41b3a9 44 #include "NDefNfcTag.h"
giovannivisentini 6:8c1eca41b3a9 45 #include "NDefNfcTagM24LR.h"
giovannivisentini 6:8c1eca41b3a9 46
giovannivisentini 6:8c1eca41b3a9 47 //#include "lib_NDEF_URI.h"
giovannivisentini 6:8c1eca41b3a9 48 /* Exported constants --------------------------------------------------------*/
giovannivisentini 6:8c1eca41b3a9 49 /** @defgroup M24LR_Exported_Constants
giovannivisentini 6:8c1eca41b3a9 50 * @{
giovannivisentini 6:8c1eca41b3a9 51 */
giovannivisentini 6:8c1eca41b3a9 52 #define I_AM_M24LR04 0x5A
giovannivisentini 6:8c1eca41b3a9 53 #define I_AM_M24LR16 0x4E
giovannivisentini 6:8c1eca41b3a9 54 #define I_AM_M24LR64 0x5E
giovannivisentini 6:8c1eca41b3a9 55
giovannivisentini 6:8c1eca41b3a9 56 #ifndef NULL
giovannivisentini 6:8c1eca41b3a9 57 #define NULL (void *) 0
giovannivisentini 6:8c1eca41b3a9 58 #endif
giovannivisentini 6:8c1eca41b3a9 59
giovannivisentini 6:8c1eca41b3a9 60 #define M24LR_PAGEWRITE_NBBYTE 4
giovannivisentini 6:8c1eca41b3a9 61
giovannivisentini 6:8c1eca41b3a9 62 #define M24LR_ADDR_DATA_I2C 0xA6
giovannivisentini 6:8c1eca41b3a9 63 #define M24LR_ADDR_SYST_I2C 0xAE
giovannivisentini 6:8c1eca41b3a9 64 #define M24LR_I2C_TIMEOUT 200 /* I2C Time out (ms), this is the maximum time needed by M24LR to complete any command */
giovannivisentini 6:8c1eca41b3a9 65
giovannivisentini 6:8c1eca41b3a9 66 #define M24LR_IT_BUSY_MASK 0x01
giovannivisentini 6:8c1eca41b3a9 67 #define M24LR_IT_WIP_MASK 0x02
giovannivisentini 6:8c1eca41b3a9 68
giovannivisentini 6:8c1eca41b3a9 69 /* Registers address */
giovannivisentini 6:8c1eca41b3a9 70 #define M24LR_SSS_REG 0x0000
giovannivisentini 6:8c1eca41b3a9 71 #define M24LR_LOCK_REG 0x0800
giovannivisentini 6:8c1eca41b3a9 72 #define M24LR_I2C_PWD_REG 0x0900
giovannivisentini 6:8c1eca41b3a9 73 #define M24LR_CFG_REG 0x0910
giovannivisentini 6:8c1eca41b3a9 74 #define M24LR_AFI_REG 0x0912
giovannivisentini 6:8c1eca41b3a9 75 #define M24LR_DSFID_REG 0x0913
giovannivisentini 6:8c1eca41b3a9 76 #define M24LR_UID_REG 0x0914
giovannivisentini 6:8c1eca41b3a9 77 #define M24LR_ICREF_REG 0x091C
giovannivisentini 6:8c1eca41b3a9 78 #define M24LR_MEMSIZE_REG 0x091D
giovannivisentini 6:8c1eca41b3a9 79 #define M24LR_CTRL_REG 0x0920
giovannivisentini 6:8c1eca41b3a9 80
giovannivisentini 6:8c1eca41b3a9 81 /* Registers mask */
giovannivisentini 6:8c1eca41b3a9 82 #define M24LR_SSS_LOCK_MASK 0x01
giovannivisentini 6:8c1eca41b3a9 83 #define M24LR_SSS_RW_MASK 0x06
giovannivisentini 6:8c1eca41b3a9 84 #define M24LR_SSS_PASSCTRL_MASK 0x18
giovannivisentini 6:8c1eca41b3a9 85 #define M24LR_LOCK_MASK 0x0F
giovannivisentini 6:8c1eca41b3a9 86
giovannivisentini 6:8c1eca41b3a9 87 #define M24LR_CFG_EHCFG0_MASK 0x01
giovannivisentini 6:8c1eca41b3a9 88 #define M24LR_CFG_EHCFG1_MASK 0x02
giovannivisentini 6:8c1eca41b3a9 89 #define M24LR_CFG_EHMODE_MASK 0x04
giovannivisentini 6:8c1eca41b3a9 90 #define M24LR_CFG_WIPBUSY_MASK 0x08
giovannivisentini 6:8c1eca41b3a9 91
giovannivisentini 6:8c1eca41b3a9 92 #define M24LR_CTRL_EHEN_MASK 0x01
giovannivisentini 6:8c1eca41b3a9 93 #define M24LR_CTRL_FIELD_MASK 0x02
giovannivisentini 6:8c1eca41b3a9 94 #define M24LR_CTRL_TPROG_MASK 0x80
giovannivisentini 6:8c1eca41b3a9 95
giovannivisentini 6:8c1eca41b3a9 96
giovannivisentini 6:8c1eca41b3a9 97 /**
giovannivisentini 6:8c1eca41b3a9 98 * @brief NFCTAG status enumerator definition
giovannivisentini 6:8c1eca41b3a9 99 */
giovannivisentini 6:8c1eca41b3a9 100 typedef enum
giovannivisentini 6:8c1eca41b3a9 101 {
giovannivisentini 6:8c1eca41b3a9 102 NFCTAG_OK = 0,
giovannivisentini 6:8c1eca41b3a9 103 NFCTAG_ERROR = 1,
giovannivisentini 6:8c1eca41b3a9 104 NFCTAG_BUSY = 2,
giovannivisentini 6:8c1eca41b3a9 105 NFCTAG_TIMEOUT = 3
giovannivisentini 6:8c1eca41b3a9 106 } NFCTAG_StatusTypeDef;
giovannivisentini 6:8c1eca41b3a9 107
giovannivisentini 6:8c1eca41b3a9 108 /**
giovannivisentini 6:8c1eca41b3a9 109 * @brief M24LR VOUT Configuration enumerator definition
giovannivisentini 6:8c1eca41b3a9 110 */
giovannivisentini 6:8c1eca41b3a9 111 typedef enum
giovannivisentini 6:8c1eca41b3a9 112 {
giovannivisentini 6:8c1eca41b3a9 113 M24LR_EH_Cfg_6MA = 0,
giovannivisentini 6:8c1eca41b3a9 114 M24LR_EH_Cfg_3MA,
giovannivisentini 6:8c1eca41b3a9 115 M24LR_EH_Cfg_1MA,
giovannivisentini 6:8c1eca41b3a9 116 M24LR_EH_Cfg_300UA
giovannivisentini 6:8c1eca41b3a9 117 } M24LR_EH_CFG_VOUT;
giovannivisentini 6:8c1eca41b3a9 118
giovannivisentini 6:8c1eca41b3a9 119 /**
giovannivisentini 6:8c1eca41b3a9 120 * @brief M24LR FIELD status enumerator definition
giovannivisentini 6:8c1eca41b3a9 121 */
giovannivisentini 6:8c1eca41b3a9 122 typedef enum
giovannivisentini 6:8c1eca41b3a9 123 {
giovannivisentini 6:8c1eca41b3a9 124 M24LR_FIELD_OFF = 0,
giovannivisentini 6:8c1eca41b3a9 125 M24LR_FIELD_ON
giovannivisentini 6:8c1eca41b3a9 126 } M24LR_FIELD_STATUS;
giovannivisentini 6:8c1eca41b3a9 127
giovannivisentini 6:8c1eca41b3a9 128 /**
giovannivisentini 6:8c1eca41b3a9 129 * @brief M24LR TT-PROG status enumerator definition
giovannivisentini 6:8c1eca41b3a9 130 */
giovannivisentini 6:8c1eca41b3a9 131 typedef enum
giovannivisentini 6:8c1eca41b3a9 132 {
giovannivisentini 6:8c1eca41b3a9 133 M24LR_T_PROG_NO = 0,
giovannivisentini 6:8c1eca41b3a9 134 M24LR_T_PROG_OK
giovannivisentini 6:8c1eca41b3a9 135 } M24LR_T_PROG_STATUS;
giovannivisentini 6:8c1eca41b3a9 136
giovannivisentini 6:8c1eca41b3a9 137 /**
giovannivisentini 6:8c1eca41b3a9 138 * @brief M24LR Energy Harvesting status enumerator definition
giovannivisentini 6:8c1eca41b3a9 139 */
giovannivisentini 6:8c1eca41b3a9 140 typedef enum
giovannivisentini 6:8c1eca41b3a9 141 {
giovannivisentini 6:8c1eca41b3a9 142 M24LR_EH_DISABLE = 0,
giovannivisentini 6:8c1eca41b3a9 143 M24LR_EH_ENABLE
giovannivisentini 6:8c1eca41b3a9 144 } M24LR_EH_STATUS;
giovannivisentini 6:8c1eca41b3a9 145
giovannivisentini 6:8c1eca41b3a9 146 /**
giovannivisentini 6:8c1eca41b3a9 147 * @brief M24LR Energy Harvesting mode enumerator definition
giovannivisentini 6:8c1eca41b3a9 148 */
giovannivisentini 6:8c1eca41b3a9 149 typedef enum
giovannivisentini 6:8c1eca41b3a9 150 {
giovannivisentini 6:8c1eca41b3a9 151 M24LR_EH_MODE_ENABLE = 0,
giovannivisentini 6:8c1eca41b3a9 152 M24LR_EH_MODE_DISABLE
giovannivisentini 6:8c1eca41b3a9 153 } M24LR_EH_MODE_STATUS;
giovannivisentini 6:8c1eca41b3a9 154
giovannivisentini 6:8c1eca41b3a9 155 /**
giovannivisentini 6:8c1eca41b3a9 156 * @brief M24LR GPO status enumerator definition
giovannivisentini 6:8c1eca41b3a9 157 */
giovannivisentini 6:8c1eca41b3a9 158 typedef enum
giovannivisentini 6:8c1eca41b3a9 159 {
giovannivisentini 6:8c1eca41b3a9 160 M24LR_GPO_BUSY = 0,
giovannivisentini 6:8c1eca41b3a9 161 M24LR_GPO_WIP
giovannivisentini 6:8c1eca41b3a9 162 } M24LR_GPO_STATUS;
giovannivisentini 6:8c1eca41b3a9 163
giovannivisentini 6:8c1eca41b3a9 164 /**
giovannivisentini 6:8c1eca41b3a9 165 * @brief M24LR Memory information structure definition
giovannivisentini 6:8c1eca41b3a9 166 */
giovannivisentini 6:8c1eca41b3a9 167 typedef struct
giovannivisentini 6:8c1eca41b3a9 168 {
giovannivisentini 6:8c1eca41b3a9 169 uint8_t BlockSize;
giovannivisentini 6:8c1eca41b3a9 170 uint16_t Mem_Size;
giovannivisentini 6:8c1eca41b3a9 171 } M24LR_Mem_Size;
giovannivisentini 6:8c1eca41b3a9 172
giovannivisentini 6:8c1eca41b3a9 173 /**
giovannivisentini 6:8c1eca41b3a9 174 * @brief M24LR I2C Write Lock register structure definition
giovannivisentini 6:8c1eca41b3a9 175 */
giovannivisentini 6:8c1eca41b3a9 176 typedef struct
giovannivisentini 6:8c1eca41b3a9 177 {
giovannivisentini 6:8c1eca41b3a9 178 uint8_t sectors_7_0;
giovannivisentini 6:8c1eca41b3a9 179 uint8_t sectors_15_8;
giovannivisentini 6:8c1eca41b3a9 180 uint8_t sectors_23_16;
giovannivisentini 6:8c1eca41b3a9 181 uint8_t sectors_31_24;
giovannivisentini 6:8c1eca41b3a9 182 uint8_t sectors_39_32;
giovannivisentini 6:8c1eca41b3a9 183 uint8_t sectors_47_40;
giovannivisentini 6:8c1eca41b3a9 184 uint8_t sectors_55_48;
giovannivisentini 6:8c1eca41b3a9 185 uint8_t sectors_63_56;
giovannivisentini 6:8c1eca41b3a9 186 } M24LR_Lock_Sectors;
giovannivisentini 6:8c1eca41b3a9 187
giovannivisentini 6:8c1eca41b3a9 188 /**
giovannivisentini 6:8c1eca41b3a9 189 * @brief M24LR UID information structure definition
giovannivisentini 6:8c1eca41b3a9 190 */
giovannivisentini 6:8c1eca41b3a9 191 typedef struct
giovannivisentini 6:8c1eca41b3a9 192 {
giovannivisentini 6:8c1eca41b3a9 193 uint32_t MSB_UID;
giovannivisentini 6:8c1eca41b3a9 194 uint32_t LSB_UID;
giovannivisentini 6:8c1eca41b3a9 195 } M24LR_UID;
giovannivisentini 6:8c1eca41b3a9 196
giovannivisentini 6:8c1eca41b3a9 197 /**
giovannivisentini 6:8c1eca41b3a9 198 * @brief M24LR Sector Security register structure definition
giovannivisentini 6:8c1eca41b3a9 199 */
giovannivisentini 6:8c1eca41b3a9 200 typedef struct
giovannivisentini 6:8c1eca41b3a9 201 {
giovannivisentini 6:8c1eca41b3a9 202 uint8_t SectorLock;
giovannivisentini 6:8c1eca41b3a9 203 uint8_t RW_Protection;
giovannivisentini 6:8c1eca41b3a9 204 uint8_t PassCtrl;
giovannivisentini 6:8c1eca41b3a9 205 } M24LR_SECTOR_SEC;
giovannivisentini 6:8c1eca41b3a9 206
Davidroid 8:7c4cf671960b 207 /**
Davidroid 8:7c4cf671960b 208 * @brief M24LR class.
Davidroid 8:7c4cf671960b 209 */
Davidroid 8:7c4cf671960b 210 class M24LR : public Nfc {
giovannivisentini 6:8c1eca41b3a9 211 public:
giovannivisentini 6:8c1eca41b3a9 212 NFCTAG_StatusTypeDef i2c_init( void );
giovannivisentini 6:8c1eca41b3a9 213 NFCTAG_StatusTypeDef i2c_read_id( uint8_t * const pICRef );
giovannivisentini 6:8c1eca41b3a9 214 NFCTAG_StatusTypeDef i2c_is_device_ready( const uint32_t Trials );
giovannivisentini 6:8c1eca41b3a9 215 NFCTAG_StatusTypeDef i2c_configure_GPO( const uint16_t ITConf );
giovannivisentini 6:8c1eca41b3a9 216 NFCTAG_StatusTypeDef i2c_get_GPO_status( uint16_t * const pGPOStatus );
giovannivisentini 6:8c1eca41b3a9 217 NFCTAG_StatusTypeDef i2c_read_data( uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte );
giovannivisentini 6:8c1eca41b3a9 218 NFCTAG_StatusTypeDef i2c_write_data( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte );
giovannivisentini 6:8c1eca41b3a9 219 NFCTAG_StatusTypeDef i2c_read_register( uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte );
giovannivisentini 6:8c1eca41b3a9 220 NFCTAG_StatusTypeDef i2c_write_register( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte );
Davidroid 8:7c4cf671960b 221
giovannivisentini 6:8c1eca41b3a9 222 /* Extended Functions */
giovannivisentini 6:8c1eca41b3a9 223 NFCTAG_StatusTypeDef i2c_read_UID( M24LR_UID * const pUid );
giovannivisentini 6:8c1eca41b3a9 224 NFCTAG_StatusTypeDef i2c_read_DSFID( uint8_t * const pDsfid );
giovannivisentini 6:8c1eca41b3a9 225 NFCTAG_StatusTypeDef i2c_read_AFI( uint8_t * const pAfi );
giovannivisentini 6:8c1eca41b3a9 226 NFCTAG_StatusTypeDef i2c_read_I2C_lock_sector( M24LR_Lock_Sectors * const pLock_sector );
giovannivisentini 6:8c1eca41b3a9 227 NFCTAG_StatusTypeDef i2c_I2C_lock_sector( const uint8_t Sector );
giovannivisentini 6:8c1eca41b3a9 228 NFCTAG_StatusTypeDef i2c_I2C_unlock_sector( const uint8_t Sector );
giovannivisentini 6:8c1eca41b3a9 229 NFCTAG_StatusTypeDef i2c_present_I2C_password( const uint32_t PassWord );
giovannivisentini 6:8c1eca41b3a9 230 NFCTAG_StatusTypeDef i2c_write_I2C_password( const uint32_t PassWord );
giovannivisentini 6:8c1eca41b3a9 231 NFCTAG_StatusTypeDef i2c_read_SSSx( const uint8_t SectorNb, M24LR_SECTOR_SEC * const pData );
giovannivisentini 6:8c1eca41b3a9 232 NFCTAG_StatusTypeDef i2c_write_SSSx( const uint8_t SectorNb, const M24LR_SECTOR_SEC * const pData );
giovannivisentini 6:8c1eca41b3a9 233 NFCTAG_StatusTypeDef i2c_read_mem_size( M24LR_Mem_Size * const pSizeInfo );
giovannivisentini 6:8c1eca41b3a9 234 NFCTAG_StatusTypeDef i2c_get_RF_WIP_busy( M24LR_GPO_STATUS * const pRf_Wip_Busy );
giovannivisentini 6:8c1eca41b3a9 235 NFCTAG_StatusTypeDef i2c_setRF_Busy( void );
giovannivisentini 6:8c1eca41b3a9 236 NFCTAG_StatusTypeDef i2c_set_RF_WIP( void );
giovannivisentini 6:8c1eca41b3a9 237 NFCTAG_StatusTypeDef i2c_read_EH_mode( M24LR_EH_MODE_STATUS * const pEH_mode );
giovannivisentini 6:8c1eca41b3a9 238 NFCTAG_StatusTypeDef i2c_enable_EH_mode( void );
giovannivisentini 6:8c1eca41b3a9 239 NFCTAG_StatusTypeDef i2c_disable_EH_mode( void );
giovannivisentini 6:8c1eca41b3a9 240 NFCTAG_StatusTypeDef i2c_read_EH_cfg( M24LR_EH_CFG_VOUT * const pEH_Cfg );
giovannivisentini 6:8c1eca41b3a9 241 NFCTAG_StatusTypeDef i2c_write_EH_cfg( const M24LR_EH_CFG_VOUT EH_Cfg );
giovannivisentini 6:8c1eca41b3a9 242 NFCTAG_StatusTypeDef i2c_get_EH( M24LR_EH_STATUS * const pEH_Val );
giovannivisentini 6:8c1eca41b3a9 243 NFCTAG_StatusTypeDef i2c_set_EH( void );
giovannivisentini 6:8c1eca41b3a9 244 NFCTAG_StatusTypeDef i2c_reset_EH( void );
giovannivisentini 6:8c1eca41b3a9 245 NFCTAG_StatusTypeDef i2c_get_RF_field( M24LR_FIELD_STATUS * const pRF_Field );
giovannivisentini 6:8c1eca41b3a9 246 NFCTAG_StatusTypeDef i2c_get_TProg( M24LR_T_PROG_STATUS * const pT_Prog );
giovannivisentini 6:8c1eca41b3a9 247
giovannivisentini 6:8c1eca41b3a9 248 void enable_energy_harvesting( void );
giovannivisentini 6:8c1eca41b3a9 249 NFCTAG_StatusTypeDef initialization( void );
giovannivisentini 6:8c1eca41b3a9 250
Davidroid 8:7c4cf671960b 251 virtual int read_binary(uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead) {
Davidroid 8:7c4cf671960b 252 return i2c_read_data( pBufferRead, Offset, NbByteToRead );
giovannivisentini 6:8c1eca41b3a9 253
giovannivisentini 6:8c1eca41b3a9 254 }
Davidroid 8:7c4cf671960b 255
Davidroid 8:7c4cf671960b 256 virtual int update_binary(uint16_t Offset, uint8_t NbByteToWrite,uint8_t *pDataToWrite) {
Davidroid 8:7c4cf671960b 257 return i2c_write_data( pDataToWrite, Offset, NbByteToWrite );
giovannivisentini 6:8c1eca41b3a9 258 }
giovannivisentini 6:8c1eca41b3a9 259
Davidroid 8:7c4cf671960b 260 M24LR(uint8_t const address, uint8_t const addressData, DevI2C &devI2C ):
giovannivisentini 6:8c1eca41b3a9 261 NDefTagUtil(*this), i2c_address_syst(address), i2c_address_data(addressData), dev_I2C(devI2C) {}
Davidroid 8:7c4cf671960b 262
Davidroid 8:7c4cf671960b 263 NDefLib::NDefNfcTag& get_NDef_tag(){
giovannivisentini 6:8c1eca41b3a9 264 return NDefTagUtil;
Davidroid 8:7c4cf671960b 265 }
Davidroid 8:7c4cf671960b 266
Davidroid 8:7c4cf671960b 267 virtual int init(void *ptr) {
Davidroid 8:7c4cf671960b 268 (void)ptr;
giovannivisentini 6:8c1eca41b3a9 269 return i2c_init();
giovannivisentini 6:8c1eca41b3a9 270 }
giovannivisentini 6:8c1eca41b3a9 271
Davidroid 8:7c4cf671960b 272 virtual int read_id(uint8_t *id) {
giovannivisentini 6:8c1eca41b3a9 273 return i2c_read_id(id);
giovannivisentini 6:8c1eca41b3a9 274 }
Davidroid 8:7c4cf671960b 275
Davidroid 8:7c4cf671960b 276 private:
Davidroid 8:7c4cf671960b 277 static uint8_t NfctagInitialized;
Davidroid 8:7c4cf671960b 278 /* Object implementing the interface to use the NDefLib. */
Davidroid 8:7c4cf671960b 279 NDefNfcTagM24LR NDefTagUtil;
Davidroid 8:7c4cf671960b 280
Davidroid 8:7c4cf671960b 281 uint8_t i2c_address_syst;
Davidroid 8:7c4cf671960b 282 uint8_t i2c_address_data;
Davidroid 8:7c4cf671960b 283 DevI2C &dev_I2C;
giovannivisentini 6:8c1eca41b3a9 284 };
giovannivisentini 6:8c1eca41b3a9 285
giovannivisentini 6:8c1eca41b3a9 286 #endif /* __M24LR_H */
giovannivisentini 6:8c1eca41b3a9 287
giovannivisentini 6:8c1eca41b3a9 288
Davidroid 8:7c4cf671960b 289 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/