aboutsummaryrefslogtreecommitdiffstats
path: root/os/rt/include/chsys.h
diff options
context:
space:
mode:
Diffstat (limited to 'os/rt/include/chsys.h')
-rw-r--r--os/rt/include/chsys.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/os/rt/include/chsys.h b/os/rt/include/chsys.h
index 9a74788ae..1b80bba65 100644
--- a/os/rt/include/chsys.h
+++ b/os/rt/include/chsys.h
@@ -145,35 +145,38 @@
/**
* @brief Realtime counter cycles to seconds.
* @details Converts from realtime counter cycles number to seconds.
+ * @note The result is rounded up to the next second boundary.
*
* @param[in] n number of cycles
* @return The number of seconds.
*
* @api
*/
-#define RTC2S(n) (rtcnt_t)(CH_CFG_RTC_FREQUENCY / (freq))
+#define RTC2S(n) ((((n) - 1UL) / CH_CFG_RTC_FREQUENCY) + 1UL)
/**
* @brief Realtime counter cycles to milliseconds.
* @details Converts from realtime counter cycles number to milliseconds.
+ * @note The result is rounded up to the next millisecond boundary.
*
* @param[in] n number of cycles
* @return The number of milliseconds.
*
* @api
*/
-#define RTC2MS(n) ((n) / (CH_CFG_RTC_FREQUENCY / 1000UL))
+#define RTC2MS(n) ((((n) - 1UL) / (CH_CFG_RTC_FREQUENCY / 1000UL)) + 1UL)
/**
* @brief Realtime counter cycles to microseconds.
* @details Converts from realtime counter cycles number to microseconds.
+ * @note The result is rounded up to the next microsecond boundary.
*
* @param[in] n number of cycles
* @return The number of microseconds.
*
* @api
*/
-#define RTC2US(n) ((n) / (CH_CFG_RTC_FREQUENCY / 1000000UL))
+#define RTC2US(n) ((((n) - 1UL) / (CH_CFG_RTC_FREQUENCY / 1000000UL)) + 1UL)
/** @} */
/**