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
This commit is contained in:
Giovanni Di Sirio 2017-10-13 09:25:38 +00:00
parent 72d563b45f
commit 882e9afb95
2 changed files with 36 additions and 36 deletions

View File

@ -42,7 +42,7 @@
* @brief System time counter resolution.
* @note Allowed values are 16 or 32 bits.
*/
#define CH_CFG_ST_RESOLUTION 32
#define CH_CFG_ST_RESOLUTION 16
/**
* @brief System tick frequency.

View File

@ -398,23 +398,25 @@ 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;
/* Recalculated delta.*/
nowdelta = nowdelta - vtp->delta;
vtp->next->prev = (virtual_timer_t *)&ch.vtlist;
ch.vtlist.next = vtp->next;
@ -426,21 +428,19 @@ static inline void chVTDoTickI(void) {
port_timer_stop_alarm();
}
/* Leaving the system critical zone in order to execute the callback
and in order to give a preemption chance to higher priority
interrupts.*/
chSysUnlockFromISR();
/* The callback is invoked outside the kernel critical zone.*/
chSysUnlockFromISR();
fn(vtp->par);
/* 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);
/* The "last time" is set to the current time.*/
ch.vtlist.lasttime = now;
}
/* if the list is empty, nothing else to do.*/
if (ch.vtlist.next == (virtual_timer_t *)&ch.vtlist) {