MCP79410RK
|
Class for accessing the MCP79410 EEPROM. More...
#include <MCP79410RK.h>
Public Member Functions | |
MCP79410EEPROM (MCP79410 *parent) | |
Class to read and write the 64-byte SRAM (battery backed RAM) block in the MCP79410. More... | |
virtual | ~MCP79410EEPROM () |
Destructor. Not normally used as MCP79410 constructs this object and the MCP79410 is typically a global object. | |
uint8_t | getBlockProtection () const |
Get the EEPROM block protection register. More... | |
bool | setBlockProtection (uint8_t value) |
Sets the block protection. More... | |
bool | protectedBlockRead (uint8_t *buf) |
Read from the 8-byte protected block in EEPROM. More... | |
virtual size_t | length () const |
Returns the length (128) | |
virtual uint8_t | eraseValue () const |
Erased value is 0xff. | |
virtual bool | readData (size_t addr, uint8_t *data, size_t dataLen) |
Low-level API to read data from memory. More... | |
virtual bool | writeData (size_t addr, const uint8_t *data, size_t dataLen) |
Low-level API to write data to memory. More... | |
Public Member Functions inherited from MCP79410MemoryBase | |
MCP79410MemoryBase (MCP79410 *parent) | |
Constructor. | |
virtual | ~MCP79410MemoryBase () |
Destructor. | |
virtual bool | erase () |
Erase the memory. More... | |
template<typename T > | |
T & | get (size_t addr, T &t) |
Templated accessor to get data from a specific offset. This API works like the EEPROM API. More... | |
template<typename T > | |
const T & | put (size_t addr, const T &t) |
Templated accessor to set data at a specific offset. This API works like the EEPROM API. More... | |
Additional Inherited Members | |
Protected Attributes inherited from MCP79410MemoryBase | |
MCP79410 * | parent |
The MCP79410 object that this object is associated with. | |
Class for accessing the MCP79410 EEPROM.
The EEPROM is non-volatile, and values persist even when both the power and backup battery are removed. It is slow to write to and has a finite number of write cycles.
You do not instantiate one of these, use the rtc.eeprom() method to get a reference to this object.
The default from the factory is 0xff bytes in all locations.
While you can use readData() and writeData(), you can also use the get() and put() methods like the EEPROM API to read and write primitives (int, bool, etc.) as well as structures. Note that you cannot get and put a String or char *, however, you can only store an array of characters.
MCP79410EEPROM::MCP79410EEPROM | ( | MCP79410 * | parent | ) |
uint8_t MCP79410EEPROM::getBlockProtection | ( | ) | const |
Get the EEPROM block protection register.
Constant | Value | Description |
---|---|---|
MCP79410::EEPROM_PROTECT_NONE | 0x0; | Able to write all bytes |
MCP79410::EEPROM_PROTECT_UPPER_QUARTER | 0x1 | 0x60 - 0x7f protected from writing |
MCP79410::EEPROM_PROTECT_UPPER_HALF | 0x2 | 0x40 - 0x7f protected from writing |
MCP79410::EEPROM_PROTECT_ALL | 0x3 | All bytes protected from writing |
The default value from the factory is 0 (EEPROM_PROTECT_NONE).
Setting it to other values will cause writes to the protected sections to not actually write until you change the protection register to allow writes again.
Note: block protection is separate from the 8-byte protected block, which is confusing.
bool MCP79410EEPROM::protectedBlockRead | ( | uint8_t * | buf | ) |
Read from the 8-byte protected block in EEPROM.
buf | A pointer to an 8-byte buffer to hold the data. |
The constant MCP79410::EEPROM_PROTECTED_BLOCK_SIZE can be used instead of 8.
This is different from the block protection (getBlockProtection() and setBlockProtection(). This protected block can only be written to using a special technique. See MCP79410::eepromProtectedBlockWrite.
This block is normally used for things like MAC addresses, board identification codes, etc. that are programmed once at the factory and never reset in the field.
The default from the factory is 0xff bytes for all 8 bytes.
|
virtual |
Low-level API to read data from memory.
addr | Address in the memory block (0 = beginning of block; do not use hardware register address) |
data | Pointer to buffer to store data in |
dataLen | Number of bytes to read |
Implements MCP79410MemoryBase.
bool MCP79410EEPROM::setBlockProtection | ( | uint8_t | value | ) |
Sets the block protection.
value | The value, such as MCP79410::EEPROM_PROTECT_NONE. See getBlockProtection() for more details. |
|
virtual |
Low-level API to write data to memory.
addr | Address in the memory block (0 = beginning of block; do not use hardware register address) |
data | Pointer to buffer containing the data to write to memory. Buffer is not modified (is const). |
dataLen | Number of bytes to write |
Implements MCP79410MemoryBase.