aboutsummaryrefslogtreecommitdiffstats
path: root/os/rt
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-10-15 14:59:55 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-10-15 14:59:55 +0000
commit50c33f3fdb216f6ca6bae3938c8c218dba92ab82 (patch)
treefd181407145d25d0c2936b795fa26847301e6447 /os/rt
parent0c49958d77e72945629fa31c5f4d5f5b6c638454 (diff)
downloadChibiOS-50c33f3fdb216f6ca6bae3938c8c218dba92ab82.tar.gz
ChibiOS-50c33f3fdb216f6ca6bae3938c8c218dba92ab82.tar.bz2
ChibiOS-50c33f3fdb216f6ca6bae3938c8c218dba92ab82.zip
Virtual timers new functionality added.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8363 35acf78f-673a-0410-8e92-d51de3d6d3f4
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().