summaryrefslogtreecommitdiff
path: root/include/online_calibration.h
blob: cafd59f0f51fb7ebced6937ba3aa7a319adc690c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* 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.
 */

#ifndef __CROS_EC_ONLINE_CALIBRATION_H
#define __CROS_EC_ONLINE_CALIBRATION_H

#include "motion_sense.h"
#include "stdbool.h"

/**
 * Initialize the online calibration caches.
 */
void online_calibration_init(void);

/**
 * Process a new data measurement from a given sensor.
 *
 * @param data Pointer to the data that should be processed.
 * @param sensor Pointer to the sensor that generated the data.
 * @param timestamp The time associated with the sample
 * @return EC_SUCCESS when successful.
 */
int online_calibration_process_data(
	struct ec_response_motion_sensor_data *data,
	struct motion_sensor_t *sensor,
	uint32_t timestamp);

/**
 * Check if new calibration values are available since the last read.
 *
 * @return True if the calibration values have changed.
 */
bool online_calibration_has_new_values(void);

/**
 * Read available calibration values and reset dirty bits.
 *
 * @param sensor_num The sensor index to get the calibration values for.
 * @param out The target to copy the data into.
 * @return True if a value was written to `out`.
 */
bool online_calibration_read(struct motion_sensor_t *sensor,
			     struct ec_response_online_calibration_data *out);

#endif /* __CROS_EC_ONLINE_CALIBRATION_H */