Class to provide simple access to I2C EEPROM chiles like Microchip's 24LC range or AMTELS AT24C range. Chips up to 64Kb in size are directly supported. Updated to Mbed OS v 5.1
Diff: I2CEeprom.h
- Revision:
- 7:29e505d37158
- Parent:
- 6:0b18a49e03b9
- Child:
- 8:0c122f839dc9
--- a/I2CEeprom.h Sat Mar 28 12:51:37 2020 +0000 +++ b/I2CEeprom.h Sat Mar 28 13:42:18 2020 +0000 @@ -24,9 +24,17 @@ /// Chips up to 64Kb in size are directly supported. /// The class handles multiple page writes so any amount of data can be written in /// a single call to write. -/// -/// Although not tested it should work with the MAC versions of Microchip range -/// as well but the chipSize will need to be set to include the ROM area as well. +/// At start of a write(addr,buffer,size), a buffer of up to pageSize + 2 +/// is allocated on the heap, and the data and address are copied to it. +/// This allows the write to proceed without unlocking, which might allow +/// another device on the bus access and so corrupt the write. +/// This allocation per write fits my usecase, where eeeprom variables +/// are written in a special menu mode at start up, but it may be better to +/// preallocate a buffer once at startup, if writes are occurring at arbitrary +/// times during execution to prevent surprises with out of memory issues +/// when trying to write during normal execution. +/// +/// Tested on a Microchip 24LC128. class I2CEeprom { public: /// Constructor to create a new instance of the class.