Library for interfacing with the RM3100 magnetometer from PNI Sensor Corporation
Dependents: Hello_RM3100 RM3100
Revision 1:8646c63a8dbe, committed 2018-05-24
- Comitter:
- fwrawx
- Date:
- Thu May 24 15:23:22 2018 +0000
- Parent:
- 0:b6ab7f28cde2
- Commit message:
- Change the way I2C writes are performed due to some timing issues in the mbed I2C methods.
Changed in this revision
Rm3100.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r b6ab7f28cde2 -r 8646c63a8dbe Rm3100.cpp --- a/Rm3100.cpp Tue Feb 21 04:55:49 2017 +0000 +++ b/Rm3100.cpp Thu May 24 15:23:22 2018 +0000 @@ -298,7 +298,9 @@ int Rm3100::Write(uint8_t reg, uint8_t *buffer, uint8_t count) { - _i2c.write(_addr, (const char *)®, sizeof(reg), true); - return _i2c.write(_addr, (const char *)buffer, count, false) + uint8_t data[count + 1]; + data[0] = reg; + memcpy(&data[1], buffer, count); + return _i2c.write(_addr, (const char *)data, count + 1, false) ? RM3100_RET_EIO : RM3100_RET_OK; }