summaryrefslogtreecommitdiff
path: root/include/accelgyro.h
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2020-05-17 16:43:02 -0700
committerCommit Bot <commit-bot@chromium.org>2020-11-12 03:23:26 +0000
commitd28c10498cdbf007b97b5c0a9a951373574d4eea (patch)
tree3d66ca06837aae98ff747fff85b439976e563045 /include/accelgyro.h
parent9676f9291f60efdfb31373aeb77385ebb6e9f6e5 (diff)
downloadchrome-ec-d28c10498cdbf007b97b5c0a9a951373574d4eea.tar.gz
motion_sense: Make change in range permanent
When AP changes range, unlike offset or ODR, it was not surviving init() call. If the sensor is powered off in S3, at resume the range would be back to the default. To make it consistent with other attributes, remember range change until EC powers down. - remove get_range - add current_range to store the range currently used. This is modifiable by the AP - when the AP shutdown, revert current_range to default_range - Remove const attribute for sensor structure when init and set_range is called. BUG=chromium:1083791 BRANCH=none TEST=One eve branch, check range is preserved even after 'shutdown -h 0' Change-Id: Ia7126ac0cc9c3fef60b4464d95d6dd15e64b0fc4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2215751 Reviewed-by: Yuval Peress <peress@chromium.org>
Diffstat (limited to 'include/accelgyro.h')
-rw-r--r--include/accelgyro.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/include/accelgyro.h b/include/accelgyro.h
index c85922f3ef..5d755b7eaa 100644
--- a/include/accelgyro.h
+++ b/include/accelgyro.h
@@ -22,11 +22,10 @@
struct accelgyro_drv {
/**
* Initialize accelerometers.
- * @s Pointer to sensor data pointer. Sensor data will be
- * allocated on success.
+ * @s Pointer to sensor data pointer.
* @return EC_SUCCESS if successful, non-zero if error.
*/
- int (*init)(const struct motion_sensor_t *s);
+ int (*init)(struct motion_sensor_t *s);
/**
* Read all three accelerations of an accelerometer. Note that all
@@ -48,19 +47,22 @@ struct accelgyro_drv {
int (*read_temp)(const struct motion_sensor_t *s, int *temp);
/**
- * Setter and getter methods for the sensor range. The sensor range
+ * Setter method for the sensor range. The sensor range
* defines the maximum value that can be returned from read(). As the
* range increases, the resolution gets worse.
* @s Pointer to sensor data.
* @range Range (Units are +/- G's for accel, +/- deg/s for gyro)
* @rnd Rounding flag. If true, it rounds up to nearest valid
* value. Otherwise, it rounds down.
+ *
+ * sensor->current_range is updated.
+ * It will be preserved unless EC reboots or AP is shutdown (S5).
+ *
* @return EC_SUCCESS if successful, non-zero if error.
*/
- int (*set_range)(const struct motion_sensor_t *s,
+ int (*set_range)(struct motion_sensor_t *s,
int range,
int rnd);
- int (*get_range)(const struct motion_sensor_t *s);
/**
* Setter and getter methods for the sensor resolution.
@@ -121,7 +123,7 @@ struct accelgyro_drv {
* Either a one shot mode (enable is not used),
* or enter/exit a calibration state.
*/
- int (*perform_calib)(const struct motion_sensor_t *s,
+ int (*perform_calib)(struct motion_sensor_t *s,
int enable);
/**
* handler for interrupts triggered by the sensor: it runs in task and
@@ -181,7 +183,6 @@ enum rgb_index {
/* Used to save sensor information */
struct accelgyro_saved_data_t {
int odr;
- int range;
uint16_t scale[3];
};