diff options
-rw-r--r-- | common/motion_sense.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index 114f240fba..0952068a72 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -211,28 +211,28 @@ static int motion_sense_set_ec_rate_from_ap( if (new_rate_us == 0) return 0; - if (motion_sensor_in_forced_mode(sensor)) + + if (odr_mhz == 0) /* - * AP EC sampling rate does not matter: we will collect at the - * requested sensor frequency. + * No event (interrupt or forced mode) are generated, + * any ec rate works. */ goto end_set_ec_rate_from_ap; - if (odr_mhz == 0) - goto end_set_ec_rate_from_ap; /* * If the EC collection rate is close to the sensor data rate, - * given variation from the EC scheduler, it is possible that a sensor - * will not present any measurement for a given time slice, and then 2 - * measurement for the next. That will create a large interval between - * 2 measurements. - * To prevent that, increase the EC period by 5% to be sure to get at - * least one measurement at every collection time. + * given variation from the EC scheduler, we want to be sure the EC is + * ready to send an event to the AP when either the interrupt arrives, + * or the EC is actively probing the sensor. + * Decrease the EC period by 5% to be sure to get at least one + * measurement at every collection time. * We will apply that correction only if the ec rate is within 10% of * the data rate. + * It is possible for sensors at the same ODR to not be in phase. + * One will have a delay guarantee to be less than its ODR. */ if (SECOND * 1100 / odr_mhz > new_rate_us) - new_rate_us = new_rate_us / 100 * 105; + new_rate_us = new_rate_us / 95 * 100; end_set_ec_rate_from_ap: return MAX(new_rate_us, motion_min_interval); |