mbed OS 5 example application using X-NUCLEO-NFC02A1
Dependencies: NDefLib X_NUCLEO_NFC02A1
Fork of HelloWorld_NFC02A1 by
X_NUCLEO_NFC02A1/m24lr/m24lr.h@1:11ae12d41082, 2016-08-30 (annotated)
- Committer:
- rosarium
- Date:
- Tue Aug 30 09:18:50 2016 +0000
- Revision:
- 1:11ae12d41082
- Parent:
- 0:892175366555
- Child:
- 2:6f1b1f7f8d12
NDefLib middle-ware library ported on HelloWorld_NFC02A1. Now NFC02A1 using the same middle-ware library as NFC01A1.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| rosarium | 1:11ae12d41082 | 1 | /** |
| rosarium | 1:11ae12d41082 | 2 | ****************************************************************************** |
| rosarium | 1:11ae12d41082 | 3 | * @file m24lr.h |
| rosarium | 1:11ae12d41082 | 4 | * @author AMG Central Lab |
| rosarium | 1:11ae12d41082 | 5 | * @version V1.0.0 |
| rosarium | 1:11ae12d41082 | 6 | * @date 30 Aug 2016 |
| rosarium | 1:11ae12d41082 | 7 | * @brief header file for M24LR driver . |
| rosarium | 1:11ae12d41082 | 8 | ****************************************************************************** |
| rosarium | 1:11ae12d41082 | 9 | * @attention |
| rosarium | 1:11ae12d41082 | 10 | * |
| rosarium | 1:11ae12d41082 | 11 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
| rosarium | 1:11ae12d41082 | 12 | * |
| rosarium | 1:11ae12d41082 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
| rosarium | 1:11ae12d41082 | 14 | * are permitted provided that the following conditions are met: |
| rosarium | 1:11ae12d41082 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
| rosarium | 1:11ae12d41082 | 16 | * this list of conditions and the following disclaimer. |
| rosarium | 1:11ae12d41082 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| rosarium | 1:11ae12d41082 | 18 | * this list of conditions and the following disclaimer in the documentation |
| rosarium | 1:11ae12d41082 | 19 | * and/or other materials provided with the distribution. |
| rosarium | 1:11ae12d41082 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| rosarium | 1:11ae12d41082 | 21 | * may be used to endorse or promote products derived from this software |
| rosarium | 1:11ae12d41082 | 22 | * without specific prior written permission. |
| rosarium | 1:11ae12d41082 | 23 | * |
| rosarium | 1:11ae12d41082 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| rosarium | 1:11ae12d41082 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| rosarium | 1:11ae12d41082 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| rosarium | 1:11ae12d41082 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| rosarium | 1:11ae12d41082 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| rosarium | 1:11ae12d41082 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| rosarium | 1:11ae12d41082 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| rosarium | 1:11ae12d41082 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| rosarium | 1:11ae12d41082 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| rosarium | 1:11ae12d41082 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| rosarium | 1:11ae12d41082 | 34 | * |
| rosarium | 1:11ae12d41082 | 35 | ****************************************************************************** |
| rosarium | 1:11ae12d41082 | 36 | */ |
| rosarium | 1:11ae12d41082 | 37 | |
| rosarium | 1:11ae12d41082 | 38 | |
| rosarium | 0:892175366555 | 39 | #ifndef __M24LR_H |
| rosarium | 0:892175366555 | 40 | #define __M24LR_H |
| rosarium | 0:892175366555 | 41 | |
| rosarium | 0:892175366555 | 42 | #include "common.h" |
| rosarium | 0:892175366555 | 43 | #include "DevI2C.h" |
| rosarium | 1:11ae12d41082 | 44 | #include "Nfc_class.h" |
| rosarium | 1:11ae12d41082 | 45 | #include "NDefNfcTag.h" |
| rosarium | 1:11ae12d41082 | 46 | #include "NDefNfcTagM24LR.h" |
| rosarium | 1:11ae12d41082 | 47 | |
| rosarium | 0:892175366555 | 48 | //#include "lib_NDEF_URI.h" |
| rosarium | 0:892175366555 | 49 | /* Exported constants --------------------------------------------------------*/ |
| rosarium | 0:892175366555 | 50 | /** @defgroup M24LR_Exported_Constants |
| rosarium | 0:892175366555 | 51 | * @{ |
| rosarium | 0:892175366555 | 52 | */ |
| rosarium | 0:892175366555 | 53 | #define I_AM_M24LR04 0x5A |
| rosarium | 0:892175366555 | 54 | #define I_AM_M24LR16 0x4E |
| rosarium | 0:892175366555 | 55 | #define I_AM_M24LR64 0x5E |
| rosarium | 0:892175366555 | 56 | |
| rosarium | 0:892175366555 | 57 | #ifndef NULL |
| rosarium | 0:892175366555 | 58 | #define NULL (void *) 0 |
| rosarium | 0:892175366555 | 59 | #endif |
| rosarium | 0:892175366555 | 60 | |
| rosarium | 0:892175366555 | 61 | #define M24LR_PAGEWRITE_NBBYTE 4 |
| rosarium | 0:892175366555 | 62 | |
| rosarium | 0:892175366555 | 63 | #define M24LR_ADDR_DATA_I2C 0xA6 |
| rosarium | 0:892175366555 | 64 | #define M24LR_ADDR_SYST_I2C 0xAE |
| rosarium | 0:892175366555 | 65 | #define M24LR_I2C_TIMEOUT 200 /* I2C Time out (ms), this is the maximum time needed by M24LR to complete any command */ |
| rosarium | 0:892175366555 | 66 | |
| rosarium | 0:892175366555 | 67 | #define M24LR_IT_BUSY_MASK 0x01 |
| rosarium | 0:892175366555 | 68 | #define M24LR_IT_WIP_MASK 0x02 |
| rosarium | 0:892175366555 | 69 | |
| rosarium | 0:892175366555 | 70 | /* Registers address */ |
| rosarium | 0:892175366555 | 71 | #define M24LR_SSS_REG 0x0000 |
| rosarium | 0:892175366555 | 72 | #define M24LR_LOCK_REG 0x0800 |
| rosarium | 0:892175366555 | 73 | #define M24LR_I2C_PWD_REG 0x0900 |
| rosarium | 0:892175366555 | 74 | #define M24LR_CFG_REG 0x0910 |
| rosarium | 0:892175366555 | 75 | #define M24LR_AFI_REG 0x0912 |
| rosarium | 0:892175366555 | 76 | #define M24LR_DSFID_REG 0x0913 |
| rosarium | 0:892175366555 | 77 | #define M24LR_UID_REG 0x0914 |
| rosarium | 0:892175366555 | 78 | #define M24LR_ICREF_REG 0x091C |
| rosarium | 0:892175366555 | 79 | #define M24LR_MEMSIZE_REG 0x091D |
| rosarium | 0:892175366555 | 80 | #define M24LR_CTRL_REG 0x0920 |
| rosarium | 0:892175366555 | 81 | |
| rosarium | 0:892175366555 | 82 | /* Registers mask */ |
| rosarium | 0:892175366555 | 83 | #define M24LR_SSS_LOCK_MASK 0x01 |
| rosarium | 0:892175366555 | 84 | #define M24LR_SSS_RW_MASK 0x06 |
| rosarium | 0:892175366555 | 85 | #define M24LR_SSS_PASSCTRL_MASK 0x18 |
| rosarium | 0:892175366555 | 86 | #define M24LR_LOCK_MASK 0x0F |
| rosarium | 0:892175366555 | 87 | |
| rosarium | 0:892175366555 | 88 | #define M24LR_CFG_EHCFG0_MASK 0x01 |
| rosarium | 0:892175366555 | 89 | #define M24LR_CFG_EHCFG1_MASK 0x02 |
| rosarium | 0:892175366555 | 90 | #define M24LR_CFG_EHMODE_MASK 0x04 |
| rosarium | 0:892175366555 | 91 | #define M24LR_CFG_WIPBUSY_MASK 0x08 |
| rosarium | 0:892175366555 | 92 | |
| rosarium | 0:892175366555 | 93 | #define M24LR_CTRL_EHEN_MASK 0x01 |
| rosarium | 0:892175366555 | 94 | #define M24LR_CTRL_FIELD_MASK 0x02 |
| rosarium | 0:892175366555 | 95 | #define M24LR_CTRL_TPROG_MASK 0x80 |
| rosarium | 1:11ae12d41082 | 96 | |
| rosarium | 1:11ae12d41082 | 97 | |
| rosarium | 0:892175366555 | 98 | |
| rosarium | 0:892175366555 | 99 | /** |
| rosarium | 0:892175366555 | 100 | * @brief M24LR VOUT Configuration enumerator definition |
| rosarium | 0:892175366555 | 101 | */ |
| rosarium | 0:892175366555 | 102 | typedef enum |
| rosarium | 0:892175366555 | 103 | { |
| rosarium | 0:892175366555 | 104 | M24LR_EH_Cfg_6MA = 0, |
| rosarium | 0:892175366555 | 105 | M24LR_EH_Cfg_3MA, |
| rosarium | 0:892175366555 | 106 | M24LR_EH_Cfg_1MA, |
| rosarium | 0:892175366555 | 107 | M24LR_EH_Cfg_300UA |
| rosarium | 0:892175366555 | 108 | } M24LR_EH_CFG_VOUT; |
| rosarium | 0:892175366555 | 109 | |
| rosarium | 0:892175366555 | 110 | /** |
| rosarium | 0:892175366555 | 111 | * @brief M24LR FIELD status enumerator definition |
| rosarium | 0:892175366555 | 112 | */ |
| rosarium | 0:892175366555 | 113 | typedef enum |
| rosarium | 0:892175366555 | 114 | { |
| rosarium | 0:892175366555 | 115 | M24LR_FIELD_OFF = 0, |
| rosarium | 0:892175366555 | 116 | M24LR_FIELD_ON |
| rosarium | 0:892175366555 | 117 | } M24LR_FIELD_STATUS; |
| rosarium | 0:892175366555 | 118 | |
| rosarium | 0:892175366555 | 119 | /** |
| rosarium | 0:892175366555 | 120 | * @brief M24LR TT-PROG status enumerator definition |
| rosarium | 0:892175366555 | 121 | */ |
| rosarium | 0:892175366555 | 122 | typedef enum |
| rosarium | 0:892175366555 | 123 | { |
| rosarium | 0:892175366555 | 124 | M24LR_T_PROG_NO = 0, |
| rosarium | 0:892175366555 | 125 | M24LR_T_PROG_OK |
| rosarium | 0:892175366555 | 126 | } M24LR_T_PROG_STATUS; |
| rosarium | 0:892175366555 | 127 | |
| rosarium | 0:892175366555 | 128 | /** |
| rosarium | 0:892175366555 | 129 | * @brief M24LR Energy Harvesting status enumerator definition |
| rosarium | 0:892175366555 | 130 | */ |
| rosarium | 0:892175366555 | 131 | typedef enum |
| rosarium | 0:892175366555 | 132 | { |
| rosarium | 0:892175366555 | 133 | M24LR_EH_DISABLE = 0, |
| rosarium | 0:892175366555 | 134 | M24LR_EH_ENABLE |
| rosarium | 0:892175366555 | 135 | } M24LR_EH_STATUS; |
| rosarium | 0:892175366555 | 136 | |
| rosarium | 0:892175366555 | 137 | /** |
| rosarium | 0:892175366555 | 138 | * @brief M24LR Energy Harvesting mode enumerator definition |
| rosarium | 0:892175366555 | 139 | */ |
| rosarium | 0:892175366555 | 140 | typedef enum |
| rosarium | 0:892175366555 | 141 | { |
| rosarium | 0:892175366555 | 142 | M24LR_EH_MODE_ENABLE = 0, |
| rosarium | 0:892175366555 | 143 | M24LR_EH_MODE_DISABLE |
| rosarium | 0:892175366555 | 144 | } M24LR_EH_MODE_STATUS; |
| rosarium | 0:892175366555 | 145 | |
| rosarium | 0:892175366555 | 146 | /** |
| rosarium | 0:892175366555 | 147 | * @brief M24LR GPO status enumerator definition |
| rosarium | 0:892175366555 | 148 | */ |
| rosarium | 0:892175366555 | 149 | typedef enum |
| rosarium | 0:892175366555 | 150 | { |
| rosarium | 0:892175366555 | 151 | M24LR_GPO_BUSY = 0, |
| rosarium | 0:892175366555 | 152 | M24LR_GPO_WIP |
| rosarium | 0:892175366555 | 153 | } M24LR_GPO_STATUS; |
| rosarium | 0:892175366555 | 154 | |
| rosarium | 0:892175366555 | 155 | /** |
| rosarium | 0:892175366555 | 156 | * @brief M24LR Memory information structure definition |
| rosarium | 0:892175366555 | 157 | */ |
| rosarium | 0:892175366555 | 158 | typedef struct |
| rosarium | 0:892175366555 | 159 | { |
| rosarium | 0:892175366555 | 160 | uint8_t BlockSize; |
| rosarium | 0:892175366555 | 161 | uint16_t Mem_Size; |
| rosarium | 0:892175366555 | 162 | } M24LR_Mem_Size; |
| rosarium | 0:892175366555 | 163 | |
| rosarium | 0:892175366555 | 164 | /** |
| rosarium | 0:892175366555 | 165 | * @brief M24LR I2C Write Lock register structure definition |
| rosarium | 0:892175366555 | 166 | */ |
| rosarium | 0:892175366555 | 167 | typedef struct |
| rosarium | 0:892175366555 | 168 | { |
| rosarium | 0:892175366555 | 169 | uint8_t sectors_7_0; |
| rosarium | 0:892175366555 | 170 | uint8_t sectors_15_8; |
| rosarium | 0:892175366555 | 171 | uint8_t sectors_23_16; |
| rosarium | 0:892175366555 | 172 | uint8_t sectors_31_24; |
| rosarium | 0:892175366555 | 173 | uint8_t sectors_39_32; |
| rosarium | 0:892175366555 | 174 | uint8_t sectors_47_40; |
| rosarium | 0:892175366555 | 175 | uint8_t sectors_55_48; |
| rosarium | 0:892175366555 | 176 | uint8_t sectors_63_56; |
| rosarium | 0:892175366555 | 177 | } M24LR_Lock_Sectors; |
| rosarium | 0:892175366555 | 178 | |
| rosarium | 0:892175366555 | 179 | /** |
| rosarium | 0:892175366555 | 180 | * @brief M24LR UID information structure definition |
| rosarium | 0:892175366555 | 181 | */ |
| rosarium | 0:892175366555 | 182 | typedef struct |
| rosarium | 0:892175366555 | 183 | { |
| rosarium | 0:892175366555 | 184 | uint32_t MSB_UID; |
| rosarium | 0:892175366555 | 185 | uint32_t LSB_UID; |
| rosarium | 0:892175366555 | 186 | } M24LR_UID; |
| rosarium | 0:892175366555 | 187 | |
| rosarium | 0:892175366555 | 188 | /** |
| rosarium | 0:892175366555 | 189 | * @brief M24LR Sector Security register structure definition |
| rosarium | 0:892175366555 | 190 | */ |
| rosarium | 0:892175366555 | 191 | typedef struct |
| rosarium | 0:892175366555 | 192 | { |
| rosarium | 0:892175366555 | 193 | uint8_t SectorLock; |
| rosarium | 0:892175366555 | 194 | uint8_t RW_Protection; |
| rosarium | 0:892175366555 | 195 | uint8_t PassCtrl; |
| rosarium | 0:892175366555 | 196 | } M24LR_SECTOR_SEC; |
| rosarium | 0:892175366555 | 197 | |
| rosarium | 0:892175366555 | 198 | |
| rosarium | 0:892175366555 | 199 | /** |
| rosarium | 0:892175366555 | 200 | * @} |
| rosarium | 0:892175366555 | 201 | */ |
| rosarium | 0:892175366555 | 202 | |
| rosarium | 1:11ae12d41082 | 203 | class M24LR : public Nfc { |
| rosarium | 0:892175366555 | 204 | public: |
| rosarium | 0:892175366555 | 205 | NFCTAG_StatusTypeDef i2c_Init( void ); |
| rosarium | 0:892175366555 | 206 | NFCTAG_StatusTypeDef i2c_ReadID( uint8_t * const pICRef ); |
| rosarium | 0:892175366555 | 207 | NFCTAG_StatusTypeDef i2c_IsDeviceReady( const uint32_t Trials ); |
| rosarium | 0:892175366555 | 208 | NFCTAG_StatusTypeDef i2c_ConfigureGPO( const uint16_t ITConf ); |
| rosarium | 0:892175366555 | 209 | NFCTAG_StatusTypeDef i2c_GetGPOStatus( uint16_t * const pGPOStatus ); |
| rosarium | 0:892175366555 | 210 | NFCTAG_StatusTypeDef i2c_ReadData( uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte ); |
| rosarium | 0:892175366555 | 211 | NFCTAG_StatusTypeDef i2c_WriteData( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte ); |
| rosarium | 0:892175366555 | 212 | NFCTAG_StatusTypeDef i2c_ReadRegister( uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte ); |
| rosarium | 0:892175366555 | 213 | NFCTAG_StatusTypeDef i2c_WriteRegister( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte ); |
| rosarium | 0:892175366555 | 214 | |
| rosarium | 0:892175366555 | 215 | |
| rosarium | 0:892175366555 | 216 | /* Extended Functions */ |
| rosarium | 0:892175366555 | 217 | NFCTAG_StatusTypeDef i2c_ReadUID( M24LR_UID * const pUid ); |
| rosarium | 0:892175366555 | 218 | NFCTAG_StatusTypeDef i2c_ReadDSFID( uint8_t * const pDsfid ); |
| rosarium | 0:892175366555 | 219 | NFCTAG_StatusTypeDef i2c_ReadAFI( uint8_t * const pAfi ); |
| rosarium | 0:892175366555 | 220 | NFCTAG_StatusTypeDef i2c_ReadI2CLockSector( M24LR_Lock_Sectors * const pLock_sector ); |
| rosarium | 0:892175366555 | 221 | NFCTAG_StatusTypeDef i2c_I2CLockSector( const uint8_t Sector ); |
| rosarium | 0:892175366555 | 222 | NFCTAG_StatusTypeDef i2c_I2CUnlockSector( const uint8_t Sector ); |
| rosarium | 0:892175366555 | 223 | NFCTAG_StatusTypeDef i2c_PresentI2CPassword( const uint32_t PassWord ); |
| rosarium | 0:892175366555 | 224 | NFCTAG_StatusTypeDef i2c_WriteI2CPassword( const uint32_t PassWord ); |
| rosarium | 0:892175366555 | 225 | NFCTAG_StatusTypeDef i2c_ReadSSSx( const uint8_t SectorNb, M24LR_SECTOR_SEC * const pData ); |
| rosarium | 0:892175366555 | 226 | NFCTAG_StatusTypeDef i2c_WriteSSSx( const uint8_t SectorNb, const M24LR_SECTOR_SEC * const pData ); |
| rosarium | 0:892175366555 | 227 | NFCTAG_StatusTypeDef i2c_ReadMemSize( M24LR_Mem_Size * const pSizeInfo ); |
| rosarium | 0:892175366555 | 228 | NFCTAG_StatusTypeDef i2c_GetRF_WIP_BUSY( M24LR_GPO_STATUS * const pRf_Wip_Busy ); |
| rosarium | 0:892175366555 | 229 | NFCTAG_StatusTypeDef i2c_SetRFBUSY( void ); |
| rosarium | 0:892175366555 | 230 | NFCTAG_StatusTypeDef i2c_SetRFWIP( void ); |
| rosarium | 0:892175366555 | 231 | NFCTAG_StatusTypeDef i2c_Read_EH_mode( M24LR_EH_MODE_STATUS * const pEH_mode ); |
| rosarium | 0:892175366555 | 232 | NFCTAG_StatusTypeDef i2c_Enable_EH_mode( void ); |
| rosarium | 0:892175366555 | 233 | NFCTAG_StatusTypeDef i2c_Disable_EH_mode( void ); |
| rosarium | 0:892175366555 | 234 | NFCTAG_StatusTypeDef i2c_ReadEH_Cfg( M24LR_EH_CFG_VOUT * const pEH_Cfg ); |
| rosarium | 0:892175366555 | 235 | NFCTAG_StatusTypeDef i2c_WriteEH_Cfg( const M24LR_EH_CFG_VOUT EH_Cfg ); |
| rosarium | 0:892175366555 | 236 | NFCTAG_StatusTypeDef i2c_GetEH( M24LR_EH_STATUS * const pEH_Val ); |
| rosarium | 0:892175366555 | 237 | NFCTAG_StatusTypeDef i2c_SetEH( void ); |
| rosarium | 0:892175366555 | 238 | NFCTAG_StatusTypeDef i2c_ResetEH( void ); |
| rosarium | 0:892175366555 | 239 | NFCTAG_StatusTypeDef i2c_GetRFField( M24LR_FIELD_STATUS * const pRF_Field ); |
| rosarium | 0:892175366555 | 240 | NFCTAG_StatusTypeDef i2c_GetTProg( M24LR_T_PROG_STATUS * const pT_Prog ); |
| rosarium | 0:892175366555 | 241 | |
| rosarium | 0:892175366555 | 242 | void Enable_EnergyHarvesting( void ); |
| rosarium | 0:892175366555 | 243 | NFCTAG_StatusTypeDef Initialization( void ); |
| rosarium | 0:892175366555 | 244 | |
| rosarium | 1:11ae12d41082 | 245 | virtual NFC_StatusTypeDef ReadBinary(uint16_t Offset, uint8_t NbByteToRead, |
| rosarium | 1:11ae12d41082 | 246 | uint8_t *pBufferRead) { |
| rosarium | 1:11ae12d41082 | 247 | return (NFC_StatusTypeDef) i2c_ReadData( pBufferRead, Offset, NbByteToRead ); |
| rosarium | 1:11ae12d41082 | 248 | |
| rosarium | 1:11ae12d41082 | 249 | } |
| rosarium | 1:11ae12d41082 | 250 | |
| rosarium | 1:11ae12d41082 | 251 | virtual NFC_StatusTypeDef UpdateBinary(uint16_t Offset, |
| rosarium | 1:11ae12d41082 | 252 | uint8_t NbByteToWrite,uint8_t *pDataToWrite) { |
| rosarium | 1:11ae12d41082 | 253 | return (NFC_StatusTypeDef) i2c_WriteData( pDataToWrite, Offset, NbByteToWrite ); |
| rosarium | 1:11ae12d41082 | 254 | } |
| rosarium | 1:11ae12d41082 | 255 | |
| rosarium | 0:892175366555 | 256 | M24LR(uint8_t const address, uint8_t const addressData, DevI2C &devI2C ): |
| rosarium | 1:11ae12d41082 | 257 | NDefTagUtil(*this), i2c_address_syst(address), i2c_address_data(addressData), dev_I2C(devI2C) {} |
| rosarium | 0:892175366555 | 258 | |
| rosarium | 0:892175366555 | 259 | static uint8_t NfctagInitialized; |
| rosarium | 1:11ae12d41082 | 260 | |
| rosarium | 1:11ae12d41082 | 261 | friend class NDEF_URI; |
| rosarium | 1:11ae12d41082 | 262 | |
| rosarium | 1:11ae12d41082 | 263 | /* |
| rosarium | 1:11ae12d41082 | 264 | * Object implementing the interface to use the NDefLib. |
| rosarium | 1:11ae12d41082 | 265 | */ |
| rosarium | 1:11ae12d41082 | 266 | NDefNfcTagM24LR NDefTagUtil; |
| rosarium | 1:11ae12d41082 | 267 | |
| rosarium | 0:892175366555 | 268 | uint8_t i2c_address_syst; |
| rosarium | 0:892175366555 | 269 | uint8_t i2c_address_data; |
| rosarium | 0:892175366555 | 270 | DevI2C dev_I2C; |
| rosarium | 1:11ae12d41082 | 271 | |
| rosarium | 1:11ae12d41082 | 272 | NDefLib::NDefNfcTag& getNDefTag(){ |
| rosarium | 1:11ae12d41082 | 273 | return NDefTagUtil; |
| rosarium | 1:11ae12d41082 | 274 | } |
| rosarium | 1:11ae12d41082 | 275 | |
| rosarium | 1:11ae12d41082 | 276 | // Not Required from Nfc Class |
| rosarium | 1:11ae12d41082 | 277 | /** |
| rosarium | 1:11ae12d41082 | 278 | * Open a I2C connection with the tag if an RF connection isn't already open. |
| rosarium | 1:11ae12d41082 | 279 | * @return operation status |
| rosarium | 1:11ae12d41082 | 280 | */ |
| rosarium | 1:11ae12d41082 | 281 | virtual NFC_StatusTypeDef GetSession(void){ |
| rosarium | 1:11ae12d41082 | 282 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 283 | } |
| rosarium | 1:11ae12d41082 | 284 | |
| rosarium | 1:11ae12d41082 | 285 | /** |
| rosarium | 1:11ae12d41082 | 286 | * Force to open an I2C connection , abort the RF connection. |
| rosarium | 1:11ae12d41082 | 287 | * @return NFC_SUCCESS if the session is acquired |
| rosarium | 1:11ae12d41082 | 288 | */ |
| rosarium | 1:11ae12d41082 | 289 | virtual NFC_StatusTypeDef ForceGetSession(void){ |
| rosarium | 1:11ae12d41082 | 290 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 291 | } |
| rosarium | 1:11ae12d41082 | 292 | |
| rosarium | 1:11ae12d41082 | 293 | /** |
| rosarium | 1:11ae12d41082 | 294 | * Close an I2C connection. |
| rosarium | 1:11ae12d41082 | 295 | * @return NFC_SUCCESS if the session is release |
| rosarium | 1:11ae12d41082 | 296 | */ |
| rosarium | 1:11ae12d41082 | 297 | virtual NFC_StatusTypeDef Deselect(void){ |
| rosarium | 1:11ae12d41082 | 298 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 299 | } |
| rosarium | 1:11ae12d41082 | 300 | |
| rosarium | 1:11ae12d41082 | 301 | /** |
| rosarium | 1:11ae12d41082 | 302 | * Select the application file. |
| rosarium | 1:11ae12d41082 | 303 | * @return NFC_SUCCESS if the application is selected |
| rosarium | 1:11ae12d41082 | 304 | */ |
| rosarium | 1:11ae12d41082 | 305 | virtual NFC_StatusTypeDef SelectApplication(void){ |
| rosarium | 1:11ae12d41082 | 306 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 307 | } |
| rosarium | 1:11ae12d41082 | 308 | |
| rosarium | 1:11ae12d41082 | 309 | /** |
| rosarium | 1:11ae12d41082 | 310 | * Select the CC file. |
| rosarium | 1:11ae12d41082 | 311 | * @return NFC_SUCCESS if the CC file is selected. |
| rosarium | 1:11ae12d41082 | 312 | */ |
| rosarium | 1:11ae12d41082 | 313 | virtual NFC_StatusTypeDef SelectCCfile(void){ |
| rosarium | 1:11ae12d41082 | 314 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 315 | } |
| rosarium | 1:11ae12d41082 | 316 | |
| rosarium | 1:11ae12d41082 | 317 | /** |
| rosarium | 1:11ae12d41082 | 318 | * Select the NDEF file. |
| rosarium | 1:11ae12d41082 | 319 | * @param NDEFfileId File id to open. |
| rosarium | 1:11ae12d41082 | 320 | * @return NFC_SUCCESS if the file is selected |
| rosarium | 1:11ae12d41082 | 321 | */ |
| rosarium | 1:11ae12d41082 | 322 | virtual NFC_StatusTypeDef SelectNDEFfile(uint16_t NDEFfileId){ |
| rosarium | 1:11ae12d41082 | 323 | (void)NDEFfileId; |
| rosarium | 1:11ae12d41082 | 324 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 325 | } |
| rosarium | 1:11ae12d41082 | 326 | |
| rosarium | 1:11ae12d41082 | 327 | /** |
| rosarium | 1:11ae12d41082 | 328 | * Select the system file. |
| rosarium | 1:11ae12d41082 | 329 | * @return NFC_SUCCESS if the system file is selected |
| rosarium | 1:11ae12d41082 | 330 | */ |
| rosarium | 1:11ae12d41082 | 331 | virtual NFC_StatusTypeDef SelectSystemfile(void){ |
| rosarium | 1:11ae12d41082 | 332 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 333 | } |
| rosarium | 1:11ae12d41082 | 334 | |
| rosarium | 1:11ae12d41082 | 335 | |
| rosarium | 1:11ae12d41082 | 336 | |
| rosarium | 1:11ae12d41082 | 337 | |
| rosarium | 1:11ae12d41082 | 338 | |
| rosarium | 1:11ae12d41082 | 339 | /** |
| rosarium | 1:11ae12d41082 | 340 | * Check that the password is correct. |
| rosarium | 1:11ae12d41082 | 341 | * @param uPwdId Password type. |
| rosarium | 1:11ae12d41082 | 342 | * @param NbPwdByte Password size ( must be 0x10). |
| rosarium | 1:11ae12d41082 | 343 | * @param pPwd Password buffer. |
| rosarium | 1:11ae12d41082 | 344 | * @return NFC_SUCCESS if no errors and write/read permission granted |
| rosarium | 1:11ae12d41082 | 345 | */ |
| rosarium | 1:11ae12d41082 | 346 | virtual NFC_StatusTypeDef Verify(PasswordType_t uPwdId, uint8_t NbPwdByte,const uint8_t *pPwd){ |
| rosarium | 1:11ae12d41082 | 347 | (void)uPwdId; (void)NbPwdByte; (void)pPwd; |
| rosarium | 1:11ae12d41082 | 348 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 349 | } |
| rosarium | 1:11ae12d41082 | 350 | |
| rosarium | 1:11ae12d41082 | 351 | /** |
| rosarium | 1:11ae12d41082 | 352 | * Replace the read or write password. |
| rosarium | 1:11ae12d41082 | 353 | * @param uPwdId Password to change. |
| rosarium | 1:11ae12d41082 | 354 | * @param pPwd New password. |
| rosarium | 1:11ae12d41082 | 355 | * @return NFC_SUCCESS if no errors |
| rosarium | 1:11ae12d41082 | 356 | */ |
| rosarium | 1:11ae12d41082 | 357 | virtual NFC_StatusTypeDef ChangeReferenceData(PasswordType_t uPwdId,const uint8_t *pPwd){ |
| rosarium | 1:11ae12d41082 | 358 | (void)uPwdId; (void)pPwd; |
| rosarium | 1:11ae12d41082 | 359 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 360 | } |
| rosarium | 1:11ae12d41082 | 361 | |
| rosarium | 1:11ae12d41082 | 362 | /** |
| rosarium | 1:11ae12d41082 | 363 | * Activate NDEF file password protection. |
| rosarium | 1:11ae12d41082 | 364 | * When this command is successful, read or write access to the NDEF file is protected by a 128-bit password. |
| rosarium | 1:11ae12d41082 | 365 | * @param uReadOrWrite Read or write password. |
| rosarium | 1:11ae12d41082 | 366 | * @return NFC_SUCCESS if no errors |
| rosarium | 1:11ae12d41082 | 367 | */ |
| rosarium | 1:11ae12d41082 | 368 | virtual NFC_StatusTypeDef EnableVerificationRequirement(PasswordType_t uReadOrWrite){ |
| rosarium | 1:11ae12d41082 | 369 | (void)uReadOrWrite; |
| rosarium | 1:11ae12d41082 | 370 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 371 | } |
| rosarium | 1:11ae12d41082 | 372 | |
| rosarium | 1:11ae12d41082 | 373 | /** |
| rosarium | 1:11ae12d41082 | 374 | * Deactivate NDEF file password protection. |
| rosarium | 1:11ae12d41082 | 375 | * When this command is successful, read or write access to the NDEF file is granted. |
| rosarium | 1:11ae12d41082 | 376 | * with no security enforcement. |
| rosarium | 1:11ae12d41082 | 377 | * @param uReadOrWrite Read or write password. |
| rosarium | 1:11ae12d41082 | 378 | * @return NFC_SUCCESS if no errors |
| rosarium | 1:11ae12d41082 | 379 | */ |
| rosarium | 1:11ae12d41082 | 380 | virtual NFC_StatusTypeDef DisableVerificationRequirement(PasswordType_t uReadOrWrite){ |
| rosarium | 1:11ae12d41082 | 381 | (void)uReadOrWrite; |
| rosarium | 1:11ae12d41082 | 382 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 383 | } |
| rosarium | 1:11ae12d41082 | 384 | |
| rosarium | 1:11ae12d41082 | 385 | /** |
| rosarium | 1:11ae12d41082 | 386 | * Same as {@link NFC#ReadBinary}, however permitting to read more bytes than available. |
| rosarium | 1:11ae12d41082 | 387 | * @param Offset read offset. |
| rosarium | 1:11ae12d41082 | 388 | * @param NbByteToRead Number of bytes to read. |
| rosarium | 1:11ae12d41082 | 389 | * @param[out] pBufferRead Buffer to store the read data into. |
| rosarium | 1:11ae12d41082 | 390 | * @return NFC_SUCCESS if no errors |
| rosarium | 1:11ae12d41082 | 391 | */ |
| rosarium | 1:11ae12d41082 | 392 | virtual NFC_StatusTypeDef STReadBinary(uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead){ |
| rosarium | 1:11ae12d41082 | 393 | (void)Offset; (void)NbByteToRead; (void)pBufferRead; |
| rosarium | 1:11ae12d41082 | 394 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 395 | } |
| rosarium | 1:11ae12d41082 | 396 | |
| rosarium | 1:11ae12d41082 | 397 | /** |
| rosarium | 1:11ae12d41082 | 398 | * Set the tag as read/write only, stored in the eeprom. |
| rosarium | 1:11ae12d41082 | 399 | * @param uReadOrWrite ReadPwd if write only, WritePwd if read only. |
| rosarium | 1:11ae12d41082 | 400 | * @return NFC_SUCCESS if no errors |
| rosarium | 1:11ae12d41082 | 401 | */ |
| rosarium | 1:11ae12d41082 | 402 | virtual NFC_StatusTypeDef EnablePermanentState(PasswordType_t uReadOrWrite){ |
| rosarium | 1:11ae12d41082 | 403 | (void)uReadOrWrite; |
| rosarium | 1:11ae12d41082 | 404 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 405 | } |
| rosarium | 1:11ae12d41082 | 406 | |
| rosarium | 1:11ae12d41082 | 407 | /** |
| rosarium | 1:11ae12d41082 | 408 | * Unset the tag as read/write only, stored in the eeprom. |
| rosarium | 1:11ae12d41082 | 409 | * @param uReadOrWrite ReadPwd if write only, WritePwd if read only. |
| rosarium | 1:11ae12d41082 | 410 | * @return NFC_SUCCESS if no errors |
| rosarium | 1:11ae12d41082 | 411 | * @par Caller must have I2Csuper user permissions to call this function. |
| rosarium | 1:11ae12d41082 | 412 | */ |
| rosarium | 1:11ae12d41082 | 413 | virtual NFC_StatusTypeDef DisablePermanentState(PasswordType_t uReadOrWrite){ |
| rosarium | 1:11ae12d41082 | 414 | (void)uReadOrWrite; |
| rosarium | 1:11ae12d41082 | 415 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 416 | } |
| rosarium | 1:11ae12d41082 | 417 | |
| rosarium | 1:11ae12d41082 | 418 | /** |
| rosarium | 1:11ae12d41082 | 419 | * Set the gpo output pin. |
| rosarium | 1:11ae12d41082 | 420 | * @param uSetOrReset New pin status. |
| rosarium | 1:11ae12d41082 | 421 | * @return NFC_SUCCESS if no errors |
| rosarium | 1:11ae12d41082 | 422 | */ |
| rosarium | 1:11ae12d41082 | 423 | virtual NFC_StatusTypeDef StateControl(uint8_t uSetOrReset){ |
| rosarium | 1:11ae12d41082 | 424 | (void)uSetOrReset; |
| rosarium | 1:11ae12d41082 | 425 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 426 | } |
| rosarium | 1:11ae12d41082 | 427 | |
| rosarium | 1:11ae12d41082 | 428 | /** |
| rosarium | 1:11ae12d41082 | 429 | * @brief This function configures GPO for I2C session. |
| rosarium | 1:11ae12d41082 | 430 | * @param GPO_I2Cconfig GPO configuration to set. |
| rosarium | 1:11ae12d41082 | 431 | * @return NFC_SUCCESS if no errors |
| rosarium | 1:11ae12d41082 | 432 | * @par if the configuration is I2C_ANSWER_READY, the component will start to work |
| rosarium | 1:11ae12d41082 | 433 | * in async mode. |
| rosarium | 1:11ae12d41082 | 434 | */ |
| rosarium | 1:11ae12d41082 | 435 | virtual NFC_StatusTypeDef ManageI2CGPO(NFC_GPO_MGMT GPO_I2Cconfig){ |
| rosarium | 1:11ae12d41082 | 436 | (void)GPO_I2Cconfig; |
| rosarium | 1:11ae12d41082 | 437 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 438 | } |
| rosarium | 1:11ae12d41082 | 439 | |
| rosarium | 1:11ae12d41082 | 440 | /** |
| rosarium | 1:11ae12d41082 | 441 | * @brief This function configures GPO for RF session. |
| rosarium | 1:11ae12d41082 | 442 | * @param GPO_RFconfig GPO configuration to set. |
| rosarium | 1:11ae12d41082 | 443 | * @return NFC_SUCCESS if no errors |
| rosarium | 1:11ae12d41082 | 444 | */ |
| rosarium | 1:11ae12d41082 | 445 | virtual NFC_StatusTypeDef ManageRFGPO(uint8_t GPO_RFconfig){ |
| rosarium | 1:11ae12d41082 | 446 | (void)GPO_RFconfig; |
| rosarium | 1:11ae12d41082 | 447 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 448 | } |
| rosarium | 1:11ae12d41082 | 449 | |
| rosarium | 1:11ae12d41082 | 450 | /** |
| rosarium | 1:11ae12d41082 | 451 | * @brief This function enables or disables the RF communication. |
| rosarium | 1:11ae12d41082 | 452 | * @param OnOffChoice GPO configuration to set. |
| rosarium | 1:11ae12d41082 | 453 | * @return NFC_SUCCESS if no errors |
| rosarium | 1:11ae12d41082 | 454 | */ |
| rosarium | 1:11ae12d41082 | 455 | virtual NFC_StatusTypeDef RFConfig(uint8_t OnOffChoice){ |
| rosarium | 1:11ae12d41082 | 456 | (void)OnOffChoice; |
| rosarium | 1:11ae12d41082 | 457 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 458 | } |
| rosarium | 1:11ae12d41082 | 459 | |
| rosarium | 1:11ae12d41082 | 460 | /** |
| rosarium | 1:11ae12d41082 | 461 | * Generates a negative pulse on the GPO pin. |
| rosarium | 1:11ae12d41082 | 462 | * Pulse starts immediately after the command is issued and ends at the end of the RF response. |
| rosarium | 1:11ae12d41082 | 463 | * @return NFC_SUCCESS if no errors |
| rosarium | 1:11ae12d41082 | 464 | */ |
| rosarium | 1:11ae12d41082 | 465 | virtual NFC_StatusTypeDef SendInterrupt(void){ |
| rosarium | 1:11ae12d41082 | 466 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 467 | } |
| rosarium | 1:11ae12d41082 | 468 | |
| rosarium | 1:11ae12d41082 | 469 | virtual NFC_StatusTypeDef ManageEvent(){ |
| rosarium | 1:11ae12d41082 | 470 | return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 471 | } |
| rosarium | 1:11ae12d41082 | 472 | |
| rosarium | 1:11ae12d41082 | 473 | virtual int Init(void *ptr) { |
| rosarium | 1:11ae12d41082 | 474 | (void)ptr; |
| rosarium | 1:11ae12d41082 | 475 | return (NFC_StatusTypeDef) i2c_Init(); |
| rosarium | 1:11ae12d41082 | 476 | //return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 477 | } |
| rosarium | 1:11ae12d41082 | 478 | |
| rosarium | 1:11ae12d41082 | 479 | virtual int ReadID(uint8_t *id) { |
| rosarium | 1:11ae12d41082 | 480 | return (NFC_StatusTypeDef) i2c_ReadID(id); |
| rosarium | 1:11ae12d41082 | 481 | // return(NFC_SUCCESS); |
| rosarium | 1:11ae12d41082 | 482 | } |
| rosarium | 1:11ae12d41082 | 483 | |
| rosarium | 0:892175366555 | 484 | }; |
| rosarium | 0:892175366555 | 485 | |
| rosarium | 0:892175366555 | 486 | |
| rosarium | 0:892175366555 | 487 | |
| rosarium | 0:892175366555 | 488 | |
| rosarium | 0:892175366555 | 489 | #endif /* __M24LR_H */ |
