summaryrefslogtreecommitdiff
path: root/driver/accelgyro_lsm6dsm.h
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2019-01-18 12:47:25 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-01-19 04:20:20 -0800
commitdfd8046c65df484870d12db172ae78f47169c0b8 (patch)
tree5013178113995516a42e8178739c627a166820d3 /driver/accelgyro_lsm6dsm.h
parent97b4595647cba30423c243cc4b70034f9ef942f2 (diff)
downloadchrome-ec-dfd8046c65df484870d12db172ae78f47169c0b8.tar.gz
LSM6: Throw out junk data after ODR changes
After an ODR change on the LSM6DSx sensor, a certain amount of data will be invalid until the filter for the sensor settles. This change is to throw out datapoints after an ODR change to avoid sending the AP any outright bad values. Currently, we're waiting for clarification from ST about how many data points to throw out and whether the accelerometer and gyroscope ODR changes affect each other. For now, we're being conservative and throwing out 4 samples of any sensors on after an ODR change. BUG=b:122912601 BRANCH=octopus TEST=almost all standard deviation failures gone when running CTS on phaser360, a few very close gyro errors remain Change-Id: Ie00c85e18333ce578152ed3ac616815405e8111d Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1423123 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Enrico Granata <egranata@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'driver/accelgyro_lsm6dsm.h')
-rw-r--r--driver/accelgyro_lsm6dsm.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/driver/accelgyro_lsm6dsm.h b/driver/accelgyro_lsm6dsm.h
index 3336326b90..fd7f59c3b3 100644
--- a/driver/accelgyro_lsm6dsm.h
+++ b/driver/accelgyro_lsm6dsm.h
@@ -267,9 +267,22 @@ struct lsm6dsm_data {
struct lsm6dsm_fifo_data config;
struct lsm6dsm_fifo_data current;
int next_in_patten;
+ /*
+ * After an ODR change, the sensor filters need settling time; discard
+ * initial samples with incorrect values
+ */
+ unsigned int samples_to_discard[FIFO_DEV_NUM];
#endif
};
+/*
+ * Note: The specific number of samples to discard depends on the filters
+ * configured for the chip, as well as the ODR being set. For most of our
+ * allowed ODRs, 4 should suffice.
+ * See: ST's LSM6DSM application notes (AN4987) Tables 17 and 19 for details
+ */
+#define LSM6DSM_DISCARD_SAMPLES 4
+
#define LSM6DSM_MAIN_SENSOR(_s) ((_s) - (_s)->type)
#ifdef CONFIG_ACCEL_FIFO