upm
0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
|
C++ API for the M24LR64E-based Grove NFC Tag. More...
Grove NFC tag is an 8KB electrically erasable programmable read-only memory (EEPROM) that can be written to or read from using I2C and NFC-equipped devices.
The user mode (default) allows read and write access to all 8KB of space, provided the sector security status (SSS) allows it. The root mode allows modification of the SSS data and other information, provided the proper password is submitted. The default password for a new tag is 0x00000000. See the datasheet for more details.
The Seeed Studio* wiki page for this device includes a link to an Android* application that can be used to also read and write the device via NFC, as well as set NFC passwords, which cannot be done via I2C.
Public Types | |
enum | M24LR64E_ADDR_T { I2C_PASSWORD_ADDR = 2304, RF_PASSWORD_1_ADDR = 2308, RF_PASSWORD_2_ADDR = 2312, RF_PASSWORD_3_ADDR = 2316, DSFID_ADDR = 2320, AFI_ADDR = 2321, RESV_ADDR = 2322, CONFIG_ADDR = 2323, UID_ADDR = 2324, MEM_SIZE_ADDR = 2332, IC_REF_ADDR = 2335, PROG_COMP_ENERGY_HARVEST_ADDR = 2339 } |
enum | AccessMode { USER_MODE = 0x0, ROOT_MODE = 0x1 } |
enum | SectorAccessRight { Access_1110 = 0, Access_1111 = 1, Access_1100 = 2, Access_0111 = 3 } |
enum | SectorSelectPassWd { noPasswd = 0, passwd_1 = 1, passwd_2 = 2, passwd_3 = 3 } |
Public Member Functions | |
M24LR64E (int bus, AccessMode mode=USER_MODE) | |
~M24LR64E () | |
bool | submitPasswd (uint32_t passwd) |
bool | writePasswd (uint32_t passwd) |
void | sectorProtectConfig (unsigned int sectorNumber, bool protectEnable, SectorAccessRight accessRight, SectorSelectPassWd passwd) |
void | clearSectorProtect (void) |
void | sectorWriteLockBit (unsigned int sectorNumber, bool sockEnable) |
uint8_t | getDSFID () |
uint8_t | getAFI () |
uint8_t * | getUID () |
uint32_t | getMemorySize () |
void | clearMemory () |
mraa::Result | writeByte (unsigned int address, uint8_t data) |
mraa::Result | writeBytes (unsigned int address, uint8_t *buffer, int len) |
uint8_t | readByte (unsigned int address) |
int | readBytes (unsigned int address, uint8_t *buffer, int len) |
Protected Attributes | |
mraa::I2c | m_i2c |
enum M24LR64E_ADDR_T |
M24LR64E addresses, accessible only in the root mode
M24LR64E | ( | int | bus, |
AccessMode | mode = USER_MODE |
||
) |
M24LR64E constructor
bus | I2C bus to use |
mode | Access mode (user or root) to use |
bool submitPasswd | ( | uint32_t | passwd | ) |
Submits an I2C access password
passwd | 4-byte access password |
bool writePasswd | ( | uint32_t | passwd | ) |
Writes a new I2C password
passwd | 4-byte access password |
void sectorProtectConfig | ( | unsigned int | sectorNumber, |
bool | protectEnable, | ||
SectorAccessRight | accessRight, | ||
SectorSelectPassWd | passwd | ||
) |
Sets a protection bit for a sector. Must be in the root mode
sectorNumber | Sector whose protection you are modifying |
protectEnable | True if you are enabling protection |
accessRight | Access rights to set |
passwd | Password number to enable, if any |
void clearSectorProtect | ( | void | ) |
Clears sector protection bits. Must be in the root mode.
void sectorWriteLockBit | ( | unsigned int | sectorNumber, |
bool | sockEnable | ||
) |
Sets or clears a sector security status lock bit for a sector. Must be in the root mode.
sectorNumber | Sector whose SSS you want to modify |
sockEnable | True to set the bit, false to clear it |
uint8_t getDSFID | ( | ) |
Returns a data storage family identifier (DSFID) Must be in the root mode.
uint8_t getAFI | ( | ) |
Returns an application family identifier (AFI) Must be in the root mode.
uint8_t * getUID | ( | ) |
Returns a unique ID. Must be in the root mode. Maintained to preserve compatibility with older code.
uint32_t getMemorySize | ( | ) |
Returns the memory size Must be in the root mode.
void clearMemory | ( | ) |
Sets all memory to 0, if permissions allow
mraa::Result writeByte | ( | unsigned int | address, |
uint8_t | data | ||
) |
Writes a byte to the EEPROM
address | Address to write to |
data | Data to write |
mraa::Result writeBytes | ( | unsigned int | address, |
uint8_t * | buffer, | ||
int | len | ||
) |
Writes bytes to the EEPROM
address | Address to write to |
data | Data to write |
data | Length of the data buffer |
uint8_t readByte | ( | unsigned int | address | ) |
Reads a byte from the EEPROM
address | Address to read from |
int readBytes | ( | unsigned int | address, |
uint8_t * | buffer, | ||
int | len | ||
) |
Reads multiple bytes from the EEPROM
address | Address to read from |
buffer | Buffer to store data |
len | Number of bytes to read |