diff --git a/board/eve/board.c b/board/eve/board.c index 0b02f79570..e0f168fca4 100644 --- a/board/eve/board.c +++ b/board/eve/board.c @@ -903,7 +903,7 @@ struct motion_sensor_t motion_sensors[] = { .default_range = 1 << 11, /* 16LSB / uT, fixed */ .rot_standard_ref = &mag_standard_ref, .min_frequency = BMM150_MAG_MIN_FREQ, - .max_frequency = BMM150_MAG_MAX_FREQ, + .max_frequency = BMM150_MAG_MAX_FREQ(SPECIAL), .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { diff --git a/board/nautilus/board.c b/board/nautilus/board.c index ba3395e446..d50d4485de 100644 --- a/board/nautilus/board.c +++ b/board/nautilus/board.c @@ -976,7 +976,7 @@ struct motion_sensor_t motion_sensors[] = { .default_range = 1 << 11, /* 16LSB / uT, fixed */ .rot_standard_ref = &mag_standard_ref, .min_frequency = BMM150_MAG_MIN_FREQ, - .max_frequency = BMM150_MAG_MAX_FREQ, + .max_frequency = BMM150_MAG_MAX_FREQ(SPECIAL), .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { diff --git a/board/poppy/board.c b/board/poppy/board.c index f2027516f2..60cdff40dd 100644 --- a/board/poppy/board.c +++ b/board/poppy/board.c @@ -998,7 +998,7 @@ struct motion_sensor_t motion_sensors[] = { .default_range = 1 << 11, /* 16LSB / uT, fixed */ .rot_standard_ref = &mag_standard_ref, .min_frequency = BMM150_MAG_MIN_FREQ, - .max_frequency = BMM150_MAG_MAX_FREQ, + .max_frequency = BMM150_MAG_MAX_FREQ(SPECIAL), .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { diff --git a/board/reef/board.c b/board/reef/board.c index 0e5496db52..f4696b8ce2 100644 --- a/board/reef/board.c +++ b/board/reef/board.c @@ -956,7 +956,7 @@ struct motion_sensor_t motion_sensors[] = { .default_range = 1 << 11, /* 16LSB / uT, fixed */ .rot_standard_ref = &mag_standard_ref, .min_frequency = BMM150_MAG_MIN_FREQ, - .max_frequency = BMM150_MAG_MAX_FREQ, + .max_frequency = BMM150_MAG_MAX_FREQ(SPECIAL), .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { diff --git a/driver/mag_bmm150.h b/driver/mag_bmm150.h index 51b2926e8a..d3c07db11b 100644 --- a/driver/mag_bmm150.h +++ b/driver/mag_bmm150.h @@ -76,7 +76,16 @@ /* Min and Max sampling frequency in mHz */ #define BMM150_MAG_MIN_FREQ 781 -#define BMM150_MAG_MAX_FREQ 80000 + +/* + * From Section 4.2.4, max frequency depends on the preset. + * + * Fmax ~= 1 / (145us * nXY + 500us * nZ + 980us) + * + * To be safe, declare only 75% of the value. + */ +#define BMM150_MAG_MAX_FREQ(_preset) (750000000 / \ + (145 * BMM150_REP(_preset, XY) + 500 * BMM150_REP(_preset, Z) + 980)) struct bmm150_comp_registers { /* Local copy of the compensation registers. */