diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-03-08 15:55:53 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-03-08 15:55:53 +0100 |
commit | abf3d1d93c33267e374c1dd93b2e96a7f72186c4 (patch) | |
tree | 0f2e623dc05e2051b83b6c0bf43492dc00941e80 | |
parent | 0af72f0d9db44381e15f29e8c72fb7f39603ee86 (diff) |
mpu9250: getRawMagnet: pass request success to userland
-rw-r--r-- | include/driver/mpu9250.h | 2 | ||||
-rw-r--r-- | src/driver/mpu9250.cc | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/include/driver/mpu9250.h b/include/driver/mpu9250.h index 70c7f46..e106205 100644 --- a/include/driver/mpu9250.h +++ b/include/driver/mpu9250.h @@ -269,7 +269,7 @@ class MPU9250 { inline int getGyroZ() { return getWordReg(71); } void getRawAccel(int *x, int *y, int *z); void getRawGyro(int *x, int *y, int *z); - void getRawMagnet(int *x, int *y, int *z); + bool getRawMagnet(int *x, int *y, int *z); void getAccel(float *g_x, float *g_y, float *g_z); void getGyro(float *dps_x, float *dps_y, float *dps_z); void getMagnet(int *x, int *y, int *z); diff --git a/src/driver/mpu9250.cc b/src/driver/mpu9250.cc index 32f78c7..9b34ef4 100644 --- a/src/driver/mpu9250.cc +++ b/src/driver/mpu9250.cc @@ -201,7 +201,7 @@ void MPU9250::getGyro(float *dps_x, float *dps_y, float *dps_z) *dps_z = z * fsr_factor; } -void MPU9250::getRawMagnet(int *x, int *y, int *z) +bool MPU9250::getRawMagnet(int *x, int *y, int *z) { txbuf[0] = 0x02; i2c.xmit(0x0c, 1, txbuf, 8, rxbuf); @@ -210,9 +210,10 @@ void MPU9250::getRawMagnet(int *x, int *y, int *z) *x = ((signed int)rxbuf[2] << 8) + rxbuf[1]; *y = ((signed int)rxbuf[4] << 8) + rxbuf[3]; *z = ((signed int)rxbuf[6] << 8) + rxbuf[5]; + return true; } else { - *x = *y = *z = 0; + return false; } } |