diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2016-10-05 14:12:07 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-10-07 21:51:24 -0700 |
commit | f11271c8ee4f80b3d98b44069dd68d264484ddbf (patch) | |
tree | 7858da96ffd138640b3e2400133051bde596308e /driver | |
parent | 0ea4603143984a70f895a0c83df4eab3e2b4aa58 (diff) | |
download | chrome-ec-f11271c8ee4f80b3d98b44069dd68d264484ddbf.tar.gz |
driver: bmi160: Fix logic issue when accelerometer is not first sensor
BMI160 driver assumes accel, gyro, compass are next to each other.
It was also assuming accel was sensor 0, which is wrong.
BUG=none
BRANCH=glados
TEST=On Cave, check sensors 1 (accel) and 2 (gyro) are working properly.
Change-Id: I37402e1d48070caaecbd7e32bbf53754616ee8cb
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/394067
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/accelgyro_bmi160.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c index 3a6ee8b86f..77856e6118 100644 --- a/driver/accelgyro_bmi160.c +++ b/driver/accelgyro_bmi160.c @@ -919,9 +919,7 @@ static int bmi160_decode_header(struct motion_sensor_t *s, size += (i == MOTIONSENSE_TYPE_MAG ? 8 : 6); } if (*bp + size > BUFFER_END(bmi160_buffer)) { - /* frame is not complete, it - * will be retransmitted. - */ + /* frame is not complete, it will be retransmitted. */ *bp = BUFFER_END(bmi160_buffer); return 1; } @@ -935,7 +933,7 @@ static int bmi160_decode_header(struct motion_sensor_t *s, vector.data[X] = v[X]; vector.data[Y] = v[Y]; vector.data[Z] = v[Z]; - vector.sensor_num = i; + vector.sensor_num = i + (s - motion_sensors); motion_sense_fifo_add_unit(&vector, s + i, 3); *bp += (i == MOTIONSENSE_TYPE_MAG ? 8 : 6); } |