diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2015-08-15 08:56:56 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2015-08-15 08:56:56 +0000 |
commit | f52c062a19563a76960eef4b535327909b6059b9 (patch) | |
tree | 21622538288084b91864194ca5cd9a78288c3c8f /os/hal/templates | |
parent | a2b33f23233a009759e3fad20b031b7cb9f92278 (diff) | |
download | ChibiOS-f52c062a19563a76960eef4b535327909b6059b9.tar.gz ChibiOS-f52c062a19563a76960eef4b535327909b6059b9.tar.bz2 ChibiOS-f52c062a19563a76960eef4b535327909b6059b9.zip |
Fixed bug #629.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8214 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/templates')
-rw-r--r-- | os/hal/templates/osal/osal.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/os/hal/templates/osal/osal.h b/os/hal/templates/osal/osal.h index f73070aa4..f0ead5c0b 100644 --- a/os/hal/templates/osal/osal.h +++ b/os/hal/templates/osal/osal.h @@ -363,6 +363,52 @@ typedef struct { /** @} */
/**
+ * @name Time conversion utilities for the realtime counter
+ * @{
+ */
+/**
+ * @brief Seconds to realtime counter.
+ * @details Converts from seconds to realtime counter cycles.
+ * @note The macro assumes that @p freq >= @p 1.
+ *
+ * @param[in] freq clock frequency, in Hz, of the realtime counter
+ * @param[in] sec number of seconds
+ * @return The number of cycles.
+ *
+ * @api
+ */
+#define OSAL_S2RTC(freq, sec) ((freq) * (sec))
+
+/**
+ * @brief Milliseconds to realtime counter.
+ * @details Converts from milliseconds to realtime counter cycles.
+ * @note The result is rounded upward to the next millisecond boundary.
+ * @note The macro assumes that @p freq >= @p 1000.
+ *
+ * @param[in] freq clock frequency, in Hz, of the realtime counter
+ * @param[in] msec number of milliseconds
+ * @return The number of cycles.
+ *
+ * @api
+ */
+#define OSAL_MS2RTC(freq, msec) (rtcnt_t)((((freq) + 999UL) / 1000UL) * (msec))
+
+/**
+ * @brief Microseconds to realtime counter.
+ * @details Converts from microseconds to realtime counter cycles.
+ * @note The result is rounded upward to the next microsecond boundary.
+ * @note The macro assumes that @p freq >= @p 1000000.
+ *
+ * @param[in] freq clock frequency, in Hz, of the realtime counter
+ * @param[in] usec number of microseconds
+ * @return The number of cycles.
+ *
+ * @api
+ */
+#define OSAL_US2RTC(freq, usec) (rtcnt_t)((((freq) + 999999UL) / 1000000UL) * (usec))
+/** @} */
+
+/**
* @name Sleep macros using absolute time
* @{
*/
|