Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LSM9DS1_Library by
Diff: LSM9DS1.cpp
- Revision:
- 4:1345050179ad
- Parent:
- 2:6036e7916c7a
--- 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;
}
