From 226d140bb9a39f17f4f5da6217b4d43017095682 Mon Sep 17 00:00:00 2001 From: barthess Date: Mon, 23 Apr 2012 18:33:18 +0000 Subject: Added converters from realtime ticks to time values. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4130 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/hal.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'os/hal/include') 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)) /** @} */ /** -- cgit v1.2.3