MCP79410RK
Public Member Functions
MCP79410SRAM Class Reference

Class for accessing the MCP79410 SRAM (static RAM) More...

#include <MCP79410RK.h>

Inheritance diagram for MCP79410SRAM:
MCP79410MemoryBase

Public Member Functions

 MCP79410SRAM (MCP79410 *parent)
 Class to read and write the 64-byte SRAM (battery backed RAM) block in the MCP79410. More...
 
virtual ~MCP79410SRAM ()
 Destructor. Not normally used as MCP79410 constructs this object and the MCP79410 is typically a global object.
 
virtual size_t length () const
 Returns the length (64)
 
virtual uint8_t eraseValue () const
 Erase erases to 0. More...
 
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
MCP79410parent
 The MCP79410 object that this object is associated with.
 

Detailed Description

Class for accessing the MCP79410 SRAM (static RAM)

The SRAM is fast to access and does not wear out. It's saved as long as there's power or the backup battery, so it's not as non-volatile as the EEPROM, but a good place to store up to 64 bytes of data.

You do not instantiate one of these, use the rtc.sram() method to get a reference to this object.

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.

Constructor & Destructor Documentation

◆ MCP79410SRAM()

MCP79410SRAM::MCP79410SRAM ( MCP79410 parent)

Class to read and write the 64-byte SRAM (battery backed RAM) block in the MCP79410.

You should never construct one of these; the object is exposed by the MCP79410 class.

Member Function Documentation

◆ eraseValue()

virtual uint8_t MCP79410SRAM::eraseValue ( ) const
inlinevirtual

Erase erases to 0.

Note that on cold power up, the values are random, not zero!

Implements MCP79410MemoryBase.

◆ readData()

bool MCP79410SRAM::readData ( size_t  addr,
uint8_t *  data,
size_t  dataLen 
)
virtual

Low-level API to read data from memory.

Parameters
addrAddress in the memory block (0 = beginning of block; do not use hardware register address)
dataPointer to buffer to store data in
dataLenNumber of bytes to read

Implements MCP79410MemoryBase.

◆ writeData()

bool MCP79410SRAM::writeData ( size_t  addr,
const uint8_t *  data,
size_t  dataLen 
)
virtual

Low-level API to write data to memory.

Parameters
addrAddress in the memory block (0 = beginning of block; do not use hardware register address)
dataPointer to buffer containing the data to write to memory. Buffer is not modified (is const).
dataLenNumber of bytes to write

Implements MCP79410MemoryBase.


The documentation for this class was generated from the following files: