From db1b3b34c21530672118754e84ddbe879925542e Mon Sep 17 00:00:00 2001 From: Inno Park Date: Tue, 21 Jun 2016 14:17:15 +0900 Subject: [PATCH] kevin: change coordinates axis for sensors BUG=chrome-os-partner:52844 BRANCH=none TEST=check x-y-z value from base/lid accelerometer with ec console command 'accelread' Change-Id: I38a83f13e415504600cc6c566cf8586e1309a270 Signed-off-by: Inno Park Reviewed-on: https://chromium-review.googlesource.com/354321 Commit-Ready: Aseda Aboagye Tested-by: Aseda Aboagye Reviewed-by: Aseda Aboagye --- board/kevin/board.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/board/kevin/board.c b/board/kevin/board.c index dac0fb61b4..9336b681cb 100644 --- a/board/kevin/board.c +++ b/board/kevin/board.c @@ -351,6 +351,19 @@ static struct mutex g_lid_mutex; struct bma2x2_accel_data g_bma255_data = { .variant = BMA255, }; + +/* Matrix to rotate accelrator into standard reference frame */ +const matrix_3x3_t base_standard_ref = { + { 0, FLOAT_TO_FP(-1), 0}, + { FLOAT_TO_FP(-1), 0, 0}, + { 0, 0, FLOAT_TO_FP(1)} +}; + +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)} +}; #endif struct motion_sensor_t motion_sensors[] = { @@ -369,7 +382,11 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_bmi160_data, .port = CONFIG_SPI_ACCEL_PORT, .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT), +#ifdef BOARD_KEVIN + .rot_standard_ref = &base_standard_ref, +#else .rot_standard_ref = NULL, /* Identity matrix. */ +#endif .default_range = 2, /* g, enough for laptop. */ .config = { /* AP: by default use EC settings */ @@ -406,7 +423,11 @@ struct motion_sensor_t motion_sensors[] = { .port = CONFIG_SPI_ACCEL_PORT, .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT), .default_range = 1000, /* dps */ - .rot_standard_ref = NULL, /* Identity Matrix. */ +#ifdef BOARD_KEVIN + .rot_standard_ref = &base_standard_ref, /* Identity Matrix. */ +#else + .rot_standard_ref = NULL, /* Identity matrix. */ +#endif .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -442,7 +463,7 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_bma255_data, .port = I2C_PORT_ACCEL, .addr = BMA2x2_I2C_ADDR1, - .rot_standard_ref = NULL, /* Identity matrix. */ + .rot_standard_ref = &lid_standard_ref, .default_range = 2, /* g, enough for laptop. */ .config = { /* AP: by default use EC settings */