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

Dependents:   storage_test

Revision:
4:d8f51b136dbd
Parent:
3:b2a132553b02
Child:
12:d9a44fb3b9a6
--- a/I2CEeprom.cpp	Sat Mar 28 01:38:00 2020 +0000
+++ b/I2CEeprom.cpp	Sat Mar 28 01:50:44 2020 +0000
@@ -92,7 +92,7 @@
     }
     return 0;
 }
-// works ok
+
 size_t I2CEeprom::write(size_t address, char value)
 {
     // Check the address and size fit onto the chip.
@@ -109,7 +109,6 @@
     return 1;
 }
 
-
 size_t I2CEeprom::ll_write(size_t address, const char *buffer, size_t size)
 {
     // TODO: change i2c address bits dependent on eeprom data address
@@ -122,7 +121,6 @@
     return size;
 }
 
-// ret num written
 size_t I2CEeprom::write(size_t address, const char *buffer, size_t size)
 {
     if (!checkSpace(address, size)) {
@@ -157,28 +155,12 @@
 
 void I2CEeprom::waitForWrite()
 {
-    
     ThisThread::sleep_for(m_writeCycleTime_ms);
     // The chip doesn't ACK while writing to the actual EEPROM
     // so loop trying to do a zero byte write until it is ACKed
     // by the chip.
     while (m_i2c.write(m_i2cAddress, 0, 0) != 0) {
-        // Wait for ack.
         ThisThread::sleep_for(1);
     }
 }
 
-bool I2CEeprom::checkSpace(size_t address, size_t size)
-{
-    // Only check, if chip size is non-zero.
-    if (m_chipSize != 0) {
-        // Check that the address start in the chip and doesn't
-        // extend past.
-        if ((address >= m_chipSize) || ((address + size) >= m_chipSize))
-            return false;
-        else
-            return true;
-    }
-
-    return true;
-}