aboutsummaryrefslogtreecommitdiffstats
path: root/os/rt/include
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-10-13 09:25:38 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-10-13 09:25:38 +0000
commit882e9afb959e5ecc8800a79bb3cf3dabf1a7ccc6 (patch)
tree24a6566d5e55e130b71b387ed41597bc4ff2a1fa /os/rt/include
parent72d563b45f02270fc18bfa61c0c0e7f94325e091 (diff)
downloadChibiOS-882e9afb959e5ecc8800a79bb3cf3dabf1a7ccc6.tar.gz
ChibiOS-882e9afb959e5ecc8800a79bb3cf3dabf1a7ccc6.tar.bz2
ChibiOS-882e9afb959e5ecc8800a79bb3cf3dabf1a7ccc6.zip
Now it is APPARENTLY working for intervals larger than system time.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/rt5_dev_point1@10817 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/rt/include')
-rw-r--r--os/rt/include/chvt.h62
1 files changed, 31 insertions, 31 deletions
diff --git a/os/rt/include/chvt.h b/os/rt/include/chvt.h
index ea4493df3..b3a803c1a 100644
--- a/os/rt/include/chvt.h
+++ b/os/rt/include/chvt.h
@@ -398,48 +398,48 @@ static inline void chVTDoTickI(void) {
/* Looping through timers.*/
vtp = ch.vtlist.next;
while (true) {
- vtfunc_t fn;
+ sysinterval_t nowdelta;
- /* The loop is stopped by the timers header having
- "ch.vtlist.vt_delta == (sysinterval_t)-1" which
- is greater than all deltas.*/
+ /* Getting the system time as reference.*/
now = chVTGetSystemTimeX();
- if (vtp->delta > chTimeDiffX(ch.vtlist.lasttime, now)) {
+ nowdelta = chTimeDiffX(ch.vtlist.lasttime, now);
+
+ /* The list scan is limited by the timers header having
+ "ch.vtlist.vt_delta == (sysinterval_t)-1" which is
+ greater than all deltas.*/
+ if (vtp->delta > nowdelta) {
break;
}
-#if 0
- /* The "last time" becomes this timer's expiration time.*/
- ch.vtlist.lasttime = chTimeAddX(ch.vtlist.lasttime, vtp->delta);
-#else
- /* The "last time" is set to the current time.*/
- ch.vtlist.lasttime = now;
-#endif
+ /* Consuming all timers between "vtp->lasttime" and now.*/
+ do {
+ vtfunc_t fn;
- vtp->next->prev = (virtual_timer_t *)&ch.vtlist;
- ch.vtlist.next = vtp->next;
- fn = vtp->func;
- vtp->func = NULL;
+ /* Recalculated delta.*/
+ nowdelta = nowdelta - vtp->delta;
- /* if the list becomes empty then the timer is stopped.*/
- if (ch.vtlist.next == (virtual_timer_t *)&ch.vtlist) {
- port_timer_stop_alarm();
- }
+ vtp->next->prev = (virtual_timer_t *)&ch.vtlist;
+ ch.vtlist.next = vtp->next;
+ fn = vtp->func;
+ vtp->func = NULL;
- /* Leaving the system critical zone in order to execute the callback
- and in order to give a preemption chance to higher priority
- interrupts.*/
- chSysUnlockFromISR();
+ /* if the list becomes empty then the timer is stopped.*/
+ if (ch.vtlist.next == (virtual_timer_t *)&ch.vtlist) {
+ port_timer_stop_alarm();
+ }
- /* The callback is invoked outside the kernel critical zone.*/
- fn(vtp->par);
+ /* The callback is invoked outside the kernel critical zone.*/
+ chSysUnlockFromISR();
+ fn(vtp->par);
+ chSysLockFromISR();
- /* Re-entering the critical zone in order to continue the exploration
- of the list.*/
- chSysLockFromISR();
+ /* Next element in the list.*/
+ vtp = ch.vtlist.next;
+ }
+ while (vtp->delta <= nowdelta);
- /* Next element in the list.*/
- vtp = ch.vtlist.next;
+ /* The "last time" is set to the current time.*/
+ ch.vtlist.lasttime = now;
}
/* if the list is empty, nothing else to do.*/