From 07297f0c1604422d427a417a60653abe60e1ca77 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 20 Jan 2014 09:38:35 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6632 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/rt/include/chsys.h | 31 ++++++++++++++++++++----------- os/rt/templates/chconf.h | 7 ------- 2 files changed, 20 insertions(+), 18 deletions(-) (limited to 'os') diff --git a/os/rt/include/chsys.h b/os/rt/include/chsys.h index 1b80bba65..6c2d61684 100644 --- a/os/rt/include/chsys.h +++ b/os/rt/include/chsys.h @@ -107,76 +107,85 @@ /** * @brief Seconds to realtime counter. * @details Converts from seconds to realtime counter cycles. - * @note The result is rounded upward to the next tick boundary. + * @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 S2RTC(sec) (CH_CFG_RTC_FREQUENCY * (sec)) +#define 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 tick boundary. + * @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 MS2RTC(msec) (rtcnt_t)(((CH_CFG_RTC_FREQUENCY + 999UL) / \ - 1000UL) * (msec)) +#define 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 tick boundary. + * @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 US2RTC(usec) (rtcnt_t)(((CH_CFG_RTC_FREQUENCY + 999999UL) / \ - 1000000UL) * (usec)) +#define US2RTC(freq, usec) (rtcnt_t)((((freq) + 999999UL) / 1000000UL) * (usec)) /** * @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. + * @note The macro assumes that @p freq >= @p 1. * + * @param[in] freq clock frequency, in Hz, of the realtime counter * @param[in] n number of cycles * @return The number of seconds. * * @api */ -#define RTC2S(n) ((((n) - 1UL) / CH_CFG_RTC_FREQUENCY) + 1UL) +#define RTC2S(freq, n) ((((n) - 1UL) / (freq)) + 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. + * @note The macro assumes that @p freq >= @p 1000. * + * @param[in] freq clock frequency, in Hz, of the realtime counter * @param[in] n number of cycles * @return The number of milliseconds. * * @api */ -#define RTC2MS(n) ((((n) - 1UL) / (CH_CFG_RTC_FREQUENCY / 1000UL)) + 1UL) +#define RTC2MS(freq, n) ((((n) - 1UL) / ((freq) / 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. + * @note The macro assumes that @p freq >= @p 1000000. * + * @param[in] freq clock frequency, in Hz, of the realtime counter * @param[in] n number of cycles * @return The number of microseconds. * * @api */ -#define RTC2US(n) ((((n) - 1UL) / (CH_CFG_RTC_FREQUENCY / 1000000UL)) + 1UL) +#define RTC2US(freq, n) ((((n) - 1UL) / ((freq) / 1000000UL)) + 1UL) /** @} */ /** diff --git a/os/rt/templates/chconf.h b/os/rt/templates/chconf.h index 12f5742ec..8a2d5efa1 100644 --- a/os/rt/templates/chconf.h +++ b/os/rt/templates/chconf.h @@ -58,13 +58,6 @@ */ #define CH_CFG_ST_TIMEDELTA 2 -/** - * @brief Realtime Counter frequency. - * @details Frequency of the system counter used for realtime delays and - * measurements. - */ -#define CH_CFG_RTC_FREQUENCY 72000000 - /** @} */ /*===========================================================================*/ -- cgit v1.2.3