drivers/sensors/lis2dh: use realtime clock if monotonic is not available

This commit is contained in:
Juha Niskanen 2018-01-31 07:41:39 -06:00 committed by Gregory Nutt
parent 325a5804f1
commit a5cb1129f9

View File

@ -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);