aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'os/kernel')
-rw-r--r--os/kernel/include/chtm.h3
-rw-r--r--os/kernel/src/chtm.c6
2 files changed, 6 insertions, 3 deletions
diff --git a/os/kernel/include/chtm.h b/os/kernel/include/chtm.h
index b72bff8e6..93e24d48c 100644
--- a/os/kernel/include/chtm.h
+++ b/os/kernel/include/chtm.h
@@ -63,8 +63,9 @@
typedef struct {
rtcnt_t best; /**< @brief Best measurement. */
rtcnt_t worst; /**< @brief Worst measurement. */
- rtcnt_t cumulative; /**< @brief Cumulative measurement. */
rtcnt_t last; /**< @brief Last measurement. */
+ ucnt_t n; /**< @brief Number of measurements. */
+ rttime_t cumulative; /**< @brief Cumulative measurement. */
} time_measurement_t;
/*===========================================================================*/
diff --git a/os/kernel/src/chtm.c b/os/kernel/src/chtm.c
index 2bec0cc1c..e54bacbbf 100644
--- a/os/kernel/src/chtm.c
+++ b/os/kernel/src/chtm.c
@@ -60,8 +60,9 @@ static inline void tm_stop(time_measurement_t *tmp,
rtcnt_t now,
rtcnt_t offset) {
+ tmp->n++;
tmp->last = now - tmp->last - offset;
- tmp->cumulative += tmp->last;
+ tmp->cumulative += (rttime_t)tmp->last;
if (tmp->last > tmp->worst)
tmp->worst = tmp->last;
else if (tmp->last < tmp->best)
@@ -101,8 +102,9 @@ void chTMObjectInit(time_measurement_t *tmp) {
tmp->best = (rtcnt_t)-1;
tmp->worst = (rtcnt_t)0;
- tmp->cumulative = (rtcnt_t)0;
tmp->last = (rtcnt_t)0;
+ tmp->n = (ucnt_t)0;
+ tmp->cumulative = (rttime_t)0;
}
/**