summaryrefslogtreecommitdiff
path: root/include/timer.h
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-08-07 22:45:21 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-08-24 19:08:15 +0000
commitde42bb285fa45a777ed7a27be9f4c99c8f606ed8 (patch)
treeafaecf0636aaab1932243b5f5bd9e198cc08e73f /include/timer.h
parent5faadc6748d556375c1effd56dac226f2a773ad1 (diff)
downloadchrome-ec-de42bb285fa45a777ed7a27be9f4c99c8f606ed8.tar.gz
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 <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/291992 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Diffstat (limited to 'include/timer.h')
-rw-r--r--include/timer.h10
1 files changed, 10 insertions, 0 deletions
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 */