diff options
author | Aseda Aboagye <aaboagye@google.com> | 2020-05-20 13:48:33 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-21 02:49:58 +0000 |
commit | f957f7fef2ae683d90840ccb89a922a5fd587082 (patch) | |
tree | 32e4dc99a885185d6b89d3db9b3bf04c59565833 /board/waddledoo/board.c | |
parent | bf889b296035360369abc13fe7892040079d93a8 (diff) | |
download | chrome-ec-f957f7fef2ae683d90840ccb89a922a5fd587082.tar.gz |
waddledoo: Add rotation matrices for sensors
This commit adds the needed rotation matrices for the sensors to place
the measurements into the standard reference frame.
BUG=b:155253629
BRANCH=None
TEST=Build and flash waddledoo. Compare accel readings against
released chromebooks and verify that they match in orientation and
sign.
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Change-Id: I6d1cb3ed674d71b083eef5e44e972794108701a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2210826
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Commit-Queue: Diana Z <dzigterman@chromium.org>
Auto-Submit: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board/waddledoo/board.c')
-rw-r--r-- | board/waddledoo/board.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/board/waddledoo/board.c b/board/waddledoo/board.c index 2d8a4c4f47..cd0a2cfccc 100644 --- a/board/waddledoo/board.c +++ b/board/waddledoo/board.c @@ -242,6 +242,19 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, static struct mutex g_lid_mutex; static struct mutex g_base_mutex; +/* Matrices to rotate accelerometers into the standard reference. */ +static const mat33_fp_t lid_standard_ref = { + { 0, FLOAT_TO_FP(1), 0}, + { FLOAT_TO_FP(-1), 0, 0}, + { 0, 0, FLOAT_TO_FP(1)} +}; + +static const mat33_fp_t base_standard_ref = { + { 0, FLOAT_TO_FP(1), 0}, + { FLOAT_TO_FP(-1), 0, 0}, + { 0, 0, FLOAT_TO_FP(1)} +}; + static struct accelgyro_saved_data_t g_bma253_data; static struct bmi_drv_data_t g_bmi160_data; @@ -257,7 +270,7 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_bma253_data, .port = I2C_PORT_SENSOR, .i2c_spi_addr_flags = BMA2x2_I2C_ADDR1_FLAGS, - .rot_standard_ref = NULL, + .rot_standard_ref = &lid_standard_ref, .default_range = 2, .min_frequency = BMA255_ACCEL_MIN_FREQ, .max_frequency = BMA255_ACCEL_MAX_FREQ, @@ -281,7 +294,7 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_bmi160_data, .port = I2C_PORT_SENSOR, .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS, - .rot_standard_ref = NULL, + .rot_standard_ref = &base_standard_ref, .default_range = 4, .min_frequency = BMI_ACCEL_MIN_FREQ, .max_frequency = BMI_ACCEL_MAX_FREQ, @@ -308,7 +321,7 @@ struct motion_sensor_t motion_sensors[] = { .port = I2C_PORT_SENSOR, .i2c_spi_addr_flags = BMI160_ADDR0_FLAGS, .default_range = 1000, /* dps */ - .rot_standard_ref = NULL, + .rot_standard_ref = &base_standard_ref, .min_frequency = BMI_GYRO_MIN_FREQ, .max_frequency = BMI_GYRO_MAX_FREQ, }, |