aboutsummaryrefslogtreecommitdiffstats
path: root/os/rt
diff options
context:
space:
mode:
Diffstat (limited to 'os/rt')
-rw-r--r--os/rt/include/chvt.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/os/rt/include/chvt.h b/os/rt/include/chvt.h
index d44d0b91b..e124a14e3 100644
--- a/os/rt/include/chvt.h
+++ b/os/rt/include/chvt.h
@@ -325,6 +325,41 @@ static inline bool chVTIsSystemTimeWithin(systime_t start, systime_t end) {
}
/**
+ * @brief Returns the time interval until the next timer event.
+ * @note The return value is not perfectly accurate and can report values
+ * in excess of @p CH_CFG_ST_TIMEDELTA ticks.
+ * @note The interval returned by this function is only meaningful if
+ * more timers are not added to the list until the returned time.
+ *
+ * @param[out] timep pointer to a variable that will contain the time
+ * interval until the next timer elapses. This pointer
+ * can be @p NULL if the information is not required.
+ * @return The time, in ticks, until next time event.
+ * @retval false if the timers list is empty.
+ * @retbal true if the timers list contains at least one timer.
+ *
+ * @iclass
+ */
+static inline bool chVTGetTimersStateI(systime_t *timep) {
+
+ chDbgCheckClassI();
+
+ if (&ch.vtlist == (virtual_timers_list_t *)ch.vtlist.vt_next)
+ return false;
+
+ if (timep != NULL) {
+#if CH_CFG_ST_TIMEDELTA == 0
+ *timep = ch.vtlist.vt_next->vt_delta;
+#else
+ *timep = ch.vtlist.vt_lasttime + ch.vtlist.vt_next->vt_delta +
+ CH_CFG_ST_TIMEDELTA - chVTGetSystemTimeX();
+#endif
+ }
+
+ return true;
+}
+
+/**
* @brief Returns @p true if the specified timer is armed.
* @pre The timer must have been initialized using @p chVTObjectInit()
* or @p chVTDoSetI().