aboutsummaryrefslogtreecommitdiffstats
path: root/os/rt
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-01-20 09:38:35 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-01-20 09:38:35 +0000
commit07297f0c1604422d427a417a60653abe60e1ca77 (patch)
tree7696572afd66b9c95c1e97d168e2a737f0b587b6 /os/rt
parent83ad77612c9ebc3df58aa85236350226da88cf31 (diff)
downloadChibiOS-07297f0c1604422d427a417a60653abe60e1ca77.tar.gz
ChibiOS-07297f0c1604422d427a417a60653abe60e1ca77.tar.bz2
ChibiOS-07297f0c1604422d427a417a60653abe60e1ca77.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6632 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/rt')
-rw-r--r--os/rt/include/chsys.h31
-rw-r--r--os/rt/templates/chconf.h7
2 files changed, 20 insertions, 18 deletions
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
-
/** @} */
/*===========================================================================*/