diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2015-08-25 18:57:31 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2016-08-01 16:37:54 +0000 |
commit | 5e8a89ee7c8c26a6e1e216bbf29d55d38e8828b9 (patch) | |
tree | 38388e8565b7e040c413a841bc242306fdbaf696 | |
parent | 8112e0168d31ec5ad353ed0cfdd317b31968f8d6 (diff) | |
download | chrome-ec-5e8a89ee7c8c26a6e1e216bbf29d55d38e8828b9.tar.gz |
UPSTREAM: common: motion_sense: Fix Light sensor sequencing
Light was gathered too often:
- missing timestamp when reading completes.
- error when calculating next timestamp.
BRANCH=ry, cyan
BUG=chrome-os-partner:3282, b:27849483
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>
(cherry picked from commit e11637aed6b58085c13bcc4e88cef706a5184964)
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/359362
-rw-r--r-- | common/motion_sense.c | 11 |
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; } |