From da4f9beaee8f1f8f344012b4d9a122462a6c802e Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 10 Mar 2009 15:31:58 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@827 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/chsys.c | 8 ++++++-- src/chthreads.c | 2 +- src/chvt.c | 10 +++++----- src/include/sys.h | 4 ++++ src/include/vt.h | 16 ++++++++++++++-- 5 files changed, 30 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/chsys.c b/src/chsys.c index 20c1e17fb..666d0cfef 100644 --- a/src/chsys.c +++ b/src/chsys.c @@ -110,14 +110,18 @@ void chSysTimerHandlerI(void) { #if CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED void chSysLock(void) { - chDbgAssert(currp->p_locks >= 0, "chinit.c, chSysLock()"); + chDbgAssert(currp->p_locks >= 0, + "chSysLock(), #1", + "negative nesting counter"); if (currp->p_locks++ == 0) port_lock(); } void chSysUnlock(void) { - chDbgAssert(currp->p_locks > 0, "chinit.c, chSysUnlock()"); + chDbgAssert(currp->p_locks > 0, + "chSysUnlock(), #1", + "non-positive nesting counter"); if (--currp->p_locks == 0) port_unlock(); } diff --git a/src/chthreads.c b/src/chthreads.c index a22514f09..70db14130 100644 --- a/src/chthreads.c +++ b/src/chthreads.c @@ -290,7 +290,7 @@ void chThdSleep(systime_t time) { void chThdSleepUntil(systime_t time) { chSysLock(); - if ((time -= chSysGetTime()) > 0) + if ((time -= chTimeNow()) > 0) chThdSleepS(time); chSysUnlock(); } diff --git a/src/chvt.c b/src/chvt.c index 76ab6a7f3..9d4fec138 100644 --- a/src/chvt.c +++ b/src/chvt.c @@ -19,7 +19,7 @@ /** * @file chvt.c - * @brief Time related code. + * @brief Time and Virtual Timers related code. * @addtogroup Time * @{ */ @@ -58,8 +58,8 @@ void vt_init(void) { void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par) { VirtualTimer *p; - chDbgCheck((vtp != NULL) && (vtfunc != NULL) && - (time != TIME_IMMEDIATE) && (time != TIME_INFINITE), "chVTSetI"); + chDbgCheck((vtp != NULL) && (vtfunc != NULL) && (time != TIME_INFINITE), + "chVTSetI"); vtp->vt_par = par; vtp->vt_func = vtfunc; @@ -103,9 +103,9 @@ void chVTResetI(VirtualTimer *vtp) { * @retval TRUE current time within the specified time window. * @retval FALSE current time not within the specified time window. */ -bool_t chSysInTimeWindow(systime_t start, systime_t end) { +bool_t chTimeIsWithin(systime_t start, systime_t end) { - systime_t time = chSysGetTime(); + systime_t time = chTimeNow(); return end >= start ? (time >= start) && (time < end) : (time >= start) || (time < end); } diff --git a/src/include/sys.h b/src/include/sys.h index 90fbfd1a1..a84d33da8 100644 --- a/src/include/sys.h +++ b/src/include/sys.h @@ -171,6 +171,10 @@ extern "C" { #endif void chSysInit(void); void chSysTimerHandlerI(void); +#if CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED + void chSysLock(void); + void chSysUnlock(void); +#endif /* CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED */ #ifdef __cplusplus } #endif diff --git a/src/include/vt.h b/src/include/vt.h index e104bb101..e736e1af0 100644 --- a/src/include/vt.h +++ b/src/include/vt.h @@ -104,7 +104,7 @@ extern "C" { void vt_init(void); void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par); void chVTResetI(VirtualTimer *vtp); - bool_t chSysInTimeWindow(systime_t start, systime_t end); + bool_t chTimeIsWithin(systime_t start, systime_t end); #ifdef __cplusplus } #endif @@ -118,8 +118,20 @@ extern "C" { * @note The counter can reach its maximum and then returns to zero. * @note This function is designed to work with the @p chThdSleepUntil(). */ -#define chSysGetTime() (vtlist.vt_systime) +#define chTimeNow() (vtlist.vt_systime) +/** + * Provided for backward compatibility. + * @deprecated Will be removed in 1.2.0. + */ +#define chSysGetTime() chTimeNow() + +/** + * Provided for backward compatibility. + * @deprecated Will be removed in 1.2.0. + */ +#define chSysInTimeWindow(start, end) chTimeIsWithin(start, end) + #endif /* _VT_H_ */ /** @} */ -- cgit v1.2.3