diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-06-26 10:54:55 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-06-26 10:54:55 +0000 |
commit | 300ecfe103d1d305e78a15196d2fa1aecfddc729 (patch) | |
tree | d4b2f54280a9fc8f6e7487f65687ad90e8ebb0e5 /src | |
parent | a108008263c8c8fe80921e549346b78462b76036 (diff) | |
download | ChibiOS-300ecfe103d1d305e78a15196d2fa1aecfddc729.tar.gz ChibiOS-300ecfe103d1d305e78a15196d2fa1aecfddc729.tar.bz2 ChibiOS-300ecfe103d1d305e78a15196d2fa1aecfddc729.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@323 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src')
-rw-r--r-- | src/chsleep.c | 14 | ||||
-rw-r--r-- | src/include/sleep.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/chsleep.c b/src/chsleep.c index 859333b79..7f9f161f1 100644 --- a/src/chsleep.c +++ b/src/chsleep.c @@ -39,4 +39,18 @@ void chThdSleep(systime_t time) { }
#endif /* CH_USE_SLEEP */
+#ifdef CH_USE_SYSTEMTIME
+/**
+ * Checks if the current system time is within the specified time window.
+ * @param start the start of the time window (inclusive)
+ * @param end the end of the time window (non inclusive)
+ */
+bool_t chSysInTimeWindow(systime_t start, systime_t end) {
+
+ systime_t time = chSysGetTime();
+ return end >= start ? (time >= start) && (time < end) :
+ (time >= start) || (time < end);
+}
+#endif /* CH_USE_SYSTEMTIME */
+
/** @} */
diff --git a/src/include/sleep.h b/src/include/sleep.h index 51c4ac5d0..c718bb4ba 100644 --- a/src/include/sleep.h +++ b/src/include/sleep.h @@ -31,6 +31,9 @@ extern "C" { #ifdef CH_USE_SLEEP
void chThdSleep(systime_t time);
#endif /* CH_USE_SLEEP */
+#ifdef CH_USE_SYSTEMTIME
+bool_t chSysInTimeWindow(systime_t start, systime_t end);
+#endif /* CH_USE_SYSTEMTIME */
#ifdef __cplusplus
}
#endif
|