IoAbstraction
Public Member Functions | List of all members
I2cAt24Eeprom Class Reference

#include <EepromAbstractionWire.h>

Inheritance diagram for I2cAt24Eeprom:
EepromAbstraction

Public Member Functions

 I2cAt24Eeprom (uint8_t address, At24EepromType ty, WireType wireImpl=defaultWireTypePtr)
 
bool hasErrorOccurred () override
 
uint8_t read8 (EepromPosition position) override
 
void write8 (EepromPosition position, uint8_t val) override
 
uint16_t read16 (EepromPosition position) override
 
void write16 (EepromPosition position, uint16_t val) override
 
uint32_t read32 (EepromPosition position) override
 
void write32 (EepromPosition position, uint32_t val) override
 
void readIntoMemArray (uint8_t *memDest, EepromPosition romSrc, uint8_t len) override
 
void writeArrayToRom (EepromPosition romDest, const uint8_t *memSrc, uint8_t len) override
 

Detailed Description

An implementation of eeprom that works with the very well known At24CXXX chips over i2c. Before using this class you must first initialise the Wire library by calling Wire.begin(); If you do not do this, your code may hang. Further, avoid any call to read or write until at least the setup() function is called. This is a limitation of the way the Wire library gets constructed.

It is your responsibility to call Wire.begin because you don't want more than one class reinitialising the Wire library.

Thanks to https://github.com/cyberp/AT24Cx for some of the ideas I've used in this library, although this is implemented differently.

Constructor & Destructor Documentation

◆ I2cAt24Eeprom()

I2cAt24Eeprom::I2cAt24Eeprom ( uint8_t  address,
At24EepromType  ty,
WireType  wireImpl = defaultWireTypePtr 
)

Create an I2C EEPROM object giving it's address and the page size of the device. Page sizes are defined in this header file.

Member Function Documentation

◆ hasErrorOccurred()

bool I2cAt24Eeprom::hasErrorOccurred ( )
overridevirtual

This indicates if an I2C error has ocrrued at any point since the last call to error. Side effect: Every call clears it's state.

Reimplemented from EepromAbstraction.

◆ read8()

uint8_t I2cAt24Eeprom::read8 ( EepromPosition  position)
overridevirtual

Read an 8 bit (byte) value at a specified position

Parameters
positionaddress at which to read

Implements EepromAbstraction.

◆ write8()

void I2cAt24Eeprom::write8 ( EepromPosition  position,
uint8_t  val 
)
overridevirtual

write an 8 bit (byte) value to the specified position

Parameters
positionthe position at which to write
valthe new value

Implements EepromAbstraction.

◆ read16()

uint16_t I2cAt24Eeprom::read16 ( EepromPosition  position)
overridevirtual

read a 16 bit value at position at a specified position

Parameters
positionthe position at which to read

Implements EepromAbstraction.

◆ write16()

void I2cAt24Eeprom::write16 ( EepromPosition  position,
uint16_t  val 
)
overridevirtual

write a 16 bit value to the specified position

Parameters
positionthe position at which to write
valthe value to read

Implements EepromAbstraction.

◆ read32()

uint32_t I2cAt24Eeprom::read32 ( EepromPosition  position)
overridevirtual

read a 32 bit value at a specified position

Parameters
positionthe position at which to read

Implements EepromAbstraction.

◆ write32()

void I2cAt24Eeprom::write32 ( EepromPosition  position,
uint32_t  val 
)
overridevirtual

write a 32 bit value to position

Parameters
positionthe position at which to write
valthe value to write out.

Implements EepromAbstraction.

◆ readIntoMemArray()

void I2cAt24Eeprom::readIntoMemArray ( uint8_t *  memDest,
EepromPosition  romSrc,
uint8_t  len 
)
overridevirtual

Read an array of bytes from EEPROM into memory

Parameters
memDestthe memory where the EEPROM data should be copied to
romSrcthe source position in EEPROM storage
lenthe length of the array

Implements EepromAbstraction.

◆ writeArrayToRom()

void I2cAt24Eeprom::writeArrayToRom ( EepromPosition  romDest,
const uint8_t *  memSrc,
uint8_t  len 
)
overridevirtual

Writes an array of bytes from memory to EEPROM storage

Parameters
romDestthe start position in eeprom storage that the array should be copied to
memSrcthe memory where the rom should be copied from
lenthe length of the array

Implements EepromAbstraction.


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