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>
This commit is contained in:
Gwendal Grignou 2020-11-06 10:21:07 -08:00 committed by Commit Bot
parent 0dc8b304f1
commit 4a399faf37
3 changed files with 7 additions and 30 deletions

View File

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

View File

@ -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();

View File

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