summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2020-11-06 10:21:07 -0800
committerCommit Bot <commit-bot@chromium.org>2020-11-23 05:57:46 +0000
commit4a399faf37a8c14797ea9f60e6430e678e6f8a15 (patch)
treed31adb415749d7292f83406eee29421e787e1cbd
parent0dc8b304f1a4857e4897fe40ae0fe7821a9f8c51 (diff)
downloadchrome-ec-4a399faf37a8c14797ea9f60e6430e678e6f8a15.tar.gz
test: motion: Update test to match motion_sense
Put sensors in forced mode, since interrupts are not generated in test mode. Remove unnecessary task wakeup, since motion sense are sending them. Fix comments and remove empty code. BUG=b:170703322 BRANCH=kukui TEST=unittest Change-Id: Ic9096998a29cebeb47bed5cc2c148b7743f6c78f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2523295 Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r--test/motion_common.c1
-rw-r--r--test/motion_lid.c33
-rw-r--r--test/test_config.h3
3 files changed, 7 insertions, 30 deletions
diff --git a/test/motion_common.c b/test/motion_common.c
index 4efa407b9f..135da43188 100644
--- a/test/motion_common.c
+++ b/test/motion_common.c
@@ -138,7 +138,6 @@ void wait_for_valid_sample(void)
sample = *lpc_status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK;
usleep(TEST_LID_EC_RATE);
- task_wake(TASK_ID_MOTIONSENSE);
while ((*lpc_status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK) == sample)
usleep(TEST_LID_SLEEP_RATE);
}
diff --git a/test/motion_lid.c b/test/motion_lid.c
index 2c6c216430..d3b64fa1ba 100644
--- a/test/motion_lid.c
+++ b/test/motion_lid.c
@@ -29,7 +29,7 @@ extern enum chipset_state_mask sensor_active;
#define TEST_LID_EC_RATE (10 * MSEC)
/*
- * Time in ms to wait for the task to read the vectors.
+ * Time in us to wait for the task to read the vectors.
*/
#define TEST_LID_SLEEP_RATE (TEST_LID_EC_RATE / 5)
#define ONE_G_MEASURED (1 << 14)
@@ -95,11 +95,6 @@ struct motion_sensor_t motion_sensors[] = {
.rot_standard_ref = NULL,
.default_range = MOTION_SCALING_FACTOR / ONE_G_MEASURED,
.config = {
- /* AP: by default shutdown all sensors */
- [SENSOR_CONFIG_AP] = {
- .odr = 0,
- .ec_rate = 0,
- },
/* EC use accel for angle detection */
[SENSOR_CONFIG_EC_S0] = {
.odr = 119000 | ROUND_UP_FLAG,
@@ -110,15 +105,11 @@ struct motion_sensor_t motion_sensors[] = {
.odr = 119000 | ROUND_UP_FLAG,
.ec_rate = TEST_LID_EC_RATE * 100,
},
- [SENSOR_CONFIG_EC_S5] = {
- .odr = 0,
- .ec_rate = 0,
- },
},
},
[LID] = {
.name = "lid",
- .active_mask = SENSOR_ACTIVE_S0,
+ .active_mask = SENSOR_ACTIVE_S0_S3,
.chip = MOTIONSENSE_CHIP_KXCJ9,
.type = MOTIONSENSE_TYPE_ACCEL,
.location = MOTIONSENSE_LOC_LID,
@@ -126,11 +117,6 @@ struct motion_sensor_t motion_sensors[] = {
.rot_standard_ref = NULL,
.default_range = MOTION_SCALING_FACTOR / ONE_G_MEASURED,
.config = {
- /* AP: by default shutdown all sensors */
- [SENSOR_CONFIG_AP] = {
- .odr = 0,
- .ec_rate = 0,
- },
/* EC use accel for angle detection */
[SENSOR_CONFIG_EC_S0] = {
.odr = 119000 | ROUND_UP_FLAG,
@@ -141,10 +127,6 @@ struct motion_sensor_t motion_sensors[] = {
.odr = 200000 | ROUND_UP_FLAG,
.ec_rate = TEST_LID_EC_RATE * 100,
},
- [SENSOR_CONFIG_EC_S5] = {
- .odr = 0,
- .ec_rate = 0,
- },
},
},
};
@@ -159,7 +141,6 @@ static void wait_for_valid_sample(void)
sample = *lpc_status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK;
usleep(TEST_LID_EC_RATE);
- task_wake(TASK_ID_MOTIONSENSE);
while ((*lpc_status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK) == sample)
usleep(TEST_LID_SLEEP_RATE);
}
@@ -175,13 +156,15 @@ static int test_lid_angle(void)
/* We don't have TASK_CHIP so simulate init ourselves */
hook_notify(HOOK_CHIPSET_SHUTDOWN);
+ /* Wait for the sensor task to start */
+ msleep(50);
TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S5);
TEST_ASSERT(accel_get_data_rate(lid) == 0);
/* Go to S0 state */
hook_notify(HOOK_CHIPSET_SUSPEND);
hook_notify(HOOK_CHIPSET_RESUME);
- msleep(1000);
+ msleep(50);
TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S0);
TEST_ASSERT(accel_get_data_rate(lid) == 119000);
@@ -196,12 +179,6 @@ static int test_lid_angle(void)
lid->xyz[Y] = 0;
lid->xyz[Z] = -ONE_G_MEASURED;
gpio_set_level(GPIO_LID_OPEN, 0);
- /* Initial wake up, like init does */
- task_wake(TASK_ID_MOTIONSENSE);
-
- /* wait for the EC sampling period to expire */
- msleep(TEST_LID_EC_RATE);
- task_wake(TASK_ID_MOTIONSENSE);
wait_for_valid_sample();
lid_angle = motion_lid_get_angle();
diff --git a/test/test_config.h b/test/test_config.h
index a9545421bb..51c2e5603d 100644
--- a/test/test_config.h
+++ b/test/test_config.h
@@ -181,7 +181,8 @@ enum sensor_id {
#define CONFIG_ACCEL_STD_REF_FRAME_OLD
#endif
-#if defined(TEST_MOTION_ANGLE_TABLET)
+#if defined(TEST_MOTION_ANGLE_TABLET) || \
+ defined(TEST_MOTION_LID)
#define CONFIG_ACCEL_FORCE_MODE_MASK \
((1 << CONFIG_LID_ANGLE_SENSOR_BASE) | \
(1 << CONFIG_LID_ANGLE_SENSOR_LID))