summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-08-25 18:57:31 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-08-29 00:04:15 -0700
commite11637aed6b58085c13bcc4e88cef706a5184964 (patch)
tree6102376a07ef58de533631cbbbf589899e9f3205
parent7a2299163b7769b546db53c0dd225eee9e0a0df1 (diff)
downloadchrome-ec-e11637aed6b58085c13bcc4e88cef706a5184964.tar.gz
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>
-rw-r--r--common/motion_sense.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 64179750f3..b5de3480ff 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -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;
}