diff options
Diffstat (limited to 'board/samus')
-rw-r--r-- | board/samus/board.c | 62 | ||||
-rw-r--r-- | board/samus/board.h | 3 | ||||
-rw-r--r-- | board/samus/ec.tasklist | 1 |
3 files changed, 65 insertions, 1 deletions
diff --git a/board/samus/board.c b/board/samus/board.c index 82c9c92457..e1c528f30a 100644 --- a/board/samus/board.c +++ b/board/samus/board.c @@ -13,8 +13,10 @@ #include "charger.h" #include "common.h" #include "console.h" -#include "driver/temp_sensor/tmp006.h" +#include "driver/accel_kxcj9.h" +#include "driver/accelgyro_lsm6ds0.h" #include "driver/als_isl29035.h" +#include "driver/temp_sensor/tmp006.h" #include "extpower.h" #include "fan.h" #include "gpio.h" @@ -24,6 +26,7 @@ #include "jtag.h" #include "keyboard_scan.h" #include "lid_switch.h" +#include "motion_sense.h" #include "peci.h" #include "power.h" #include "power_button.h" @@ -31,6 +34,7 @@ #include "pwm_chip.h" #include "registers.h" #include "switch.h" +#include "task.h" #include "temp_sensor.h" #include "temp_sensor_chip.h" #include "timer.h" @@ -238,3 +242,59 @@ int board_discharge_on_ac(int enable) { return charger_discharge_on_ac(enable); } + +/* Base Sensor mutex */ +static struct mutex g_base_mutex; + +/* Lid Sensor mutex */ +static struct mutex g_lid_mutex; + +/* kxcj9 local/private data */ +struct kxcj9_data g_kxcj9_data; + +/* Four Motion sensors */ +struct motion_sensor_t motion_sensors[] = { + + {"Base", SENSOR_CHIP_LSM6DS0, SENSOR_ACCELEROMETER, LOCATION_BASE, + &lsm6ds0_drv, &g_base_mutex, NULL, LSM6DS0_ADDR1}, + + {"Lid", SENSOR_CHIP_KXCJ9, SENSOR_ACCELEROMETER, LOCATION_LID, + &kxcj9_drv, &g_lid_mutex, &g_kxcj9_data, KXCJ9_ADDR0}, + + {"Base Gyro", SENSOR_CHIP_LSM6DS0, SENSOR_GYRO, LOCATION_BASE, + &lsm6ds0_drv, &g_base_mutex, NULL, LSM6DS0_ADDR1}, + +}; +const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); + +/* Define the accelerometer orientation matrices. */ +#ifndef CONFIG_ACCEL_CALIBRATE +const +#endif +struct accel_orientation acc_orient = { + /* Lid and base sensor are already aligned. */ + .rot_align = { + { 1, 0, 0}, + { 0, 1, 0}, + { 0, 0, 1} + }, + + /* Hinge aligns with y axis. */ + .rot_hinge_90 = { + { 1, 0, 0}, + { 0, 1, 0}, + { 0, 0, 1} + }, + .rot_hinge_180 = { + {-1, 0, 0}, + { 0, 1, 0}, + { 0, 0, -1} + }, + .rot_standard_ref = { + {-1, 0, 0}, + { 0, -1, 0}, + { 0, 0, -1} + }, + .hinge_axis = {0, 1, 0}, +}; + diff --git a/board/samus/board.h b/board/samus/board.h index 5344db91d5..74d3003ab9 100644 --- a/board/samus/board.h +++ b/board/samus/board.h @@ -15,9 +15,12 @@ #undef HEY_USE_BUILTIN_CLKRUN /* Optional features */ +#define CONFIG_ACCELGYRO_LSM6DS0 +#define CONFIG_ACCEL_KXCJ9 #define CONFIG_ALS #define CONFIG_ALS_ISL29035 #define CONFIG_BOARD_VERSION +#define CONFIG_CMD_ACCELS #define CONFIG_POWER_COMMON #define CONFIG_CHIPSET_CAN_THROTTLE #define CONFIG_KEYBOARD_BOARD_CONFIG diff --git a/board/samus/ec.tasklist b/board/samus/ec.tasklist index 5429b0bb69..d043fe1777 100644 --- a/board/samus/ec.tasklist +++ b/board/samus/ec.tasklist @@ -21,6 +21,7 @@ TASK_NOTEST(ALS, als_task, NULL, SMALLER_TASK_STACK_SIZE) \ TASK_NOTEST(LIGHTBAR, lightbar_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(CHARGER, charger_task, NULL, LARGER_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_NOTEST(PDCMD, pd_command_task, NULL, SMALLER_TASK_STACK_SIZE) \ |