From 2b9666556feda37e6fda9c081dd7403ea8b6ec3f Mon Sep 17 00:00:00 2001 From: "jerry2.huang" Date: Tue, 3 Nov 2020 13:38:28 +0800 Subject: boten: add motion sensor interrupt config and matrices Add config for boten motion sensor's interrupt and matrices for rotate BUG=b:172290264 BRANCH=none TEST=buildall, flash ec to dut and boot to check the ectool command motionsense work normally. Signed-off-by: jerry2.huang Change-Id: I89e3f5d1c5e460ed26126c5d0489afde7c7843f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2515430 Reviewed-by: Henry Sun Reviewed-by: Diana Z --- board/boten/board.c | 19 ++++++++++++++++--- board/boten/board.h | 2 ++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/board/boten/board.c b/board/boten/board.c index edfff35f4e..0e82934373 100644 --- a/board/boten/board.c +++ b/board/boten/board.c @@ -282,6 +282,19 @@ BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); 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 = { + { FLOAT_TO_FP(1), 0, 0}, + { 0, FLOAT_TO_FP(1), 0}, + { 0, 0, FLOAT_TO_FP(-1)} +}; + +static const mat33_fp_t base_standard_ref = { + { FLOAT_TO_FP(1), 0, 0}, + { 0, FLOAT_TO_FP(1), 0}, + { 0, 0, FLOAT_TO_FP(-1)} +}; + /* Sensor Data */ static struct stprivate_data g_lis2dwl_data; static struct lsm6dsm_data lsm6dsm_data = LSM6DSM_DATA; @@ -299,7 +312,7 @@ struct motion_sensor_t motion_sensors[] = { .drv_data = &g_lis2dwl_data, .port = I2C_PORT_SENSOR, .i2c_spi_addr_flags = LIS2DWL_ADDR1_FLAGS, - .rot_standard_ref = NULL, + .rot_standard_ref = &lid_standard_ref, .default_range = 2, /* g */ .min_frequency = LIS2DW12_ODR_MIN_VAL, .max_frequency = LIS2DW12_ODR_MAX_VAL, @@ -326,7 +339,7 @@ struct motion_sensor_t motion_sensors[] = { .flags = MOTIONSENSE_FLAG_INT_SIGNAL, .port = I2C_PORT_SENSOR, .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS, - .rot_standard_ref = NULL, + .rot_standard_ref = &base_standard_ref, .default_range = 4, /* g */ .min_frequency = LSM6DSM_ODR_MIN_VAL, .max_frequency = LSM6DSM_ODR_MAX_VAL, @@ -356,7 +369,7 @@ struct motion_sensor_t motion_sensors[] = { .port = I2C_PORT_SENSOR, .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS, .default_range = 1000 | ROUND_UP_FLAG, /* dps */ - .rot_standard_ref = NULL, + .rot_standard_ref = &base_standard_ref, .min_frequency = LSM6DSM_ODR_MIN_VAL, .max_frequency = LSM6DSM_ODR_MAX_VAL, }, diff --git a/board/boten/board.h b/board/boten/board.h index f8ce11b817..f74be69f3b 100644 --- a/board/boten/board.h +++ b/board/boten/board.h @@ -41,6 +41,8 @@ /* Sensors */ #define CONFIG_ACCEL_LIS2DWL /* Lid accel */ #define CONFIG_ACCELGYRO_LSM6DSM /* Base accel */ +#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \ + TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) /* Sensors without hardware FIFO are in forced mode */ #define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) -- cgit v1.2.1