aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
Diffstat (limited to 'os')
-rw-r--r--os/hal/include/hal.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/os/hal/include/hal.h b/os/hal/include/hal.h
index ff0c489a7..170c2bc03 100644
--- a/os/hal/include/hal.h
+++ b/os/hal/include/hal.h
@@ -114,6 +114,39 @@
*/
#define US2RTT(usec) (((halGetCounterFrequency() + 999999UL) / 1000000UL) * \
(usec))
+
+/**
+ * @brief Realtime ticks to seconds to.
+ * @details Converts from realtime ticks number to seconds.
+ *
+ * @param[in] ticks number of ticks
+ * @return The number of seconds.
+ *
+ * @api
+ */
+#define RTT2S(ticks) ((ticks) / halGetCounterFrequency())
+
+/**
+ * @brief Realtime ticks to milliseconds.
+ * @details Converts from realtime ticks number to milliseconds.
+ *
+ * @param[in] ticks number of ticks
+ * @return The number of milliseconds.
+ *
+ * @api
+ */
+#define RTT2MS(ticks) ((ticks) / (halGetCounterFrequency() / 1000UL))
+
+/**
+ * @brief Realtime ticks to microseconds.
+ * @details Converts from realtime ticks number to microseconds.
+ *
+ * @param[in] ticks number of ticks
+ * @return The number of microseconds.
+ *
+ * @api
+ */
+#define RTT2US(ticks) ((ticks) / (halGetCounterFrequency() / 1000000UL))
/** @} */
/**