diff options
author | Aseda Aboagye <aaboagye@google.com> | 2018-05-15 20:43:05 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-05-16 05:08:35 -0700 |
commit | 1d114ffa3ccca7fd99a49a67754806e3655d7fe6 (patch) | |
tree | 178540eea2f67d925f56859950eebd676cb95458 | |
parent | 9be407f10ed2710a4a29a94ef96f6a6c97a2f2a1 (diff) | |
download | chrome-ec-1d114ffa3ccca7fd99a49a67754806e3655d7fe6.tar.gz |
nocturne: Fix accel/gyro reference.
The BMI160 driver requires that the macro I2C_PORT_ACCEL is defined.
This commit simply defines that macro and defines a matrix to rotate the
sensor data into the standard frame.
BUG=b:79715267
BRANCH=master
TEST=Flash nocturne, verify that the BMI160 initializes successfully.
Verify that when device is struck from the left edge, positive
acceleration is seen on the X axis. When device is struck from the
bottom edge, positive acceleration is seen on Y axis.
Change-Id: I6407b21fdfe311fa8ac7d83a8050ebfb27b4e0d8
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1059535
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
-rw-r--r-- | board/nocturne/board.c | 10 | ||||
-rw-r--r-- | board/nocturne/board.h | 1 |
2 files changed, 9 insertions, 2 deletions
diff --git a/board/nocturne/board.c b/board/nocturne/board.c index ee9d924c93..33168a7973 100644 --- a/board/nocturne/board.c +++ b/board/nocturne/board.c @@ -155,6 +155,12 @@ static struct opt3001_drv_data_t g_opt3001_data = { .offset = 0, }; +/* Matrix to rotate accel/gyro into standard reference frame. */ +const matrix_3x3_t lid_standard_ref = { + { 0, FLOAT_TO_FP(-1), 0}, + { FLOAT_TO_FP(-1), 0, 0}, + { 0, 0, FLOAT_TO_FP(1)} +}; struct motion_sensor_t motion_sensors[] = { [LID_ACCEL] = { @@ -168,7 +174,7 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_bmi160_data, .port = I2C_PORT_ALS_GYRO, .addr = BMI160_ADDR0, - .rot_standard_ref = NULL, + .rot_standard_ref = &lid_standard_ref, .default_range = 4, /* g, enough for laptop. */ .min_frequency = BMI160_ACCEL_MIN_FREQ, .max_frequency = BMI160_ACCEL_MAX_FREQ, @@ -192,7 +198,7 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_bmi160_data, .port = I2C_PORT_ALS_GYRO, .addr = BMI160_ADDR0, - .rot_standard_ref = NULL, + .rot_standard_ref = &lid_standard_ref, .default_range = 1000, /* dps */ .min_frequency = BMI160_GYRO_MIN_FREQ, .max_frequency = BMI160_GYRO_MAX_FREQ, diff --git a/board/nocturne/board.h b/board/nocturne/board.h index 0c9bfd9f1b..5d866f1056 100644 --- a/board/nocturne/board.h +++ b/board/nocturne/board.h @@ -146,6 +146,7 @@ #define I2C_PORT_POWER NPCX_I2C_PORT0_0 #define I2C_PORT_BATTERY NPCX_I2C_PORT4_1 #define I2C_PORT_ALS_GYRO NPCX_I2C_PORT5_0 +#define I2C_PORT_ACCEL I2C_PORT_ALS_GYRO #define I2C_PORT_USB_C0 NPCX_I2C_PORT1_0 #define I2C_PORT_USB_C1 NPCX_I2C_PORT2_0 |