aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-12-01 10:29:36 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-12-01 10:29:36 +0000
commitc7da76627c4c5479ed91bd6709e17abc22691b84 (patch)
tree9c04a05b9cb2900de8428e08bea6e179436956c1 /os
parent5b59f89d98bc8d4ae1a7269ab1e09a6d8f649d2f (diff)
downloadChibiOS-c7da76627c4c5479ed91bd6709e17abc22691b84.tar.gz
ChibiOS-c7da76627c4c5479ed91bd6709e17abc22691b84.tar.bz2
ChibiOS-c7da76627c4c5479ed91bd6709e17abc22691b84.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7551 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/rt/include/chvt.h24
-rw-r--r--os/rt/src/chvt.c11
2 files changed, 27 insertions, 8 deletions
diff --git a/os/rt/include/chvt.h b/os/rt/include/chvt.h
index 9538474c9..1d7c8c545 100644
--- a/os/rt/include/chvt.h
+++ b/os/rt/include/chvt.h
@@ -464,11 +464,21 @@ static inline void chVTDoTickI(void) {
}
#else /* CH_CFG_ST_TIMEDELTA > 0 */
virtual_timer_t *vtp;
- systime_t now = chVTGetSystemTimeX();
- systime_t delta = now - ch.vtlist.vt_lasttime;
+ systime_t now;
- while ((vtp = ch.vtlist.vt_next)->vt_delta <= delta) {
+ while (true) {
vtfunc_t fn;
+ systime_t delta;
+
+ /* Getting the current system time and calculating the time window since
+ the last time has expired.*/
+ now = chVTGetSystemTimeX();
+ delta = now - ch.vtlist.vt_lasttime;
+
+ /* The next element is outside the current time window, the loop
+ is stopped here.*/
+ if ((vtp = ch.vtlist.vt_next)->vt_delta > delta)
+ break;
/* The "last time" becomes this timer's expiration time.*/
delta -= vtp->vt_delta;
@@ -491,8 +501,12 @@ static inline void chVTDoTickI(void) {
port_timer_stop_alarm();
}
else {
- /* Updating the alarm to the next deadline.*/
- port_timer_set_alarm(now + vtp->vt_delta);
+ /* Updating the alarm to the next deadline, deadline that must not be
+ closer in time than the minimum time delta.*/
+ if (vtp->vt_delta >= CH_CFG_ST_TIMEDELTA)
+ port_timer_set_alarm(now + vtp->vt_delta);
+ else
+ port_timer_set_alarm(now + CH_CFG_ST_TIMEDELTA);
}
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
}
diff --git a/os/rt/src/chvt.c b/os/rt/src/chvt.c
index 4fd154e57..de33e7b9c 100644
--- a/os/rt/src/chvt.c
+++ b/os/rt/src/chvt.c
@@ -180,9 +180,14 @@ void chVTDoResetI(virtual_timer_t *vtp) {
port_timer_stop_alarm();
}
else {
- /* The alarm is set to the next element in the delta list.*/
- port_timer_set_alarm(ch.vtlist.vt_lasttime +
- ch.vtlist.vt_next->vt_delta);
+ /* Updating the alarm to the next deadline, deadline that must not be
+ closer in time than the minimum time delta.*/
+ if (ch.vtlist.vt_next->vt_delta >= CH_CFG_ST_TIMEDELTA)
+ port_timer_set_alarm(ch.vtlist.vt_lasttime +
+ ch.vtlist.vt_next->vt_delta);
+ else
+ port_timer_set_alarm(ch.vtlist.vt_lasttime +
+ CH_CFG_ST_TIMEDELTA);
}
}
#endif /* CH_CFG_ST_TIMEDELTA > 0 */