diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2019-03-21 14:05:36 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-04-04 05:39:54 -0700 |
commit | e726fe4b2c1ea392ed059c4dbdedec253605cd7f (patch) | |
tree | 3825a1d03dcb4c094295ce6bf203654d8cf71b11 | |
parent | 0e99e97634135c9d4e6b60dcd6837bb76d91acf7 (diff) | |
download | chrome-ec-e726fe4b2c1ea392ed059c4dbdedec253605cd7f.tar.gz |
bmm150: lower max frequency to match a frequency supported by BMI160
Be sure the frequency we report does not need to be rounded up by BMI160
when BMM150 is behind BMI160.
For instance, if we set 29Hz as maximum frequency, 29Hz will be rounded
up to 50Hz (BMI160 samples at its own recognized frequency).
At that speed, the BMM150 will lock up.
BUG=b:120942904
BRANCH=none
TEST=On eve with magnetometer check the maximum frequency reported by
the magnetometer is 25Hz.
Check the magnetometer is working with 'ectool motionsense 3'
Change-Id: I7025fe8a400e050907af490784521295d987051a
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1535161
Reviewed-by: Enrico Granata <egranata@chromium.org>
Reviewed-by: Yilun Lin <yllin@chromium.org>
-rw-r--r-- | driver/mag_bmm150.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/driver/mag_bmm150.h b/driver/mag_bmm150.h index 94777e1b61..a504b1a20a 100644 --- a/driver/mag_bmm150.h +++ b/driver/mag_bmm150.h @@ -84,10 +84,10 @@ * * To be safe, declare only 75% of the value. */ -#define BMM150_MAG_MAX_FREQ(_preset) (750000000 / \ +#define __BMM150_MAG_MAX_FREQ(_preset) (750000000 / \ (145 * BMM150_REP(_preset, XY) + 500 * BMM150_REP(_preset, Z) + 980)) -#if (BMM150_MAG_MAX_FREQ(SPECIAL) > CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ) +#if (__BMM150_MAG_MAX_FREQ(SPECIAL) > CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ) #error "EC too slow for magnetometer" #endif @@ -118,6 +118,18 @@ struct bmm150_private_data { #define BMM150_CAL(_s) \ (&BMI160_GET_DATA(_s)->compass.cal) +#ifdef CONFIG_MAG_BMI160_BMM150 +#include "accelgyro_bmi160.h" +/* + * Behind a BMI160, the BMM150 is in forced mode. Be sure to choose a frequency + * comptible with BMI160. + */ +#define BMM150_MAG_MAX_FREQ(_preset) \ + BMI160_REG_TO_ODR(BMI160_ODR_TO_REG(__BMM150_MAG_MAX_FREQ(_preset))) +#else +#define BMM150_MAG_MAX_FREQ(_preset) __BMM150_MAG_MAX_FREQ(_preset) +#endif + /* Specific initialization of BMM150 when behing BMI160 */ int bmm150_init(const struct motion_sensor_t *s); |