diff options
Diffstat (limited to 'src/include/sleep.h')
-rw-r--r-- | src/include/sleep.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/include/sleep.h b/src/include/sleep.h index 161842a29..022b7be23 100644 --- a/src/include/sleep.h +++ b/src/include/sleep.h @@ -30,14 +30,12 @@ extern "C" { #endif
#ifdef CH_USE_SLEEP
void chThdSleep(t_time time);
-#ifdef CH_USE_SYSTEMTIME
- void chThdSleepUntil(t_time time);
-#endif /* CH_USE_SYSTEMTIME */
#endif /* CH_USE_SLEEP */
#ifdef __cplusplus
}
#endif
+#ifdef CH_USE_SYSTEMTIME
/**
* Returns the number of system ticks since the \p chSysInit() invocation.
* @return the system ticks number
@@ -48,6 +46,20 @@ extern "C" { */
#define chSysGetTime() rlist.r_stime
+/**
+ * Suspends the invoking thread until the system time arrives to the specified
+ * value.
+ * @note The function is available only if the \p CH_USE_SYSTEMTIME
+ * option is enabled in \p chconf.h.
+ */
+#define chThdSleepUntil(t) { \
+ chSysLock(); \
+ chSchGoSleepTimeoutS(PRSLEEP, \
+ (t_time)((t) - chSysGetTime())) \
+ chSysUnlock(); \
+}
+#endif /* CH_USE_SYSTEMTIME */
+
#endif /* _SLEEP_H_ */
/** @} */
|