Fork of 24LCxx_I2C. Works for Renesas EEPROMs. Fixes problems with PageWrites over page boundaries.

Fork of 24LCxx_I2C by Yann Garcia

Revision:
3:fc3eb4d2b07e
Parent:
2:16ce7dae9019
Child:
4:2add27250e69
--- a/24LCxx_I2C.cpp	Thu Jul 18 05:34:34 2013 +0000
+++ b/24LCxx_I2C.cpp	Wed May 21 19:58:39 2014 +0000
@@ -37,7 +37,7 @@
         _internalId.assign(out.str());
         DEBUG("C24LCXX_I2C: _internalId='%s'", _internalId.c_str())
 #endif // __DEBUG
-        _i2cInstance = new I2C(p_sda, p_scl, "24LCxx_I2C");
+        _i2cInstance = new I2C(p_sda, p_scl); //, "24LCxx_I2C");
         C24LCXX_I2C::I2CModuleRefCounter += 1;
         DEBUG_ENTER("C24LCXX_I2C: refCounter=%d", C24LCXX_I2C::I2CModuleRefCounter)
 
@@ -98,7 +98,8 @@
         // 1.Prepare buffer
         char i2cBuffer[3]; // Memory address + one byte of data
         // 1.1. Memory address
-        short address = p_address + 1; // Index start to 1
+        //short address = p_address + 1; // Index start to 1
+        short address = p_address; // no Index + 1
         i2cBuffer[0] = (unsigned char)(address >> 8);
         DEBUG("C24LCXX_I2C::Write (byte): pI2CBuffer[0]: 0x%02x", i2cBuffer[0])
         i2cBuffer[1] = (unsigned char)((unsigned char)address & 0xff);
@@ -121,7 +122,8 @@
         // 1.Prepare buffer
         char i2cBuffer[4]; // Memory address + one short (2 bytes)
         // 1.1. Memory address
-        short address = p_address + 1; // Index start to 1
+        //short address = p_address + 1; // Index start to 1
+        short address = p_address;  // no Index+1
         i2cBuffer[0] = (unsigned char)(address >> 8);
         DEBUG("C24LCXX_I2C::Write (short): pI2CBuffer[0]: 0x%02x", i2cBuffer[0])
         i2cBuffer[1] = (unsigned char)((unsigned char)address & 0xff);
@@ -150,7 +152,8 @@
         // 1.Prepare buffer
         char i2cBuffer[6]; // Memory address + one integer (4 bytes)
         // 1.1. Memory address
-        short address = p_address + 1; // Index start to 1
+        //short address = p_address + 1; // Index start to 1
+        short address = p_address;  // no Index+1
         i2cBuffer[0] = (unsigned char)(address >> 8);
         DEBUG("C24LCXX_I2C::Write (int): pI2CBuffer[0]: 0x%02x", i2cBuffer[0])
         i2cBuffer[1] = (unsigned char)((unsigned char)address & 0xff);
@@ -207,7 +210,8 @@
         
         char i2cBuffer[2 + length];
         // 1.1. Memory address
-        short address = p_address + 1;
+        //short address = p_address + 1; // Index start to 1
+        short address = p_address;  // no Index+1
         i2cBuffer[0] = (unsigned char)(address >> 8);
         DEBUG("C24LCXX_I2C::Write (char *): pI2CBuffer[0]: 0x%02x", i2cBuffer[0])
         i2cBuffer[1] = (unsigned char)((unsigned char)address & 0xff);