diff options
author | Kevin K Wong <kevin.k.wong@intel.com> | 2015-03-31 17:49:37 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-04-15 04:50:45 +0000 |
commit | 5654dedc875e8e95b564f506550f8596105f0cc5 (patch) | |
tree | c1d4fc8baf9ca72f6fa568ec78a1b2ed366691ef | |
parent | 26c777c5e0b7533378641f2ab681ea3587bc69ce (diff) | |
download | chrome-ec-5654dedc875e8e95b564f506550f8596105f0cc5.tar.gz |
strago: Enabled accelerometer support.
BUG=none
TEST=Verified lid angle value via accelinfo console command.
BRANCH=none
Change-Id: I7857fadeb6ffbd83c55d00649437c52ac3f204ba
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/265595
Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r-- | board/strago/board.c | 51 | ||||
-rw-r--r-- | board/strago/board.h | 8 | ||||
-rw-r--r-- | board/strago/ec.tasklist | 1 |
3 files changed, 60 insertions, 0 deletions
diff --git a/board/strago/board.c b/board/strago/board.c index 06628fcae6..cc9b33ed35 100644 --- a/board/strago/board.c +++ b/board/strago/board.c @@ -5,11 +5,16 @@ /* Strago board-specific configuration */ #include "charger.h" +#include "driver/accel_kxcj9.h" #include "driver/temp_sensor/tmp432.h" #include "extpower.h" #include "gpio.h" +#include "host_command.h" #include "i2c.h" #include "lid_switch.h" +#include "math_util.h" +#include "motion_lid.h" +#include "motion_sense.h" #include "power.h" #include "power_button.h" #include "registers.h" @@ -70,3 +75,49 @@ int board_discharge_on_ac(int enable) { return charger_discharge_on_ac(enable); } + +/* Four Motion sensors */ +/* kxcj9 mutex and local/private data*/ +static struct mutex g_kxcj9_mutex[2]; +struct kxcj9_data g_kxcj9_data[2]; + +/* 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 = { + {FLOAT_TO_FP(-1), 0, 0}, + { 0, FLOAT_TO_FP(-1), 0}, + { 0, 0, FLOAT_TO_FP(-1)} +}; + +struct motion_sensor_t motion_sensors[] = { + {SENSOR_ACTIVE_S0, "Base Accel", MOTIONSENSE_CHIP_KXCJ9, + MOTIONSENSE_TYPE_ACCEL, MOTIONSENSE_LOC_BASE, + &kxcj9_drv, &g_kxcj9_mutex[0], &g_kxcj9_data[0], + KXCJ9_ADDR1, &base_standard_ref, 100000, 2}, + {SENSOR_ACTIVE_S0, "Lid Accel", MOTIONSENSE_CHIP_KXCJ9, + MOTIONSENSE_TYPE_ACCEL, MOTIONSENSE_LOC_LID, + &kxcj9_drv, &g_kxcj9_mutex[1], &g_kxcj9_data[1], + KXCJ9_ADDR0, &lid_standard_ref, 100000, 2}, +}; +const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); + +/* Define the accelerometer orientation matrices. */ +const struct accel_orientation acc_orient = { + /* Hinge aligns with x axis. */ + .rot_hinge_90 = { + { FLOAT_TO_FP(1), 0, 0}, + { 0, 0, FLOAT_TO_FP(1)}, + { 0, FLOAT_TO_FP(-1), 0} + }, + .rot_hinge_180 = { + { FLOAT_TO_FP(1), 0, 0}, + { 0, FLOAT_TO_FP(-1), 0}, + { 0, 0, FLOAT_TO_FP(-1)} + }, + .hinge_axis = {1, 0, 0}, +}; diff --git a/board/strago/board.h b/board/strago/board.h index b8d4b8a132..f1e28017dd 100644 --- a/board/strago/board.h +++ b/board/strago/board.h @@ -55,6 +55,14 @@ #define I2C_PORT_PD_MCU 2 #define I2C_PORT_THERMAL 3 +/* Accelerometer */ +#define CONFIG_ACCEL_KXCJ9 +#define CONFIG_CMD_ACCELS +#define CONFIG_CMD_ACCEL_INFO +#define CONFIG_LID_ANGLE +#define CONFIG_SENSOR_BASE 0 +#define CONFIG_SENSOR_LID 1 + /* Modules we want to exclude */ #undef CONFIG_EEPROM #undef CONFIG_EOPTION diff --git a/board/strago/ec.tasklist b/board/strago/ec.tasklist index 354d7e45fc..bc15569efd 100644 --- a/board/strago/ec.tasklist +++ b/board/strago/ec.tasklist @@ -19,6 +19,7 @@ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \ + TASK_NOTEST(MOTIONSENSE, motion_sense_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_NOTEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \ TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \ |