aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-10-13 08:52:00 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-10-13 08:52:00 +0000
commit72d563b45f02270fc18bfa61c0c0e7f94325e091 (patch)
tree991f703d7fd56d5aa76c3afcffd29562e00262ce /os
parent750a8f14b696e51b8522cddcf0265775b610dfa1 (diff)
downloadChibiOS-72d563b45f02270fc18bfa61c0c0e7f94325e091.tar.gz
ChibiOS-72d563b45f02270fc18bfa61c0c0e7f94325e091.tar.bz2
ChibiOS-72d563b45f02270fc18bfa61c0c0e7f94325e091.zip
Experimental code.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/rt5_dev_point1@10816 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/rt/include/chvt.h27
-rw-r--r--os/rt/src/chvt.c7
2 files changed, 23 insertions, 11 deletions
diff --git a/os/rt/include/chvt.h b/os/rt/include/chvt.h
index 3dc67f2a3..ea4493df3 100644
--- a/os/rt/include/chvt.h
+++ b/os/rt/include/chvt.h
@@ -395,19 +395,26 @@ static inline void chVTDoTickI(void) {
systime_t now;
sysinterval_t delta;
- /* First timer to be processed.*/
+ /* Looping through timers.*/
vtp = ch.vtlist.next;
- now = chVTGetSystemTimeX();
-
- /* All timers within the time window are triggered and removed,
- note that the loop is stopped by the timers header having
- "ch.vtlist.vt_delta == (sysinterval_t)-1" which is greater than
- all deltas.*/
- while (vtp->delta <= chTimeDiffX(ch.vtlist.lasttime, now)) {
+ while (true) {
vtfunc_t fn;
+ /* The loop is stopped by the timers header having
+ "ch.vtlist.vt_delta == (sysinterval_t)-1" which
+ is greater than all deltas.*/
+ now = chVTGetSystemTimeX();
+ if (vtp->delta > chTimeDiffX(ch.vtlist.lasttime, now)) {
+ 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
vtp->next->prev = (virtual_timer_t *)&ch.vtlist;
ch.vtlist.next = vtp->next;
@@ -431,10 +438,8 @@ static inline void chVTDoTickI(void) {
of the list.*/
chSysLockFromISR();
- /* Next element in the list, the current time could have advanced so
- recalculating the time window.*/
+ /* Next element in the list.*/
vtp = ch.vtlist.next;
- now = chVTGetSystemTimeX();
}
/* if the list is empty, nothing else to do.*/
diff --git a/os/rt/src/chvt.c b/os/rt/src/chvt.c
index 1c5b2fea2..0667bf7c3 100644
--- a/os/rt/src/chvt.c
+++ b/os/rt/src/chvt.c
@@ -125,6 +125,13 @@ void chVTDoSetI(virtual_timer_t *vtp, sysinterval_t delay,
vtp->prev = (virtual_timer_t *)&ch.vtlist;
vtp->delta = delay;
+#if CH_CFG_INTERVALS_SIZE > CH_CFG_ST_RESOLUTION
+ /* The delta could be too large for the physical timer to handle.*/
+ if (delay > (sysinterval_t)TIME_MAX_SYSTIME) {
+ delay = (sysinterval_t)TIME_MAX_SYSTIME;
+ }
+#endif
+
/* Being the first element in the list the alarm timer is started.*/
port_timer_start_alarm(chTimeAddX(ch.vtlist.lasttime, delay));