-
-
Notifications
You must be signed in to change notification settings - Fork 127
EepromAt24c32 object
EepromAt24c32 object provides access to all the functions of the At24cXX eeprom chip often found on a DS3231 module.
Construct a eeprom object using the provided WIRE method and address bits configuration
T_WIRE_METHOD - the typename of the class to use for the wire method. TwoWire
is the normal hardware method class.
wire - the instance of the T_WIRE_METHOD to use. Wire
is the normal hardware instance to use.
addressBits - the configuration of address bits shorted together on the board. By default just leave this off. If you have shorted the pads together to change the address of the eeprom, then provide this value. The order of the bits is A2, A1, A0. By default this value is 0b111
and it is expected that none of the address pads are shorted. If A0 is shorted together on the board, then this value should be 0b110
.
Below is an example of how to create an instance of the object using the normal Arduino hardware Wire support.
#include <Wire.h>
#include <EepromAT24C32.h>
EepromAt24c32<TwoWire> RtcEeprom(Wire);
If you want to use SoftwareWire library, you can replace the above with this and it will work.
#include <SoftwareWire.h>
#include <EepromAT24C32.h>
SoftwareWire myWire(SDA, SCL); // replace with the pins you use
EepromAt24c32<SoftwareWire> RtcEeprom(myWire);
The normal begin method that should be called within Setup()
<return>, the error code from the last Wire transaction. After each method call below, you may check if this return value for an error. See https://www.arduino.cc/en/Reference/WireEndTransmission for values of this error.
memoryAddress - the address within the memory of the eeprom to store a value.
value - the 8 bit value to store.
memoryAddress - the address within the memory of the eeprom to retrieve a value.
<return>, the value of that memory address
This method will write within a single page of eeprom. Pages are 32 bytes (5 bits), so writing past a page boundary will just wrap within the page of the starting memory address.
xxxppppp pppaaaaa => p = page #, a = address within the page
NOTE: Wire limits a single transaction to 32 bytes on many platforms. Due to the EEPROM not supporting sequential writes, this limits the size of a single write, two bytes for the address to write to, and the 30 bytes of data to write.
memoryAddress - the starting address within the memory of the eeprom to copy the following buffer
pValue - the pointer to a buffer of bytes
countBytes - the number of bytes to copy
<return>, the number of bytes actually copied. This maybe smaller than countBytes due to reaching the end of the available memory address page.
memoryAddress - the starting address within the memory of the eeprom to copy from
pValue - the pointer to a buffer of bytes to copy into
countBytes - the number of bytes to copy
<return>, the number of bytes actually copied. This maybe smaller than countBytes due to reaching the end of the available memory.