summaryrefslogtreecommitdiff
path: root/test/online_calibration.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/online_calibration.c')
-rw-r--r--test/online_calibration.c62
1 files changed, 29 insertions, 33 deletions
diff --git a/test/online_calibration.c b/test/online_calibration.c
index 1b3abf51bc..cecb543eef 100644
--- a/test/online_calibration.c
+++ b/test/online_calibration.c
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -48,17 +48,14 @@ static struct accelgyro_drv mock_sensor_driver = {
.read_temp = mock_read_temp,
};
-static struct accel_cal_algo base_accel_cal_algos[] = {
- {
- .newton_fit = NEWTON_FIT(4, 15, FLOAT_TO_FP(0.01f),
- FLOAT_TO_FP(0.25f),
- FLOAT_TO_FP(1.0e-8f), 100),
- }
-};
+static struct accel_cal_algo base_accel_cal_algos[] = { {
+ .newton_fit = NEWTON_FIT(4, 15, FLOAT_TO_FP(0.01f), FLOAT_TO_FP(0.25f),
+ FLOAT_TO_FP(1.0e-8f), 100),
+} };
static struct accel_cal base_accel_cal_data = {
- .still_det = STILL_DET(FLOAT_TO_FP(0.00025f), 800 * MSEC, 1200 * MSEC,
- 5),
+ .still_det =
+ STILL_DET(FLOAT_TO_FP(0.00025f), 800 * MSEC, 1200 * MSEC, 5),
.algos = base_accel_cal_algos,
.num_temp_windows = ARRAY_SIZE(base_accel_cal_algos),
};
@@ -68,9 +65,8 @@ static struct mag_cal_t lid_mag_cal_data;
static bool next_accel_cal_accumulate_result;
static fpv3_t next_accel_cal_bias;
-bool accel_cal_accumulate(
- struct accel_cal *cal, uint32_t sample_time, fp_t x, fp_t y, fp_t z,
- fp_t temp)
+bool accel_cal_accumulate(struct accel_cal *cal, uint32_t sample_time, fp_t x,
+ fp_t y, fp_t z, fp_t temp)
{
if (next_accel_cal_accumulate_result) {
cal->bias[X] = next_accel_cal_bias[X];
@@ -110,8 +106,8 @@ static int test_read_temp_on_stage(void)
mock_read_temp_results = &expected;
data.sensor_num = BASE;
- rc = online_calibration_process_data(
- &data, &motion_sensors[0], __hw_clock_source_read());
+ rc = online_calibration_process_data(&data, &motion_sensors[0],
+ __hw_clock_source_read());
TEST_EQ(rc, EC_SUCCESS, "%d");
TEST_EQ(expected.used_count, 1, "%d");
@@ -128,12 +124,12 @@ static int test_read_temp_from_cache_on_stage(void)
mock_read_temp_results = &expected;
data.sensor_num = BASE;
- rc = online_calibration_process_data(
- &data, &motion_sensors[0], __hw_clock_source_read());
+ rc = online_calibration_process_data(&data, &motion_sensors[0],
+ __hw_clock_source_read());
TEST_EQ(rc, EC_SUCCESS, "%d");
- rc = online_calibration_process_data(
- &data, &motion_sensors[0], __hw_clock_source_read());
+ rc = online_calibration_process_data(&data, &motion_sensors[0],
+ __hw_clock_source_read());
TEST_EQ(rc, EC_SUCCESS, "%d");
TEST_EQ(expected.used_count, 1, "%d");
@@ -150,13 +146,13 @@ static int test_read_temp_twice_after_cache_stale(void)
mock_read_temp_results = &expected;
data.sensor_num = BASE;
- rc = online_calibration_process_data(
- &data, &motion_sensors[0], __hw_clock_source_read());
+ rc = online_calibration_process_data(&data, &motion_sensors[0],
+ __hw_clock_source_read());
TEST_EQ(rc, EC_SUCCESS, "%d");
sleep(2);
- rc = online_calibration_process_data(
- &data, &motion_sensors[0], __hw_clock_source_read());
+ rc = online_calibration_process_data(&data, &motion_sensors[0],
+ __hw_clock_source_read());
TEST_EQ(rc, EC_SUCCESS, "%d");
TEST_EQ(expected.used_count, 2, "%d");
@@ -176,17 +172,17 @@ static int test_new_calibration_value(void)
next_accel_cal_accumulate_result = false;
data.sensor_num = BASE;
- rc = online_calibration_process_data(
- &data, &motion_sensors[BASE], __hw_clock_source_read());
+ rc = online_calibration_process_data(&data, &motion_sensors[BASE],
+ __hw_clock_source_read());
TEST_EQ(rc, EC_SUCCESS, "%d");
TEST_EQ(online_calibration_has_new_values(), false, "%d");
next_accel_cal_accumulate_result = true;
- next_accel_cal_bias[X] = 0.01f; /* expect: 81 */
- next_accel_cal_bias[Y] = -0.02f; /* expect: -163 */
- next_accel_cal_bias[Z] = 0; /* expect: 0 */
- rc = online_calibration_process_data(
- &data, &motion_sensors[BASE], __hw_clock_source_read());
+ next_accel_cal_bias[X] = 0.01f; /* expect: 81 */
+ next_accel_cal_bias[Y] = -0.02f; /* expect: -163 */
+ next_accel_cal_bias[Z] = 0; /* expect: 0 */
+ rc = online_calibration_process_data(&data, &motion_sensors[BASE],
+ __hw_clock_source_read());
TEST_EQ(rc, EC_SUCCESS, "%d");
TEST_EQ(online_calibration_has_new_values(), true, "%d");
@@ -216,8 +212,8 @@ int test_mag_reading_updated_cal(void)
init_mag_cal(&expected_results);
mag_cal_update(&expected_results, test_values);
- rc = online_calibration_process_data(
- &data, &motion_sensors[LID], __hw_clock_source_read());
+ rc = online_calibration_process_data(&data, &motion_sensors[LID],
+ __hw_clock_source_read());
TEST_EQ(rc, EC_SUCCESS, "%d");
TEST_EQ(expected_results.kasa_fit.nsamples,
lid_mag_cal_data.kasa_fit.nsamples, "%d");
@@ -231,7 +227,7 @@ void before_test(void)
online_calibration_init();
}
-void run_test(int argc, char **argv)
+void run_test(int argc, const char **argv)
{
test_reset();