diff options
Diffstat (limited to 'os/kernel/include')
-rw-r--r-- | os/kernel/include/ch.h | 2 | ||||
-rw-r--r-- | os/kernel/include/chstats.h | 5 | ||||
-rw-r--r-- | os/kernel/include/chsys.h | 89 | ||||
-rw-r--r-- | os/kernel/include/chtm.h | 92 |
4 files changed, 102 insertions, 86 deletions
diff --git a/os/kernel/include/ch.h b/os/kernel/include/ch.h index e30ddd515..d2a29ac0c 100644 --- a/os/kernel/include/ch.h +++ b/os/kernel/include/ch.h @@ -108,9 +108,9 @@ typedef struct thread thread_t; #include "chconf.h"
#include "chtypes.h"
#include "chdebug.h"
+#include "chcore.h"
#include "chtm.h"
#include "chstats.h"
-#include "chcore.h"
#include "chsys.h"
#include "chvt.h"
#include "chthreads.h"
diff --git a/os/kernel/include/chstats.h b/os/kernel/include/chstats.h index a94a84814..dee5c9bec 100644 --- a/os/kernel/include/chstats.h +++ b/os/kernel/include/chstats.h @@ -39,6 +39,10 @@ /* Module pre-compile time settings. */
/*===========================================================================*/
+#if !CH_CFG_USE_TM
+#error "CH_DBG_STATISTICS requires CH_CFG_USE_TM"
+#endif
+
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
@@ -84,6 +88,7 @@ extern kernel_stats_t kernel_stats; #ifdef __cplusplus
extern "C" {
#endif
+ void _stats_init(void);
#ifdef __cplusplus
}
#endif
diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h index 3dc6623e9..0fd07b96b 100644 --- a/os/kernel/include/chsys.h +++ b/os/kernel/include/chsys.h @@ -101,20 +101,99 @@ /** @} */
/**
+ * @name Time conversion utilities for the realtime counter
+ * @{
+ */
+/**
+ * @brief Seconds to realtime counter.
+ * @details Converts from seconds to realtime counter cycles.
+ * @note The result is rounded upward to the next tick boundary.
+ *
+ * @param[in] freq realtime counter operating frequency
+ * @param[in] sec number of seconds
+ * @return The number of cycles.
+ *
+ * @api
+ */
+#define S2RTV(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.
+ *
+ * @param[in] freq realtime counter operating frequency
+ * @param[in] msec number of milliseconds
+ * @return The number of cycles.
+ *
+ * @api
+ */
+#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.
+ *
+ * @param[in] freq realtime counter operating frequency
+ * @param[in] usec number of microseconds
+ * @return The number of cycles.
+ *
+ * @api
+ */
+#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.
+ *
+ * @param[in] freq realtime counter operating frequency
+ * @param[in] n number of cycles
+ * @return The number of seconds.
+ *
+ * @api
+ */
+#define RTC2S(freq, n) (rtcnt_t)((n) / (freq))
+
+/**
+ * @brief Realtime counter cycles to milliseconds.
+ * @details Converts from realtime counter cycles number to milliseconds.
+ *
+ * @param[in] freq realtime counter operating frequency
+ * @param[in] n number of cycles
+ * @return The number of milliseconds.
+ *
+ * @api
+ */
+#define RTC2MS(freq, n) ((n) / ((freq) / 1000UL))
+
+/**
+ * @brief Realtime counter cycles to microseconds.
+ * @details Converts from realtime counter cycles number to microseconds.
+ *
+ * @param[in] freq realtime counter operating frequency
+ * @param[in] n number of cycles
+ * @return The number of microseconds.
+ *
+ * @api
+ */
+#define RTC2US(freq, n) ((n) / ((freq) / 1000000UL))
+/** @} */
+
+/**
* @brief Returns the current value of the system real time counter.
* @note This function can be called from any context.
- * @note If the port does not support a realtime counter then this
- * function returns the system time.
*
* @return The value of the system realtime counter of
- * type rtcnt_t.
+ * type rtcnt_t. If the port does not support a
+ * realtime counter then zero is returned.
*
- * @special
+ * @xclass
*/
#if CH_PORT_SUPPORTS_RT || defined(__DOXYGEN__)
#define chSysGetRealtimeCounterX() (rtcnt_t)port_rt_get_counter_value()
#else
-#define chSysGetRealtimeCounterX() (rtcnt_t)chVTGetSystemTimeX()
+#define chSysGetRealtimeCounterX() 0
#endif
/*===========================================================================*/
diff --git a/os/kernel/include/chtm.h b/os/kernel/include/chtm.h index a7500a26b..bd1d73dd9 100644 --- a/os/kernel/include/chtm.h +++ b/os/kernel/include/chtm.h @@ -45,6 +45,10 @@ /* Derived constants and error checks. */
/*===========================================================================*/
+#if !CH_PORT_SUPPORTS_RT
+#error "CH_CFG_USE_TM requires CH_PORT_SUPPORTS_RT"
+#endif
+
/*===========================================================================*/
/* Module data structures and types. */
/*===========================================================================*/
@@ -69,80 +73,6 @@ typedef struct { /* Module macros. */
/*===========================================================================*/
-/**
- * @name Time conversion utilities for the realtime counter
- * @{
- */
-/**
- * @brief Seconds to realtime counter.
- * @details Converts from seconds to realtime counter cycles.
- * @note The result is rounded upward to the next tick boundary.
- *
- * @param[in] sec number of seconds
- * @return The number of cycles.
- *
- * @api
- */
-#define S2RTV(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.
- *
- * @param[in] msec number of milliseconds
- * @return The number of cycles.
- *
- * @api
- */
-#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.
- *
- * @param[in] usec number of microseconds
- * @return The number of cycles.
- *
- * @api
- */
-#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.
- *
- * @param[in] n number of cycles
- * @return The number of seconds.
- *
- * @api
- */
-#define RTC2S(freq, n) (rtcnt_t)((n) / (freq))
-
-/**
- * @brief Realtime counter cycles to milliseconds.
- * @details Converts from realtime counter cycles number to milliseconds.
- *
- * @param[in] n number of cycles
- * @return The number of milliseconds.
- *
- * @api
- */
-#define RTC2MS(freq, n) ((n) / ((freq) / 1000UL))
-
-/**
- * @brief Realtime counter cycles to microseconds.
- * @details Converts from realtime counter cycles number to microseconds.
- *
- * @param[in] n number of cycles
- * @return The number of microseconds.
- *
- * @api
- */
-#define RTC2US(freq, n) ((n) / ((freq) / 1000000UL))
-/** @} */
-
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
@@ -150,12 +80,14 @@ typedef struct { #ifdef __cplusplus
extern "C" {
#endif
- void _rt_init(void);
- bool chRTIsCounterWithin(rtcnt_t start, rtcnt_t end);
- void chRTPolledDelay(rtcnt_t cycles);
- void chRTTimeMeasurementObjectInit(time_measurement_t *tmp);
- NOINLINE void chRTTimeMeasurementStartX(time_measurement_t *tmp);
- NOINLINE void chRTTimeMeasurementStopX(time_measurement_t *tmp);
+ void _tm_init(void);
+ bool chTMIsCounterWithinX(rtcnt_t cnt, rtcnt_t start, rtcnt_t end);
+ void chTMPolledDelayX(rtcnt_t cycles);
+ void chTMObjectInit(time_measurement_t *tmp);
+ NOINLINE void chTMStartX(time_measurement_t *tmp);
+ NOINLINE void chTMStopX(time_measurement_t *tmp);
+ NOINLINE void chTMChainToX(time_measurement_t *tmp1,
+ time_measurement_t *tmp2);
#ifdef __cplusplus
}
#endif
|