aboutsummaryrefslogtreecommitdiffstats
path: root/os/rt/include
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-11-04 13:35:10 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-11-04 13:35:10 +0000
commit202661e81e18dad821a1855caf39add96440f6cf (patch)
tree2dab0a7863bdc1d504b730db2c936a6d57872763 /os/rt/include
parent3d2ebf13f5b01f802fae0afec8651cde4c121be8 (diff)
downloadChibiOS-202661e81e18dad821a1855caf39add96440f6cf.tar.gz
ChibiOS-202661e81e18dad821a1855caf39add96440f6cf.tar.bz2
ChibiOS-202661e81e18dad821a1855caf39add96440f6cf.zip
Improved time range functions. Reduced size for NIL when tickless mode is used.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6416 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/rt/include')
-rw-r--r--os/rt/include/chvt.h35
1 files changed, 34 insertions, 1 deletions
diff --git a/os/rt/include/chvt.h b/os/rt/include/chvt.h
index fa859e8fe..66eda87f3 100644
--- a/os/rt/include/chvt.h
+++ b/os/rt/include/chvt.h
@@ -152,7 +152,6 @@ struct virtual_timer {
extern "C" {
#endif
void _vt_init(void);
- bool chVTIsTimeWithinX(systime_t time, systime_t start, systime_t end);
void chVTDoSetI(virtual_timer_t *vtp, systime_t delay,
vtfunc_t vtfunc, void *par);
void chVTDoResetI(virtual_timer_t *vtp);
@@ -222,6 +221,40 @@ static inline systime_t chVTGetSystemTime(void) {
}
/**
+ * @brief Returns the elapsed time since the specified start time.
+ *
+ * @param[in] start start time
+ * @return The elapsed time.
+ *
+ * @xclass
+ */
+static inline systime_t chVTTimeElapsedSinceX(systime_t start) {
+
+ return chVTGetSystemTimeX() - start;
+}
+
+/**
+ * @brief Checks if the specified time is within the specified time window.
+ * @note When start==end then the function returns always true because the
+ * whole time range is specified.
+ * @note This function can be called from any context.
+ *
+ * @param[in] time the time to be verified
+ * @param[in] start the start of the time window (inclusive)
+ * @param[in] end the end of the time window (non inclusive)
+ * @retval true current time within the specified time window.
+ * @retval false current time not within the specified time window.
+ *
+ * @xclass
+ */
+static inline bool chVTIsTimeWithinX(systime_t time,
+ systime_t start,
+ systime_t end) {
+
+ return (bool)(time - start < end - start);
+}
+
+/**
* @brief Checks if the current system time is within the specified time
* window.
* @note When start==end then the function returns always true because the