32 #define EE_BSEL_NONE 0
33 #define EE_BSEL_8BIT_ADDR 1
34 #define EE_BSEL_17BIT_ADDR 2
35 #define EE_BSEL_17BIT_ADDR_ALT 3
38 #define _EE24(byteSize, pageSize, mode) \
39 (((byteSize) / (pageSize)) | (((unsigned long)(pageSize)) << 16) | \
40 (((unsigned long)(mode)) << 28))
43 #define EEPROM_24LC00 _EE24(16UL, 1, EE_BSEL_8BIT_ADDR)
44 #define EEPROM_24LC01 _EE24(128UL, 8, EE_BSEL_8BIT_ADDR)
45 #define EEPROM_24LC014 _EE24(128UL, 16, EE_BSEL_8BIT_ADDR)
46 #define EEPROM_24LC02 _EE24(256UL, 8, EE_BSEL_8BIT_ADDR)
47 #define EEPROM_24LC024 _EE24(256UL, 16, EE_BSEL_8BIT_ADDR)
48 #define EEPROM_24LC025 _EE24(256UL, 16, EE_BSEL_8BIT_ADDR)
49 #define EEPROM_24LC04 _EE24(512UL, 16, EE_BSEL_8BIT_ADDR)
50 #define EEPROM_24LC08 _EE24(1024UL, 16, EE_BSEL_8BIT_ADDR)
51 #define EEPROM_24LC16 _EE24(2048UL, 16, EE_BSEL_8BIT_ADDR)
52 #define EEPROM_24LC32 _EE24(4096UL, 32, EE_BSEL_NONE)
53 #define EEPROM_24LC64 _EE24(8192UL, 32, EE_BSEL_NONE)
54 #define EEPROM_24LC128 _EE24(16384UL, 32, EE_BSEL_NONE)
55 #define EEPROM_24LC256 _EE24(32768UL, 64, EE_BSEL_NONE)
56 #define EEPROM_24LC512 _EE24(65536UL, 128, EE_BSEL_NONE)
57 #define EEPROM_24LC1025 _EE24(131072UL, 128, EE_BSEL_17BIT_ADDR_ALT)
58 #define EEPROM_24LC1026 _EE24(131072UL, 128, EE_BSEL_17BIT_ADDR)
65 unsigned long size()
const {
return _size; }
66 unsigned long pageSize()
const {
return _pageSize; }
70 uint8_t
read(
unsigned long address);
71 size_t read(
unsigned long address,
void *data,
size_t length);
73 bool write(
unsigned long address, uint8_t value);
74 size_t write(
unsigned long address,
const void *data,
size_t length);
79 unsigned long _pageSize;
83 void writeAddress(
unsigned long address);
unsigned long size() const
Returns the size of the EEPROM in bytes.
uint8_t read(unsigned long address)
Reads a single byte from the EEPROM at address.
Reading and writing EEPROM's from the 24LCXX family.
EEPROM24(I2CMaster &bus, unsigned long type, uint8_t bank=0)
Constructs a new EEPROM access object on bus for an EEPROM of the specified type. ...
bool write(unsigned long address, uint8_t value)
Writes a byte value to address in the EEPROM.
unsigned long pageSize() const
Returns the size of a single EEPROM page in bytes.
Abstract base class for I2C master implementations.
bool available()
Returns true if the EEPROM is available on the I2C bus; false otherwise.