summaryrefslogtreecommitdiff
path: root/test/motion_common.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /test/motion_common.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-release-R99-14469.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'test/motion_common.c')
-rw-r--r--test/motion_common.c145
1 files changed, 0 insertions, 145 deletions
diff --git a/test/motion_common.c b/test/motion_common.c
deleted file mode 100644
index 135da43188..0000000000
--- a/test/motion_common.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/* Copyright 2018 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.
- *
- * Common test code to test lid angle calculation.
- */
-
-#include "accelgyro.h"
-#include "driver/accelgyro_bmi_common.h"
-#include "host_command.h"
-#include "motion_common.h"
-#include "motion_sense.h"
-#include "task.h"
-#include "timer.h"
-
-/*****************************************************************************/
-/* Mock functions */
-static int accel_init(struct motion_sensor_t *s)
-{
- return sensor_init_done(s);
-}
-
-static int accel_read(const struct motion_sensor_t *s, intv3_t v)
-{
- rotate(s->xyz, *s->rot_standard_ref, v);
- return EC_SUCCESS;
-}
-
-static int accel_set_range(struct motion_sensor_t *s, int range, int rnd)
-{
- s->current_range = range;
- return EC_SUCCESS;
-}
-
-static int accel_get_resolution(const struct motion_sensor_t *s)
-{
-#ifdef TEST_BODY_DETECTION
- /* Assume we are using BMI160 */
- return BMI_RESOLUTION;
-#endif
- return 0;
-}
-
-int test_data_rate[2] = { 0 };
-
-static int accel_set_data_rate(const struct motion_sensor_t *s,
- const int rate,
- const int rnd)
-{
- test_data_rate[s - motion_sensors] = rate | (rnd ? ROUND_UP_FLAG : 0);
- return EC_SUCCESS;
-}
-
-static int accel_get_data_rate(const struct motion_sensor_t *s)
-{
- return test_data_rate[s - motion_sensors];
-}
-
-#ifdef TEST_BODY_DETECTION
-static int accel_get_rms_noise(const struct motion_sensor_t *s)
-{
- /* Assume we are using BMI160 */
- fp_t rate = INT_TO_FP(accel_get_data_rate(s) / 1000);
- fp_t noise_100hz = INT_TO_FP(BMI160_ACCEL_RMS_NOISE_100HZ);
- fp_t sqrt_rate_ratio = fp_sqrtf(fp_div(rate,
- INT_TO_FP(BMI_ACCEL_100HZ)));
- return FP_TO_INT(fp_mul(noise_100hz, sqrt_rate_ratio));
-}
-#endif
-
-const struct accelgyro_drv test_motion_sense = {
- .init = accel_init,
- .read = accel_read,
- .set_range = accel_set_range,
- .get_resolution = accel_get_resolution,
- .set_data_rate = accel_set_data_rate,
- .get_data_rate = accel_get_data_rate,
-#ifdef CONFIG_BODY_DETECTION
- .get_rms_noise = accel_get_rms_noise,
-#endif
-};
-
-struct motion_sensor_t motion_sensors[] = {
- [BASE] = {
- .name = "base",
- .active_mask = SENSOR_ACTIVE_S0_S3_S5,
- .chip = MOTIONSENSE_CHIP_LSM6DS0,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_BASE,
- .drv = &test_motion_sense,
- .rot_standard_ref = NULL,
- .default_range = 2, /* g, enough for laptop. */
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = TEST_LID_FREQUENCY,
- },
- },
- },
- [LID] = {
- .name = "lid",
- .active_mask = SENSOR_ACTIVE_S0,
- .chip = MOTIONSENSE_CHIP_KXCJ9,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &test_motion_sense,
- .rot_standard_ref = NULL,
- .default_range = 2, /* g, enough for laptop. */
- .config = {
- /* EC use accel for angle detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = TEST_LID_FREQUENCY,
- },
- },
- },
-};
-const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
-
-/* Read 6 samples from array to sensor vectors, convert units if necessary. */
-void feed_accel_data(const float *array, int *idx,
- int (filler)(const struct motion_sensor_t*, const float))
-{
- int i, j;
-
- for (i = 0; i < motion_sensor_count; i++) {
- struct motion_sensor_t *s = &motion_sensors[i];
-
- for (j = X; j <= Z; j++)
- s->xyz[j] = filler(s, array[*idx + i * 3 + j]);
- }
- *idx += 6;
-}
-
-void wait_for_valid_sample(void)
-{
- uint8_t sample;
- uint8_t *lpc_status = host_get_memmap(EC_MEMMAP_ACC_STATUS);
-
- sample = *lpc_status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK;
- usleep(TEST_LID_EC_RATE);
- while ((*lpc_status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK) == sample)
- usleep(TEST_LID_SLEEP_RATE);
-}
-
-