aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/sleep.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/include/sleep.h b/src/include/sleep.h
index 36ba9470a..ac76b3fe8 100644
--- a/src/include/sleep.h
+++ b/src/include/sleep.h
@@ -25,6 +25,23 @@
#ifndef _SLEEP_H_
#define _SLEEP_H_
+/**
+ * Time conversion utility. Converts from seconds to system ticks number.
+ */
+#define S2ST(sec) ((sec) * CH_FREQUENCY)
+
+/**
+ * Time conversion utility. Converts from milliseconds to system ticks number.
+ * @note The result is rounded upward to the next tick boundary.
+ */
+#define MS2ST(msec) (((((msec) - 1L) * CH_FREQUENCY) / 1000) + 1)
+
+/**
+ * Time conversion utility. Converts from microseconds to system ticks number.
+ * @note The result is rounded upward to the next tick boundary.
+ */
+#define US2ST(usec) (((((usec) - 1L) * CH_FREQUENCY) / 1000000) + 1)
+
#ifdef __cplusplus
extern "C" {
#endif