summaryrefslogtreecommitdiff
path: root/test/gyro_cal.c
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2020-10-23 12:05:48 -0600
committerCommit Bot <commit-bot@chromium.org>2020-12-08 19:06:07 +0000
commit6f0894886e4d15c60430b380001156b5292438cb (patch)
tree7b26a03738d1640fd610506fbfbb40004297d9f4 /test/gyro_cal.c
parent9760abbefee06a7ffa214dd477665b8c9476061e (diff)
downloadchrome-ec-6f0894886e4d15c60430b380001156b5292438cb.tar.gz
common:online_calibration: Spoof sensor data
This change allows the `accelspoof` ec command to also override the calibration data (bypassing the calibration module). This config flag should be used when testing layers above the EC (kernel and up)'s handling of the calibration values. BRANCH=none BUG=none TEST=Built on eve and added unit tests. TEST=make run-online_calibration_spoof -j Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I4735b9613c152af5559661a91565b05635d6495e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2494986
Diffstat (limited to 'test/gyro_cal.c')
-rw-r--r--test/gyro_cal.c102
1 files changed, 1 insertions, 101 deletions
diff --git a/test/gyro_cal.c b/test/gyro_cal.c
index 85d53789ef..10d48ca18e 100644
--- a/test/gyro_cal.c
+++ b/test/gyro_cal.c
@@ -6,6 +6,7 @@
#include "common.h"
#include "gyro_cal.h"
#include "gyro_still_det.h"
+#include "gyro_cal_init_for_test.h"
#include "motion_sense.h"
#include "test_util.h"
#include <string.h>
@@ -70,107 +71,6 @@ static float normal_random2(float mean, float stddev)
}
/**
- *
- * @param det Pointer to the stillness detector
- * @param var_threshold The variance threshold in units^2
- * @param confidence_delta The confidence delta in units^2
- */
-static void gyro_still_det_initialization_for_test(struct gyro_still_det *det,
- float var_threshold,
- float confidence_delta)
-{
- /* Clear all data structure variables to 0. */
- memset(det, 0, sizeof(struct gyro_still_det));
-
- /*
- * Set the delta about the variance threshold for calculation
- * of the stillness confidence score.
- */
- if (confidence_delta < var_threshold)
- det->confidence_delta = confidence_delta;
- else
- det->confidence_delta = var_threshold;
-
- /*
- * Set the variance threshold parameter for the stillness
- * confidence score.
- */
- det->var_threshold = var_threshold;
-
- /* Signal to start capture of next stillness data window. */
- det->start_new_window = true;
-}
-
-static void gyro_cal_initialization_for_test(struct gyro_cal *gyro_cal)
-{
- /* GyroCal initialization. */
- memset(gyro_cal, 0, sizeof(struct gyro_cal));
-
- /*
- * Initialize the stillness detectors.
- * Gyro parameter input units are [rad/sec].
- * Accel parameter input units are [m/sec^2].
- * Magnetometer parameter input units are [uT].
- */
- gyro_still_det_initialization_for_test(&gyro_cal->gyro_stillness_detect,
- /* var_threshold */ 5e-5f,
- /* confidence_delta */ 1e-5f);
- gyro_still_det_initialization_for_test(
- &gyro_cal->accel_stillness_detect,
- /* var_threshold */ 8e-3f,
- /* confidence_delta */ 1.6e-3f);
- gyro_still_det_initialization_for_test(&gyro_cal->mag_stillness_detect,
- /* var_threshold */ 1.4f,
- /* confidence_delta */ 0.25f);
-
- /* Reset stillness flag and start timestamp. */
- gyro_cal->prev_still = false;
- gyro_cal->start_still_time_us = 0;
-
- /* Set the min and max window stillness duration. */
- gyro_cal->min_still_duration_us = 5 * SECOND;
- gyro_cal->max_still_duration_us = 6 * SECOND;
-
- /* Sets the duration of the stillness processing windows. */
- gyro_cal->window_time_duration_us = 1500000;
-
- /* Set the window timeout duration. */
- gyro_cal->gyro_window_timeout_duration_us = 5 * SECOND;
-
- /* Load the last valid cal from system memory. */
- gyro_cal->bias_x = 0.0f; /* [rad/sec] */
- gyro_cal->bias_y = 0.0f; /* [rad/sec] */
- gyro_cal->bias_z = 0.0f; /* [rad/sec] */
- gyro_cal->calibration_time_us = 0;
-
- /* Set the stillness threshold required for gyro bias calibration. */
- gyro_cal->stillness_threshold = 0.95f;
-
- /*
- * Current window end-time used to assist in keeping sensor data
- * collection in sync. Setting this to zero signals that sensor data
- * will be dropped until a valid end-time is set from the first gyro
- * timestamp received.
- */
- gyro_cal->stillness_win_endtime_us = 0;
-
- /* Gyro calibrations will be applied (see, gyro_cal_remove_bias()). */
- gyro_cal->gyro_calibration_enable = true;
-
- /*
- * Sets the stability limit for the stillness window mean acceptable
- * delta.
- */
- gyro_cal->stillness_mean_delta_limit = 50.0f * MDEG_TO_RAD;
-
- /* Sets the min/max temperature delta limit for the stillness period. */
- gyro_cal->temperature_delta_limit_kelvin = 1.5f;
-
- /* Ensures that the data tracking functionality is reset. */
- init_gyro_cal(gyro_cal);
-}
-
-/**
* Tests that a calibration is updated after a period where the IMU device is
* stationary. Accelerometer and gyroscope measurements are simulated with data
* sheet specs for the BMI160 at their respective noise floors. A magnetometer