Base class for handling I2C devices

Files at this revision

API Documentation at this revision

Comitter:
glansberry
Date:
Wed Sep 30 16:21:45 2015 +0000
Parent:
2:0a77105ec549
Commit message:
Fix bug where the continues start bit was not being set. Potentially causes bad I2C bus transactions

Changed in this revision

Base_I2C_Device.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Base_I2C_Device.cpp	Wed Jul 29 14:53:01 2015 -0400
+++ b/Base_I2C_Device.cpp	Wed Sep 30 16:21:45 2015 +0000
@@ -9,7 +9,7 @@
 char temp_read[1];
 
         temp_write[0] = reg;
-        i2c.write(m_address, temp_write, 1, false); // no stop (unsure)
+        i2c.write(m_address, temp_write, 1, true);  // no stop, because we follow with a read
         i2c.read(m_address, temp_read, 1, 0);
                         
         return (uint8_t)temp_read[0];
@@ -20,7 +20,7 @@
 char temp_read[2];
 
         temp_write[0] = reg;
-        i2c.write(m_address, temp_write, 1, false); // no stop (unsure)
+        i2c.write(m_address, temp_write, 1, true); // no stop, because we follow with a read
         i2c.read(m_address, temp_read, 2, 0);
         
         return (((uint16_t)temp_read[0]) << 8) | (uint16_t)temp_read[1];
@@ -32,7 +32,7 @@
 char temp_write[1];
 
         temp_write[0] = reg;
-        i2c.write(m_address, temp_write, 1, false); // no stop (unsure)
+        i2c.write(m_address, temp_write, 1, true);  // no stop, because we follow with a read
         i2c.read(m_address, temp_read, bytes, 0);
 	
 	return temp_read;
@@ -45,7 +45,7 @@
     
     temp_write[0] = reg;
     temp_write[1] = value;   //check order of these (endianness)
-    return i2c.write(m_address, temp_write, 2, 0);    
+    return i2c.write(m_address, temp_write, 2, false);    
 }
 
 int Base_I2C_Device::WriteRegister(uint8_t reg, uint16_t value)   
@@ -55,5 +55,5 @@
     temp_write[0] = reg;
     temp_write[1] = value>>8;   
     temp_write[2] = (value & 0xFF);
-    return i2c.write(m_address, temp_write, 3, 0);    
+    return i2c.write(m_address, temp_write, 3, false);    
 }
\ No newline at end of file