summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2016-08-20 15:35:53 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-08-24 17:40:30 -0700
commit9f0d4e9760cbe40b119822b04a5cd5b2ae66c71b (patch)
treee1b17c97ce1881f2e6004c2604ec84ee600a312b
parent71c9cc6f3f9673b7aab927a915fb8ed15be520ac (diff)
downloadchrome-ec-9f0d4e9760cbe40b119822b04a5cd5b2ae66c71b.tar.gz
test: motion_lid: Use new sensor frame
Update motion_lid to use Android/HTML5 vector frame for sensor. BUG=none BRANCH=none TEST=Test motion_lid passes. Change-Id: Ic4484e716b678b8399b058ade2bc13480f6cf393 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/373724 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--test/motion_lid.c52
-rw-r--r--test/test_config.h1
2 files changed, 17 insertions, 36 deletions
diff --git a/test/motion_lid.c b/test/motion_lid.c
index 81ab132300..26eff7f1a4 100644
--- a/test/motion_lid.c
+++ b/test/motion_lid.c
@@ -96,18 +96,6 @@ const struct accelgyro_drv test_motion_sense = {
.get_data_rate = accel_get_data_rate,
};
-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)}
-};
-
-const matrix_3x3_t lid_standard_ref = {
- { FLOAT_TO_FP(1), 0, 0},
- { FLOAT_TO_FP(1), 0, 0},
- { 0, 0, FLOAT_TO_FP(1)}
-};
-
struct motion_sensor_t motion_sensors[] = {
{.name = "base",
.active_mask = SENSOR_ACTIVE_S0_S3_S5,
@@ -115,11 +103,7 @@ struct motion_sensor_t motion_sensors[] = {
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_BASE,
.drv = &test_motion_sense,
- .mutex = NULL,
- .drv_data = NULL,
- .port = 0,
- .addr = 0,
- .rot_standard_ref = &base_standard_ref,
+ .rot_standard_ref = NULL,
.default_range = 2, /* g, enough for laptop. */
.config = {
/* AP: by default shutdown all sensors */
@@ -149,11 +133,7 @@ struct motion_sensor_t motion_sensors[] = {
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_LID,
.drv = &test_motion_sense,
- .mutex = NULL,
- .drv_data = NULL,
- .port = 0,
- .addr = 0,
- .rot_standard_ref = &lid_standard_ref,
+ .rot_standard_ref = NULL,
.default_range = 2, /* g, enough for laptop. */
.config = {
/* AP: by default shutdown all sensors */
@@ -197,8 +177,10 @@ static void wait_for_valid_sample(void)
static int test_lid_angle(void)
{
- struct motion_sensor_t *base = &motion_sensors[0];
- struct motion_sensor_t *lid = &motion_sensors[1];
+ struct motion_sensor_t *base = &motion_sensors[
+ CONFIG_LID_ANGLE_SENSOR_BASE];
+ struct motion_sensor_t *lid = &motion_sensors[
+ CONFIG_LID_ANGLE_SENSOR_LID];
/* We don't have TASK_CHIP so simulate init ourselves */
hook_notify(HOOK_CHIPSET_SHUTDOWN);
@@ -223,7 +205,7 @@ static int test_lid_angle(void)
base->xyz[Z] = 1000;
lid->xyz[X] = 0;
lid->xyz[Y] = 0;
- lid->xyz[Z] = 1000;
+ lid->xyz[Z] = -1000;
/* Initial wake up, like init does */
task_wake(TASK_ID_MOTIONSENSE);
@@ -235,16 +217,16 @@ static int test_lid_angle(void)
TEST_ASSERT(motion_lid_get_angle() == 0);
/* Set lid open to 90 degrees. */
- lid->xyz[X] = -1000;
- lid->xyz[Y] = 0;
+ lid->xyz[X] = 0;
+ lid->xyz[Y] = 1000;
lid->xyz[Z] = 0;
wait_for_valid_sample();
TEST_ASSERT(motion_lid_get_angle() == 90);
/* Set lid open to 225. */
- lid->xyz[X] = 500;
- lid->xyz[Y] = 0;
- lid->xyz[Z] = -500;
+ lid->xyz[X] = 0;
+ lid->xyz[Y] = -500;
+ lid->xyz[Z] = 500;
wait_for_valid_sample();
TEST_ASSERT(motion_lid_get_angle() == 225);
@@ -252,8 +234,8 @@ static int test_lid_angle(void)
* Align base with hinge and make sure it returns unreliable for angle.
* In this test it doesn't matter what the lid acceleration vector is.
*/
- base->xyz[X] = 0;
- base->xyz[Y] = 1000;
+ base->xyz[X] = 1000;
+ base->xyz[Y] = 0;
base->xyz[Z] = 0;
wait_for_valid_sample();
TEST_ASSERT(motion_lid_get_angle() == LID_ANGLE_UNRELIABLE);
@@ -265,9 +247,9 @@ static int test_lid_angle(void)
base->xyz[X] = 500;
base->xyz[Y] = 400;
base->xyz[Z] = 300;
- lid->xyz[X] = -500;
- lid->xyz[Y] = -400;
- lid->xyz[Z] = -300;
+ lid->xyz[X] = 500;
+ lid->xyz[Y] = 400;
+ lid->xyz[Z] = 300;
wait_for_valid_sample();
TEST_ASSERT(motion_lid_get_angle() == 180);
diff --git a/test/test_config.h b/test/test_config.h
index 81542407e2..30369e7207 100644
--- a/test/test_config.h
+++ b/test/test_config.h
@@ -44,7 +44,6 @@
#endif
#ifdef TEST_MOTION_LID
-#define CONFIG_ACCEL_STD_REF_FRAME_OLD
#define CONFIG_LID_ANGLE
#define CONFIG_LID_ANGLE_SENSOR_BASE 0
#define CONFIG_LID_ANGLE_SENSOR_LID 1