danny hack
Diff: Lis2dh12.cpp
- Revision:
- 1:d89f4b12116b
- Parent:
- 0:cc5d477d5dbe
- Child:
- 2:1fa08c7a2a3c
--- a/Lis2dh12.cpp Fri Dec 29 17:40:50 2017 +0000 +++ b/Lis2dh12.cpp Fri Jan 05 13:32:08 2018 +0000 @@ -68,6 +68,15 @@ int16_t Lis2dh12::readXAxis(){ int16_t rawData; char tempData; + // Make sure new data is ready + do{ + i2c.readFromReg((char)STATUS, &tempData, 1); + }while(!(tempData & 0x08)); + do{ + i2c.readFromReg((char)STATUS, &tempData, 1); + }while(!(tempData & 0x80)); + // Same data have been overwritten + i2c.readFromReg((char)OUT_X_H, &tempData, 1); rawData = (int8_t)tempData << 8; i2c.readFromReg((char)OUT_X_L, &tempData, 1);