aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'os/kernel')
-rw-r--r--os/kernel/include/chvt.h27
-rw-r--r--os/kernel/src/chvt.c20
2 files changed, 26 insertions, 21 deletions
diff --git a/os/kernel/include/chvt.h b/os/kernel/include/chvt.h
index c677689af..c1b246cd3 100644
--- a/os/kernel/include/chvt.h
+++ b/os/kernel/include/chvt.h
@@ -207,6 +207,32 @@ typedef struct {
* @api
*/
#define chTimeNow() (vtlist.vt_systime)
+
+/**
+ * @brief Returns the elapsed time since the specified start time.
+ *
+ * @param[in] start start time
+ * @return The elapsed time.
+ *
+ * @api
+ */
+#define chTimeElapsedSince(start) (chTimeNow() - (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
+ * whole time range is specified.
+ *
+ * @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.
+ *
+ * @api
+ */
+#define chTimeIsWithin(start, end) \
+ (chTimeElapsedSince(start) < ((end) - (start)))
/** @} */
extern VTList vtlist;
@@ -220,7 +246,6 @@ extern "C" {
void _vt_init(void);
void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par);
void chVTResetI(VirtualTimer *vtp);
- bool_t chTimeIsWithin(systime_t start, systime_t end);
#ifdef __cplusplus
}
#endif
diff --git a/os/kernel/src/chvt.c b/os/kernel/src/chvt.c
index a8e3ce499..f2d6cd697 100644
--- a/os/kernel/src/chvt.c
+++ b/os/kernel/src/chvt.c
@@ -111,24 +111,4 @@ void chVTResetI(VirtualTimer *vtp) {
vtp->vt_func = (vtfunc_t)NULL;
}
-/**
- * @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
- * whole time range is specified.
- *
- * @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.
- *
- * @api
- */
-bool_t chTimeIsWithin(systime_t start, systime_t end) {
-
- systime_t time = chTimeNow();
- return end > start ? (time >= start) && (time < end) :
- (time >= start) || (time < end);
-}
-
/** @} */