From de42bb285fa45a777ed7a27be9f4c99c8f606ed8 Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Fri, 7 Aug 2015 22:45:21 -0700 Subject: motion_sense: calculate threshold properly Working on light sensor, sensor were read on every time, SENSOR_EC_THRES was not taken into account. Fix 64/32 conversions and add a function for dealing with rollover. TEST=Set light sensor probe at 1s. Set accel sensor at 100Hz to fill fifo often; verify that light sensor is queried every second only. BRANCH=smaug BUG=chrome-os-partner:39900 Change-Id: If1df53c1a9a304c992f8e517f5d516210118a437 Signed-off-by: Gwendal Grignou Reviewed-on: https://chromium-review.googlesource.com/291992 Reviewed-by: Sheng-liang Song --- include/timer.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/timer.h') diff --git a/include/timer.h b/include/timer.h index 2c439e959e..5f92207252 100644 --- a/include/timer.h +++ b/include/timer.h @@ -155,4 +155,14 @@ static inline unsigned time_since32(timestamp_t start) */ clock_t clock(void); +/** + * To compare time and deal with rollover + * + * Return true if a is after b. + */ +static inline int time_after(uint32_t a, uint32_t b) +{ + return (int32_t)(b - a) < 0; +} + #endif /* __CROS_EC_TIMER_H */ -- cgit v1.2.1