From 2fdaf6623c5c73c694b0a1c1b3750b7cb1987584 Mon Sep 17 00:00:00 2001 From: lu zhang Date: Fri, 30 Aug 2019 13:48:50 +0800 Subject: treeya: fix rotation matrices of lid and base sensors Now there are two sets of lid/base sensors in proto phase. Both of rotation matrices need to be fixed. BUG=b:138744661 BRANCH=none TEST=Using ec console 'accelinfo on' verified lid angle now goes from 0 to 360 and swtiches to tablet mode after crossing 180 threshold. Change-Id: I93a89a878cf064071eb5f3786f4f5f5475ba2de2 Signed-off-by: lu zhang Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1773032 Reviewed-by: Paul Ma Reviewed-by: Edward Hill Tested-by: Paul Ma --- board/treeya/board.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/board/treeya/board.c b/board/treeya/board.c index 61c7180632..16816e5068 100644 --- a/board/treeya/board.c +++ b/board/treeya/board.c @@ -54,16 +54,21 @@ static struct lsm6dsm_data g_lsm6dsm_data; /* Matrix to rotate accelrator into standard reference frame */ static const mat33_fp_t lsm6dsm_base_standard_ref = { - { 0, FLOAT_TO_FP(1), 0}, { FLOAT_TO_FP(-1), 0, 0}, + { 0, FLOAT_TO_FP(-1), 0}, { 0, 0, FLOAT_TO_FP(1)} }; -/* just a placeholder, will revise when board is out */ static const mat33_fp_t lis2dwl_lid_standard_ref = { + { FLOAT_TO_FP(1), 0, 0}, + { 0, FLOAT_TO_FP(1), 0}, + { 0, 0, FLOAT_TO_FP(1)} +}; + +static const mat33_fp_t treeya_standard_ref = { { 0, FLOAT_TO_FP(-1), 0}, - { FLOAT_TO_FP(-1), 0, 0}, - { 0, 0, FLOAT_TO_FP(-1)} + { FLOAT_TO_FP(1), 0, 0}, + { 0, 0, FLOAT_TO_FP(1)} }; struct motion_sensor_t lid_accel_1 = { @@ -145,10 +150,11 @@ struct motion_sensor_t base_gyro_1 = { .max_frequency = LSM6DSM_ODR_MAX_VAL, }; -/* sku_id a8-a9 use ST sensors */ static int board_use_st_sensor(void) { + /* sku_id 0xa8-0xa9 use ST sensors */ uint32_t sku_id = system_get_sku_id(); + return sku_id == 0xa8 || sku_id == 0xa9; } @@ -163,6 +169,11 @@ void board_update_sensor_config_from_sku(void) motion_sensors[LID_ACCEL] = lid_accel_1; motion_sensors[BASE_ACCEL] = base_accel_1; motion_sensors[BASE_GYRO] = base_gyro_1; + } else{ + /*Need to change matrix for treeya*/ + motion_sensors[LID_ACCEL].rot_standard_ref = &treeya_standard_ref; + motion_sensors[BASE_ACCEL].rot_standard_ref = &treeya_standard_ref; + motion_sensors[BASE_GYRO].rot_standard_ref = &treeya_standard_ref; } /* Enable Gyro interrupts */ -- cgit v1.2.1