samus: enable accel & gyro sensors

- Base: lsm6ds0
- Lid : kxcj9
- gyro: lsm6ds0

BUG=chrome-os-partner:27313
BRANCH=ToT
TEST=Verified on Samus.

Tested with EC CLI utils
accelrate, accelrange, accelres, accelread, accelcalib

Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Change-Id: I9f5f771e43a7b026ac59fb4d459638a4b8ea8f79
Reviewed-on: https://chromium-review.googlesource.com/212373
Reviewed-by: Alec Berg <alecaberg@chromium.org>
This commit is contained in:
Sheng-Liang Song
2014-08-13 18:50:33 -07:00
committed by chrome-internal-fetch
parent 7d40063d46
commit 0535178d29
4 changed files with 69 additions and 2 deletions

View File

@@ -53,7 +53,10 @@ BUILD_ASSERT(ARRAY_SIZE(buttons) == CONFIG_BUTTON_COUNT);
#endif
/* Define the accelerometer orientation matrices. */
const struct accel_orientation acc_orient = {
#ifndef CONFIG_ACCEL_CALIBRATE
const
#endif
struct accel_orientation acc_orient = {
/* Lid and base sensor are already aligned. */
.rot_align = {
{ 1, 0, 0},

View File

@@ -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},
};

View File

@@ -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

View File

@@ -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) \