From 300ecfe103d1d305e78a15196d2fa1aecfddc729 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 26 Jun 2008 10:54:55 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@323 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/chsleep.c | 14 ++++++++++++++ src/include/sleep.h | 3 +++ 2 files changed, 17 insertions(+) (limited to 'src') 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 -- cgit v1.2.3