From fa64f08fc1ad45d0984828695697f6abde7e8ffd Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 23 Jul 2013 13:51:02 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6024 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chvt.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'os/kernel') diff --git a/os/kernel/include/chvt.h b/os/kernel/include/chvt.h index 2c4b489d5..d1659d286 100644 --- a/os/kernel/include/chvt.h +++ b/os/kernel/include/chvt.h @@ -41,6 +41,14 @@ /* Derived constants and error checks. */ /*===========================================================================*/ +#if CH_CFG_FREQUENCY <= 0 +#error "invalid CH_CFG_FREQUENCY specified" +#endif + +#if (CH_CFG_TIMEDELTA < 0) || (CH_CFG_TIMEDELTA == 1) +#error "invalid NIL_CFG_TIMEDELTA specified" +#endif + /*===========================================================================*/ /* Module data structures and types. */ /*===========================================================================*/ @@ -387,6 +395,8 @@ static inline void chVTDoTickI(void) { systime_t delta = now - vtlist.vt_lasttime; while ((vtp = vtlist.vt_next)->vt_delta <= delta) { + delta -= vtp->vt_delta; + vtlist.vt_lasttime += vtp->vt_delta; vtfunc_t fn = vtp->vt_func; vtp->vt_func = (vtfunc_t)NULL; vtp->vt_next->vt_prev = (void *)&vtlist; @@ -401,10 +411,7 @@ static inline void chVTDoTickI(void) { port_timer_stop_alarm(); } else { - /* The delta is subtracted to the next list element, the current time - becomes the new delta list base time.*/ - vtp->vt_delta -= delta; - vtlist.vt_lasttime = now; + /* Updating the alarm to the next deadline.*/ port_timer_set_alarm(now + vtp->vt_delta); } #endif /* CH_CFG_TIMEDELTA > 0 */ -- cgit v1.2.3