X_NUCLEO_NFC02A1 library for M24LR
Dependencies: ST_INTERFACES
Dependents: HelloWorld_NFC02A1_mbedOS HelloWorld_NFC02A1laatste HelloWorld_NFC02A1
Fork of X_NUCLEO_NFC02A1 by
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.
m24lr/M24LR.h@7:b876cdcf095a, 2017-07-11 (annotated)
- Committer:
- Davidroid
- Date:
- Tue Jul 11 15:23:56 2017 +0000
- Revision:
- 7:b876cdcf095a
- Parent:
- 6:8c1eca41b3a9
- Child:
- 8:7c4cf671960b
Updating with the new mbed library.
Who changed what in which revision?
User | Revision | Line number | New 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>© 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 | |
giovannivisentini | 6:8c1eca41b3a9 | 207 | |
giovannivisentini | 6:8c1eca41b3a9 | 208 | /** |
giovannivisentini | 6:8c1eca41b3a9 | 209 | * @} |
giovannivisentini | 6:8c1eca41b3a9 | 210 | */ |
giovannivisentini | 6:8c1eca41b3a9 | 211 | |
giovannivisentini | 6:8c1eca41b3a9 | 212 | class M24LR : public Nfc { |
giovannivisentini | 6:8c1eca41b3a9 | 213 | public: |
giovannivisentini | 6:8c1eca41b3a9 | 214 | NFCTAG_StatusTypeDef i2c_init( void ); |
giovannivisentini | 6:8c1eca41b3a9 | 215 | NFCTAG_StatusTypeDef i2c_read_id( uint8_t * const pICRef ); |
giovannivisentini | 6:8c1eca41b3a9 | 216 | NFCTAG_StatusTypeDef i2c_is_device_ready( const uint32_t Trials ); |
giovannivisentini | 6:8c1eca41b3a9 | 217 | NFCTAG_StatusTypeDef i2c_configure_GPO( const uint16_t ITConf ); |
giovannivisentini | 6:8c1eca41b3a9 | 218 | NFCTAG_StatusTypeDef i2c_get_GPO_status( uint16_t * const pGPOStatus ); |
giovannivisentini | 6:8c1eca41b3a9 | 219 | NFCTAG_StatusTypeDef i2c_read_data( uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte ); |
giovannivisentini | 6:8c1eca41b3a9 | 220 | NFCTAG_StatusTypeDef i2c_write_data( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte ); |
giovannivisentini | 6:8c1eca41b3a9 | 221 | NFCTAG_StatusTypeDef i2c_read_register( uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte ); |
giovannivisentini | 6:8c1eca41b3a9 | 222 | NFCTAG_StatusTypeDef i2c_write_register( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte ); |
giovannivisentini | 6:8c1eca41b3a9 | 223 | |
giovannivisentini | 6:8c1eca41b3a9 | 224 | |
giovannivisentini | 6:8c1eca41b3a9 | 225 | /* Extended Functions */ |
giovannivisentini | 6:8c1eca41b3a9 | 226 | NFCTAG_StatusTypeDef i2c_read_UID( M24LR_UID * const pUid ); |
giovannivisentini | 6:8c1eca41b3a9 | 227 | NFCTAG_StatusTypeDef i2c_read_DSFID( uint8_t * const pDsfid ); |
giovannivisentini | 6:8c1eca41b3a9 | 228 | NFCTAG_StatusTypeDef i2c_read_AFI( uint8_t * const pAfi ); |
giovannivisentini | 6:8c1eca41b3a9 | 229 | NFCTAG_StatusTypeDef i2c_read_I2C_lock_sector( M24LR_Lock_Sectors * const pLock_sector ); |
giovannivisentini | 6:8c1eca41b3a9 | 230 | NFCTAG_StatusTypeDef i2c_I2C_lock_sector( const uint8_t Sector ); |
giovannivisentini | 6:8c1eca41b3a9 | 231 | NFCTAG_StatusTypeDef i2c_I2C_unlock_sector( const uint8_t Sector ); |
giovannivisentini | 6:8c1eca41b3a9 | 232 | NFCTAG_StatusTypeDef i2c_present_I2C_password( const uint32_t PassWord ); |
giovannivisentini | 6:8c1eca41b3a9 | 233 | NFCTAG_StatusTypeDef i2c_write_I2C_password( const uint32_t PassWord ); |
giovannivisentini | 6:8c1eca41b3a9 | 234 | NFCTAG_StatusTypeDef i2c_read_SSSx( const uint8_t SectorNb, M24LR_SECTOR_SEC * const pData ); |
giovannivisentini | 6:8c1eca41b3a9 | 235 | NFCTAG_StatusTypeDef i2c_write_SSSx( const uint8_t SectorNb, const M24LR_SECTOR_SEC * const pData ); |
giovannivisentini | 6:8c1eca41b3a9 | 236 | NFCTAG_StatusTypeDef i2c_read_mem_size( M24LR_Mem_Size * const pSizeInfo ); |
giovannivisentini | 6:8c1eca41b3a9 | 237 | NFCTAG_StatusTypeDef i2c_get_RF_WIP_busy( M24LR_GPO_STATUS * const pRf_Wip_Busy ); |
giovannivisentini | 6:8c1eca41b3a9 | 238 | NFCTAG_StatusTypeDef i2c_setRF_Busy( void ); |
giovannivisentini | 6:8c1eca41b3a9 | 239 | NFCTAG_StatusTypeDef i2c_set_RF_WIP( void ); |
giovannivisentini | 6:8c1eca41b3a9 | 240 | NFCTAG_StatusTypeDef i2c_read_EH_mode( M24LR_EH_MODE_STATUS * const pEH_mode ); |
giovannivisentini | 6:8c1eca41b3a9 | 241 | NFCTAG_StatusTypeDef i2c_enable_EH_mode( void ); |
giovannivisentini | 6:8c1eca41b3a9 | 242 | NFCTAG_StatusTypeDef i2c_disable_EH_mode( void ); |
giovannivisentini | 6:8c1eca41b3a9 | 243 | NFCTAG_StatusTypeDef i2c_read_EH_cfg( M24LR_EH_CFG_VOUT * const pEH_Cfg ); |
giovannivisentini | 6:8c1eca41b3a9 | 244 | NFCTAG_StatusTypeDef i2c_write_EH_cfg( const M24LR_EH_CFG_VOUT EH_Cfg ); |
giovannivisentini | 6:8c1eca41b3a9 | 245 | NFCTAG_StatusTypeDef i2c_get_EH( M24LR_EH_STATUS * const pEH_Val ); |
giovannivisentini | 6:8c1eca41b3a9 | 246 | NFCTAG_StatusTypeDef i2c_set_EH( void ); |
giovannivisentini | 6:8c1eca41b3a9 | 247 | NFCTAG_StatusTypeDef i2c_reset_EH( void ); |
giovannivisentini | 6:8c1eca41b3a9 | 248 | NFCTAG_StatusTypeDef i2c_get_RF_field( M24LR_FIELD_STATUS * const pRF_Field ); |
giovannivisentini | 6:8c1eca41b3a9 | 249 | NFCTAG_StatusTypeDef i2c_get_TProg( M24LR_T_PROG_STATUS * const pT_Prog ); |
giovannivisentini | 6:8c1eca41b3a9 | 250 | |
giovannivisentini | 6:8c1eca41b3a9 | 251 | void enable_energy_harvesting( void ); |
giovannivisentini | 6:8c1eca41b3a9 | 252 | NFCTAG_StatusTypeDef initialization( void ); |
giovannivisentini | 6:8c1eca41b3a9 | 253 | |
giovannivisentini | 6:8c1eca41b3a9 | 254 | virtual int read_binary(uint16_t Offset, uint8_t NbByteToRead, |
giovannivisentini | 6:8c1eca41b3a9 | 255 | uint8_t *pBufferRead) { |
giovannivisentini | 6:8c1eca41b3a9 | 256 | return i2c_read_data( pBufferRead, Offset, NbByteToRead ); |
giovannivisentini | 6:8c1eca41b3a9 | 257 | |
giovannivisentini | 6:8c1eca41b3a9 | 258 | } |
giovannivisentini | 6:8c1eca41b3a9 | 259 | |
giovannivisentini | 6:8c1eca41b3a9 | 260 | virtual int update_binary(uint16_t Offset, |
giovannivisentini | 6:8c1eca41b3a9 | 261 | uint8_t NbByteToWrite,uint8_t *pDataToWrite) { |
giovannivisentini | 6:8c1eca41b3a9 | 262 | return i2c_write_data( pDataToWrite, Offset, NbByteToWrite ); |
giovannivisentini | 6:8c1eca41b3a9 | 263 | } |
giovannivisentini | 6:8c1eca41b3a9 | 264 | |
Davidroid | 7:b876cdcf095a | 265 | M24LR(uint8_t const address, uint8_t const addressData, DevI2C *devI2C ): |
giovannivisentini | 6:8c1eca41b3a9 | 266 | NDefTagUtil(*this), i2c_address_syst(address), i2c_address_data(addressData), dev_I2C(devI2C) {} |
giovannivisentini | 6:8c1eca41b3a9 | 267 | |
giovannivisentini | 6:8c1eca41b3a9 | 268 | |
giovannivisentini | 6:8c1eca41b3a9 | 269 | NDefLib::NDefNfcTag& get_NDef_tag(){ |
giovannivisentini | 6:8c1eca41b3a9 | 270 | return NDefTagUtil; |
giovannivisentini | 6:8c1eca41b3a9 | 271 | } |
giovannivisentini | 6:8c1eca41b3a9 | 272 | |
giovannivisentini | 6:8c1eca41b3a9 | 273 | |
giovannivisentini | 6:8c1eca41b3a9 | 274 | virtual int init(void *ptr) { |
giovannivisentini | 6:8c1eca41b3a9 | 275 | (void)ptr; |
giovannivisentini | 6:8c1eca41b3a9 | 276 | return i2c_init(); |
giovannivisentini | 6:8c1eca41b3a9 | 277 | } |
giovannivisentini | 6:8c1eca41b3a9 | 278 | |
giovannivisentini | 6:8c1eca41b3a9 | 279 | virtual int read_id(uint8_t *id) { |
giovannivisentini | 6:8c1eca41b3a9 | 280 | return i2c_read_id(id); |
giovannivisentini | 6:8c1eca41b3a9 | 281 | } |
giovannivisentini | 6:8c1eca41b3a9 | 282 | private: |
giovannivisentini | 6:8c1eca41b3a9 | 283 | static uint8_t NfctagInitialized; |
giovannivisentini | 6:8c1eca41b3a9 | 284 | |
giovannivisentini | 6:8c1eca41b3a9 | 285 | |
giovannivisentini | 6:8c1eca41b3a9 | 286 | /* |
giovannivisentini | 6:8c1eca41b3a9 | 287 | * Object implementing the interface to use the NDefLib. |
giovannivisentini | 6:8c1eca41b3a9 | 288 | */ |
giovannivisentini | 6:8c1eca41b3a9 | 289 | NDefNfcTagM24LR NDefTagUtil; |
giovannivisentini | 6:8c1eca41b3a9 | 290 | |
giovannivisentini | 6:8c1eca41b3a9 | 291 | uint8_t i2c_address_syst; |
giovannivisentini | 6:8c1eca41b3a9 | 292 | uint8_t i2c_address_data; |
Davidroid | 7:b876cdcf095a | 293 | DevI2C *dev_I2C; |
giovannivisentini | 6:8c1eca41b3a9 | 294 | }; |
giovannivisentini | 6:8c1eca41b3a9 | 295 | |
giovannivisentini | 6:8c1eca41b3a9 | 296 | |
giovannivisentini | 6:8c1eca41b3a9 | 297 | |
giovannivisentini | 6:8c1eca41b3a9 | 298 | |
giovannivisentini | 6:8c1eca41b3a9 | 299 | #endif /* __M24LR_H */ |
giovannivisentini | 6:8c1eca41b3a9 | 300 | |
giovannivisentini | 6:8c1eca41b3a9 | 301 | |
giovannivisentini | 6:8c1eca41b3a9 | 302 | |
giovannivisentini | 6:8c1eca41b3a9 | 303 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |