upm
0.3.1
Sensor/Actuator repository for libmraa (v0.7.2)
|
C++ API for the M24LR64E based Grove NFC Tag. More...
The Grove NFC tag is, in essence, an 8KB 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 data sheet for much more detailed information.
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 the 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 () |
void | getUID (uint8_t *buf) |
uint32_t | getMemorySize () |
void | clearMemory () |
void | writeByte (unsigned int address, uint8_t data) |
void | writeBytes (unsigned int address, uint8_t *buf, unsigned int len) |
uint8_t | readByte (unsigned int address) |
void | readBytes (unsigned int address, uint8_t *buf, unsigned int len) |
Protected Attributes | |
mraa::I2c | m_i2c |
M24LR64E | ( | int | bus, |
AccessMode | mode = USER_MODE |
||
) |
m24lr64e constructor
bus | i2c bus to use |
mode | the access mode (user or root) to use |
bool submitPasswd | ( | uint32_t | passwd | ) |
submit an i2c access password
passwd | the 4-byte access password |
bool writePasswd | ( | uint32_t | passwd | ) |
write a new i2c password
passwd | the 4-byte access password |
void sectorProtectConfig | ( | unsigned int | sectorNumber, |
bool | protectEnable, | ||
SectorAccessRight | accessRight, | ||
SectorSelectPassWd | passwd | ||
) |
Set the protection bit for a sector. Must be in ROOT mode
sectorNumber | the sector whose protection you are modifying |
protectEnable | true if you are enabling protection |
accessRight | the access rights to set |
passwd | the password number to enable, if any |
void clearSectorProtect | ( | void | ) |
Clear the sector protection bits. Must be in ROOT mode.
void sectorWriteLockBit | ( | unsigned int | sectorNumber, |
bool | sockEnable | ||
) |
Set or clear the Sector Security Status Lock bit for a sector. Must be in ROOT mode.
sectorNumber | the sector who's SSS you want to modify |
sockEnable | true r false to set or clear the bit |
uint8_t getDSFID | ( | ) |
return the Data Storage Familiy Identifier Must be in ROOT mode.
uint8_t getAFI | ( | ) |
return the Application Family Identifier Must be in ROOT mode.
void getUID | ( | uint8_t * | buf | ) |
return the Unique ID. Must be in ROOT mode.
buf | buffer to hold returned UID. Must be UID_LENGTH bytes. |
uint32_t getMemorySize | ( | ) |
return the memory size Must be in ROOT mode.
void clearMemory | ( | ) |
set all memory to 0, if permissions allow
void writeByte | ( | unsigned int | address, |
uint8_t | data | ||
) |
write a byte to EEPROM
address | address to write to |
data | data to write |
void writeBytes | ( | unsigned int | address, |
uint8_t * | buf, | ||
unsigned int | len | ||
) |
write bytes to EEPROM
address | address to write to |
data | data to write |
data | length of data buffer |
uint8_t readByte | ( | unsigned int | address | ) |
read a byte from EEPROM
address | address to read from |
void readBytes | ( | unsigned int | address, |
uint8_t * | buf, | ||
unsigned int | len | ||
) |
read multiple bytes from EEPROM
address | address to read from |
buffer | buffer to store data |
len | number of bytes to read |