diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2014-10-23 16:58:21 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-10-29 22:23:54 +0000 |
commit | 66164f2784b1ca34d9a10febd39c19db064c1750 (patch) | |
tree | 965c82a6d0826de677ff5c95e8191f53a01cd9e0 /include | |
parent | d5b32aa6e1e9ac206f4cbdd6cf4452a08dc2ec36 (diff) | |
download | chrome-ec-66164f2784b1ca34d9a10febd39c19db064c1750.tar.gz |
Samus: Split motion sense and lid angle
Split motion_sense.c.
Translate the accel data in the Android coordinate right away.
BUG=chrome-os-partner:32002
BRANCH=ToT
TEST=On samus, check lid angle are still correct.
Change-Id: If743e25245dc1ce4cdacb8a4d5af22616c4a79e4
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225486
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/config.h | 20 | ||||
-rw-r--r-- | include/console.h | 1 | ||||
-rw-r--r-- | include/motion_lid.h | 50 | ||||
-rw-r--r-- | include/motion_sense.h | 79 |
4 files changed, 81 insertions, 69 deletions
diff --git a/include/config.h b/include/config.h index 309d061541..dd0815e22c 100644 --- a/include/config.h +++ b/include/config.h @@ -308,6 +308,7 @@ */ #undef CONFIG_CMD_ACCELS +#undef CONFIG_CMD_ACCEL_INFO #undef CONFIG_CMD_BATDEBUG #undef CONFIG_CMD_CLOCKGATES #undef CONFIG_CMD_COMXTEST @@ -317,7 +318,6 @@ #undef CONFIG_CMD_HOSTCMD #undef CONFIG_CMD_ILIM #undef CONFIG_CMD_JUMPTAGS -#define CONFIG_CMD_LID_ANGLE #undef CONFIG_CMD_PLL #undef CONFIG_CMD_PMU #define CONFIG_CMD_POWERINDEBUG @@ -564,6 +564,18 @@ #endif +#undef CONFIG_LID_ANGLE +#ifndef CONFIG_LID_ANGLE +#undef CONFIG_SENSOR_BASE +#undef CONFIG_SENSOR_LID + +/* + * Allows using the lid angle measurement to determine if key scanning should + * be enabled or disabled when chipset is suspended. + */ +#undef CONFIG_LID_ANGLE_KEY_SCAN + +#endif /*****************************************************************************/ @@ -729,12 +741,6 @@ #undef CONFIG_LED_DRIVER_LP5562 /* LP5562, on I2C interface */ /* - * Allows using the lid angle measurement to determine if key scanning should - * be enabled or disabled when chipset is suspended. - */ -#undef CONFIG_LID_ANGLE_KEY_SCAN - -/* * Compile lid switch support. * * This is enabled by default because all boards other than reference boards diff --git a/include/console.h b/include/console.h index bf2cd536f1..29599dda4b 100644 --- a/include/console.h +++ b/include/console.h @@ -43,6 +43,7 @@ enum console_channel { CC_LIDANGLE, CC_LIGHTBAR, CC_LPC, + CC_MOTION_LID, CC_MOTION_SENSE, CC_PD_HOST_CMD, CC_PORT80, diff --git a/include/motion_lid.h b/include/motion_lid.h new file mode 100644 index 0000000000..b3348c020e --- /dev/null +++ b/include/motion_lid.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Header for motion_sense.c */ + +#ifndef __CROS_EC_MOTION_LID_H +#define __CROS_EC_MOTION_LID_H + +/* Anything outside of lid angle range [-180, 180] should work. */ +#define LID_ANGLE_UNRELIABLE 500.0F + +/** + * This structure defines all of the data needed to specify the orientation + * of the base and lid accelerometers in order to calculate the lid angle. + */ +struct accel_orientation { + /* Rotation matrix to rotate positive 90 degrees around the hinge. */ + matrix_3x3_t rot_hinge_90; + + /* + * Rotation matrix to rotate 180 degrees around the hinge. The value + * here should be rot_hinge_90 ^ 2. + */ + matrix_3x3_t rot_hinge_180; + + /* Vector pointing along hinge axis. */ + vector_3_t hinge_axis; +}; + +/* Link global structure for orientation. This must be defined in board.c. */ +extern const struct accel_orientation acc_orient; + + +/** + * Get last calculated lid angle. Note, the lid angle calculated by the EC + * is un-calibrated and is an approximate angle. + * + * @return lid angle in degrees in range [0, 360]. + */ +int motion_lid_get_angle(void); + +int host_cmd_motion_lid(struct host_cmd_handler_args *args); + +void motion_lid_calc(void); + +#endif /* __CROS_EC_MOTION_LID_H */ + + diff --git a/include/motion_sense.h b/include/motion_sense.h index be764a8d00..bb5acc308c 100644 --- a/include/motion_sense.h +++ b/include/motion_sense.h @@ -12,66 +12,6 @@ #include "math_util.h" #include "chipset.h" -/* Anything outside of lid angle range [-180, 180] should work. */ -#define LID_ANGLE_UNRELIABLE 500.0F - -/** - * This structure defines all of the data needed to specify the orientation - * of the base and lid accelerometers in order to calculate the lid angle. - */ -struct accel_orientation { - /* - * Rotation matrix to rotate the lid sensor into the same reference - * frame as the base sensor. - */ - matrix_3x3_t rot_align; - - /* Rotation matrix to rotate positive 90 degrees around the hinge. */ - matrix_3x3_t rot_hinge_90; - - /* - * Rotation matrix to rotate 180 degrees around the hinge. The value - * here should be rot_hinge_90 ^ 2. - */ - matrix_3x3_t rot_hinge_180; - - /* - * Rotation matrix to rotate base sensor into the standard reference - * frame. - */ - matrix_3x3_t rot_standard_ref; - - /* Vector pointing along hinge axis. */ - vector_3_t hinge_axis; -}; - -/* Link global structure for orientation. This must be defined in board.c. */ -extern const struct accel_orientation acc_orient; - - -/** - * Get last calculated lid angle. Note, the lid angle calculated by the EC - * is un-calibrated and is an approximate angle. - * - * @return lid angle in degrees in range [0, 360]. - */ -int motion_get_lid_angle(void); - - -/** - * Interrupt function for lid accelerometer. - * - * @param signal GPIO signal that caused interrupt - */ -void accel_int_lid(enum gpio_signal signal); - -/** - * Interrupt function for base accelerometer. - * - * @param signal GPIO signal that caused interrupt - */ -void accel_int_base(enum gpio_signal signal); - enum sensor_location_t { LOCATION_BASE = 0, LOCATION_LID = 1, @@ -110,6 +50,7 @@ struct motion_sensor_t { struct mutex *mutex; void *drv_data; uint8_t i2c_addr; + const matrix_3x3_t *rot_standard_ref; /* Default configuration parameters, RO only */ int default_odr; @@ -122,9 +63,7 @@ struct motion_sensor_t { /* state parameters */ enum sensor_state state; enum chipset_state_mask active; - vector_3_t raw_xyz; vector_3_t xyz; - }; /* Defined at board level. */ @@ -137,4 +76,20 @@ extern const unsigned int motion_sensor_count; */ #define MOTION_SENSE_HOOK_PRIO (HOOK_PRIO_DEFAULT) +#ifdef CONFIG_ACCEL_INTERRUPTS +/** + * Interrupt function for lid accelerometer. + * + * @param signal GPIO signal that caused interrupt + */ +void accel_int_lid(enum gpio_signal signal); + +/** + * Interrupt function for base accelerometer. + * + * @param signal GPIO signal that caused interrupt + */ +void accel_int_base(enum gpio_signal signal); +#endif + #endif /* __CROS_EC_MOTION_SENSE_H */ |