summaryrefslogtreecommitdiff
path: root/board/fleex/board.c
diff options
context:
space:
mode:
authorelthanhuang <elthan_huang@compal.corp-partner.google.com>2018-08-09 21:27:02 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-08-13 05:20:24 -0700
commit9ddaa42683da58042dd79000aed21d978ea21a19 (patch)
tree33d06a26db6f84ebde91b2676f1a9eef00af1c05 /board/fleex/board.c
parente76700b03d84acde223f4bcdf79db764e7ed1039 (diff)
downloadchrome-ec-9ddaa42683da58042dd79000aed21d978ea21a19.tar.gz
Fleex: Change define motion_sensors of LID_ACCEL
and initial x,y,z-axis direction of lid and base g-sensor Enable CONFIG_ACCEL_LIS2DE and motion_sensors struct of LID_ACCEL meet LIS2ED12 accelerometer. Modify standard reference frame to fit Fleex shell design. (base_standard_ref and lid_standard_ref) BUG=b:112399626 BRANCH=none TEST=Use "ectool motionsense" to check sensor0/1/2 value. Use "watch -n 1 ectool motionsense" to check x,y,z-axis. 1. When x-axis face up, get x value of sensor0 and sensor1 more than 10000 2. When y-axis face up, get y value of sensor0 and sensor1 more than 10000 3. When z-axis face up, get z value of sensor0 and sensor1 more than 10000 Change-Id: I1f4409ef634ed4849aad7017cad598588b0637d9 Signed-off-by: elthanhuang <elthan_huang@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/1169040 Commit-Ready: Elthan Huang <elthan_huang@compal.corp-partner.google.com> Tested-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com> Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'board/fleex/board.c')
-rw-r--r--board/fleex/board.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/board/fleex/board.c b/board/fleex/board.c
index 000537a97d..7a767cfd54 100644
--- a/board/fleex/board.c
+++ b/board/fleex/board.c
@@ -13,7 +13,7 @@
#include "charge_state.h"
#include "common.h"
#include "cros_board_info.h"
-#include "driver/accel_kionix.h"
+#include "driver/accel_lis2dh.h"
#include "driver/accelgyro_lsm6dsm.h"
#include "driver/bc12/bq24392.h"
#include "driver/charger/bd9995x.h"
@@ -33,6 +33,7 @@
#include "power_button.h"
#include "switch.h"
#include "system.h"
+#include "task.h"
#include "tablet_mode.h"
#include "tcpci.h"
#include "temp_sensor.h"
@@ -109,14 +110,20 @@ static struct mutex g_lid_mutex;
static struct mutex g_base_mutex;
/* Matrix to rotate accelerometer into standard reference frame */
-const matrix_3x3_t base_standard_ref = {
- { 0, FLOAT_TO_FP(-1), 0},
- { FLOAT_TO_FP(1), 0, 0},
+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)}
};
+ const matrix_3x3_t base_standard_ref = {
+ { FLOAT_TO_FP(-1), 0, 0},
+ { 0, FLOAT_TO_FP(-1), 0},
+ { 0, 0, FLOAT_TO_FP(1)}
+ };
+
/* sensor private data */
-static struct kionix_accel_data g_kx022_data;
+static struct stprivate_data g_lis2dh_data;
static struct lsm6dsm_data lsm6dsm_g_data;
static struct lsm6dsm_data lsm6dsm_a_data;
@@ -125,16 +132,19 @@ struct motion_sensor_t motion_sensors[] = {
[LID_ACCEL] = {
.name = "Lid Accel",
.active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_KX022,
+ .chip = MOTIONSENSE_CHIP_LIS2DE,
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_LID,
- .drv = &kionix_accel_drv,
+ .drv = &lis2dh_drv,
.mutex = &g_lid_mutex,
- .drv_data = &g_kx022_data,
+ .drv_data = &g_lis2dh_data,
.port = I2C_PORT_SENSOR,
- .addr = KX022_ADDR1,
- .rot_standard_ref = NULL, /* Identity matrix. */
- .default_range = 4, /* g */
+ .addr = LIS2DH_ADDR1,
+ .rot_standard_ref = &lid_standard_ref,
+ .default_range = 2, /* g */
+ /* We only use 2g because its resolution is only 8-bits */
+ .min_frequency = LIS2DH_ODR_MIN_VAL,
+ .max_frequency = LIS2DH_ODR_MAX_VAL,
.config = {
/* EC use accel for angle detection */
[SENSOR_CONFIG_EC_S0] = {