mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-11 02:15:14 +00:00
common: motion_sense: Fix Light sensor sequencing
Light was gathered too often: - missing timestamp when reading completes. - error when calculating next timestamp. BRANCH=ryu BUG=chrome-os-partner:32829 TEST=check the light is sampled ~ every seconds, whatever the motion task frequency Change-Id: Id070af3c8d2e080780334822278dda267bea058c Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/295636 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
7a2299163b
commit
e11637aed6
@@ -123,11 +123,11 @@ static inline int motion_sensor_time_to_read(const timestamp_t *ts,
|
||||
if (rate == 0)
|
||||
return 0;
|
||||
/*
|
||||
* converting from mHz to ms, need 1e6,
|
||||
* converting from mHz to us, need 1e9,
|
||||
* If within 95% of the time, check sensor.
|
||||
*/
|
||||
return time_after(ts->le.lo,
|
||||
sensor->last_collection + (950000 / rate) / 10);
|
||||
sensor->last_collection + 950000000 / rate);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -373,8 +373,10 @@ static int motion_sense_process(struct motion_sensor_t *sensor,
|
||||
|
||||
#ifdef CONFIG_ACCEL_INTERRUPTS
|
||||
if ((event & TASK_EVENT_MOTION_INTERRUPT_MASK) &&
|
||||
(sensor->drv->irq_handler != NULL))
|
||||
(sensor->drv->irq_handler != NULL)) {
|
||||
sensor->drv->irq_handler(sensor, event);
|
||||
sensor->last_collection = ts->le.lo;
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_ACCEL_FIFO
|
||||
if (sensor->drv->load_fifo != NULL) {
|
||||
@@ -464,8 +466,7 @@ void motion_sense_task(void)
|
||||
/* if the sensor is active in the current power state */
|
||||
if (SENSOR_ACTIVE(sensor)) {
|
||||
if (sensor->state != SENSOR_INITIALIZED) {
|
||||
CPRINTS("S%d active, not initalized",
|
||||
sensor);
|
||||
CPRINTS("S%d active not initalized", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user