diff options
Diffstat (limited to 'os/rt/include/chvt.h')
-rw-r--r-- | os/rt/include/chvt.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/os/rt/include/chvt.h b/os/rt/include/chvt.h index ea84df9fd..35d9986c0 100644 --- a/os/rt/include/chvt.h +++ b/os/rt/include/chvt.h @@ -160,6 +160,42 @@ struct virtual_timer { #define US2ST(usec) \
((systime_t)(((((uint32_t)(usec)) * \
((uint32_t)CH_CFG_ST_FREQUENCY) - 1UL) / 1000000UL) + 1UL))
+
+/**
+ * @brief System ticks to seconds.
+ * @details Converts from system ticks number to seconds.
+ * @note The result is rounded up to the next second boundary.
+ *
+ * @param[in] n number of system ticks
+ * @return The number of seconds.
+ *
+ * @api
+ */
+#define ST2S(n) ((((n) - 1UL) / CH_CFG_ST_FREQUENCY) + 1UL)
+
+/**
+ * @brief System ticks to milliseconds.
+ * @details Converts from system ticks number to milliseconds.
+ * @note The result is rounded up to the next millisecond boundary.
+ *
+ * @param[in] n number of system ticks
+ * @return The number of milliseconds.
+ *
+ * @api
+ */
+#define ST2MS(n) ((((n) - 1UL) / (CH_CFG_ST_FREQUENCY / 1000UL)) + 1UL)
+
+/**
+ * @brief System ticks to microseconds.
+ * @details Converts from system ticks number to microseconds.
+ * @note The result is rounded up to the next microsecond boundary.
+ *
+ * @param[in] n number of system ticks
+ * @return The number of microseconds.
+ *
+ * @api
+ */
+#define ST2US(n) ((((n) - 1UL) / (CH_CFG_ST_FREQUENCY / 1000000UL)) + 1UL)
/** @} */
/*===========================================================================*/
|