From a5cb1129f952127befd50b750c0096a37d639b8c Mon Sep 17 00:00:00 2001 From: Juha Niskanen Date: Wed, 31 Jan 2018 07:41:39 -0600 Subject: [PATCH] drivers/sensors/lis2dh: use realtime clock if monotonic is not available --- drivers/sensors/lis2dh.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/sensors/lis2dh.c b/drivers/sensors/lis2dh.c index 502246ee52..8efe51f133 100644 --- a/drivers/sensors/lis2dh.c +++ b/drivers/sensors/lis2dh.c @@ -1664,7 +1664,13 @@ static int lis2dh_reboot(FAR struct lis2dh_dev_s *dev) int32_t diff_msec; uint8_t value; + /* Prefer monotonic for timeout calculation when enabled. */ + +#ifdef CONFIG_CLOCK_MONOTONIC (void)clock_gettime(CLOCK_MONOTONIC, &start); +#else + (void)clock_gettime(CLOCK_REALTIME, &start); +#endif /* Reboot to reset chip. */ @@ -1689,7 +1695,11 @@ static int lis2dh_reboot(FAR struct lis2dh_dev_s *dev) break; } +#ifdef CONFIG_CLOCK_MONOTONIC (void)clock_gettime(CLOCK_MONOTONIC, &curr); +#else + (void)clock_gettime(CLOCK_REALTIME, &curr); +#endif diff_msec = (curr.tv_sec - start.tv_sec) * 1000; diff_msec += (curr.tv_nsec - start.tv_nsec) / (1000 * 1000);