Update current library to accommodate small devices.

Revision:
5:02908f98dca1
Parent:
4:5b7d065a1c78
Child:
6:8dc89c3b4718
diff -r 5b7d065a1c78 -r 02908f98dca1 I2CEEPROM.cpp
--- a/I2CEEPROM.cpp	Sun Oct 16 11:54:09 2016 +0000
+++ b/I2CEEPROM.cpp	Sun Oct 16 13:14:58 2016 +0000
@@ -29,7 +29,7 @@
     // Check the address and size fit onto the chip.
     if (!checkSpace(address, 1))
         return 0;
-    if(m_chipSize == 256 || m_chipSize == 128) {
+    if(m_chipSize == 256 || m_chipSize == 128 || m_chipSize == 16) {
         char values[] = { (address & 0xFF) };
         if (m_i2c.write(m_i2cAddress, values, 1) == 0) {
             if (m_i2c.read(m_i2cAddress, &value, 1) == 0) {
@@ -55,7 +55,7 @@
     if (!checkSpace(address, size))
         return 0;
 
-    if(m_chipSize == 256 || m_chipSize == 128) {
+    if(m_chipSize == 256 || m_chipSize == 128 || m_chipSize == 16) {
         char values[] = { (address & 0xFF) };
         if (m_i2c.write(m_i2cAddress, values, 1) == 0) {
             if (m_i2c.read(m_i2cAddress, buffer, size) == 0) {
@@ -81,7 +81,7 @@
     if (!checkSpace(address, 1))
         return 0;
 
-    if(m_chipSize == 256 || m_chipSize == 128) {
+    if(m_chipSize == 256 || m_chipSize == 128 || m_chipSize == 16) {
         char values[] = { (address & 0xFF), value };
         if (m_i2c.write(m_i2cAddress, values, 2) != 0) {
             return 0;
@@ -130,7 +130,7 @@
    
         //pc.printf("Writing [%.*s] at %d size %d\n\r", toWrite, page, address, toWrite);
         // Start the page write with the address in one write call.
-        if(m_chipSize == 256 || m_chipSize == 128) {
+        if(m_chipSize == 256 || m_chipSize == 128 || m_chipSize == 16) {
             for (int count = 0; count != toWrite; ++count) {
                 int addr = address + count;
                 char values[] = { (addr & 0xFF), *page };
@@ -189,7 +189,7 @@
         
         //printf("Writing %d at %d size %d\n\r", value, address, toWrite);
         // Start the page write with the address in one write call.
-        if(m_chipSize == 256 || m_chipSize == 128) {
+        if(m_chipSize == 256 || m_chipSize == 128 || m_chipSize == 16) {
             for (int count = 0; count != toWrite; ++count) {
                 int addr = address + count;
                 char values[] = { (addr & 0xFF), value };
@@ -225,10 +225,10 @@
     // 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) {
+    while (m_i2c.write(m_i2cAddress, 0, 1) != 0) {
         // Wait for ack.
-        wait_ms(5);
-    //}
+        wait_ms(1);
+    }
 }
 
 bool I2CEEPROM::checkSpace(size_t address, size_t size) {