An improved version of mbed's I2C class.

Dependents:   acd52832_Humidity_Temp_Example BB acnSensa_LIS aconnoCellularGnss ... more

Revision:
5:54ba0e4f13ae
Parent:
4:db46d6bb60f0
Child:
6:4d1b387c12c3
--- a/aconno_i2c.cpp	Thu May 24 17:50:45 2018 +0200
+++ b/aconno_i2c.cpp	Thu Jul 19 12:48:11 2018 +0200
@@ -28,11 +28,12 @@
  */
 uint8_t aconno_i2c::writeToReg(char regAddress, char *data, int len){
     uint8_t success; /* 0 on success (ack), non-0 on failure (nack) */
-    char dataToSend[2];
+    char dataToSend[len+1];
 
     dataToSend[0] = regAddress;
-    dataToSend[1] = *data;
-    success = i2c->write(i2cAddress & 0xFE, dataToSend, len + 1); // R/W bit is set low for a write command
+	memcpy(dataToSend+1, data, len);
+	// R/W bit is set low for a write command
+    success = i2c->write(i2cAddress & 0xFE, dataToSend, len + 1);
     return success;
 }
 
@@ -100,4 +101,3 @@
     success = i2c->write(i2cAddress & 0xFE, command, len);
     return success;
 }
-