IMU LSM9DS1 Library (fixed)
Fork of LSM9DS1_Library by
Revision 4:1345050179ad, committed 2017-08-03
- Comitter:
- cduck
- Date:
- Thu Aug 03 15:41:27 2017 -0700
- Parent:
- 3:77883952d12e
- Child:
- 5:8da857db15e0
- Commit message:
- Fix more compiler warnings
Changed in this revision
| LSM9DS1.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/LSM9DS1.cpp Thu Aug 03 22:32:34 2017 +0000
+++ b/LSM9DS1.cpp Thu Aug 03 15:41:27 2017 -0700
@@ -1077,7 +1077,7 @@
uint8_t LSM9DS1::SPIreadByte(uint8_t csPin, uint8_t subAddress)
{
- uint8_t temp;
+ uint8_t temp = 0;
// Use the multiple read function to read 1 byte.
// Value is returned to `temp`.
SPIreadBytes(csPin, subAddress, &temp, 1);
@@ -1154,7 +1154,7 @@
temp[0] = 0x00;
i2c.write(address, temp, 1);
//i2c.write( address | 0x01);
- int a = i2c.read(address, &data, 1);
+ i2c.read(address, &data, 1);
return data;
}
@@ -1183,15 +1183,9 @@
}
return count;
*/
- int i;
- char temp_dest[count];
- char temp[1] = {subAddress};
- i2c.write(address, temp, 1);
- i2c.read(address, temp_dest, count);
-
- //i2c doesn't take uint8_ts, but rather chars so do this nasty af conversion
- for (i=0; i < count; i++) {
- dest[i] = temp_dest[i];
- }
+ char temp = (char)subAddress;
+ i2c.write(address, &temp, 1);
+ i2c.read(address, (char*)dest, count);
+
return count;
}
