mirror of https://github.com/rusefi/ChibiOS.git
Fix for the 1st timer bug.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14438 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
3085bb40ca
commit
ca2fde8996
|
@ -409,7 +409,7 @@ void chVTDoTickI(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else /* CH_CFG_ST_TIMEDELTA > 0 */
|
#else /* CH_CFG_ST_TIMEDELTA > 0 */
|
||||||
ch_delta_list_t *dlp;
|
virtual_timer_t *vtp;
|
||||||
sysinterval_t delta, nowdelta;
|
sysinterval_t delta, nowdelta;
|
||||||
systime_t now;
|
systime_t now;
|
||||||
|
|
||||||
|
@ -418,25 +418,31 @@ void chVTDoTickI(void) {
|
||||||
nowdelta = chTimeDiffX(vtlp->lasttime, now);
|
nowdelta = chTimeDiffX(vtlp->lasttime, now);
|
||||||
|
|
||||||
/* Looping through timers consuming all timers with deltas lower or equal
|
/* Looping through timers consuming all timers with deltas lower or equal
|
||||||
than the interval between "now" and "lasttime".
|
than the interval between "now" and "lasttime".*/
|
||||||
Note that the list scan is limited by the delta list header having
|
while (true) {
|
||||||
"vtlp->dlist.delta == (sysinterval_t)-1" which is greater than all
|
|
||||||
deltas.*/
|
|
||||||
dlp = vtlp->dlist.next;
|
|
||||||
while (nowdelta >= dlp->delta) {
|
|
||||||
virtual_timer_t *vtp = (virtual_timer_t *)dlp;
|
|
||||||
systime_t lasttime;
|
systime_t lasttime;
|
||||||
|
|
||||||
|
/* First timer in the delta list.*/
|
||||||
|
vtp = (virtual_timer_t *)vtlp->dlist.next;
|
||||||
|
|
||||||
|
/* Loop break condition.
|
||||||
|
Note that the list scan is limited by the delta list header having
|
||||||
|
"vtlp->dlist.delta == (sysinterval_t)-1" which is greater than all
|
||||||
|
deltas*/
|
||||||
|
if (nowdelta < vtp->dlist.delta) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Last time deadline is updated to the next timer's time.*/
|
/* Last time deadline is updated to the next timer's time.*/
|
||||||
lasttime = chTimeAddX(vtlp->lasttime, dlp->delta);
|
lasttime = chTimeAddX(vtlp->lasttime, vtp->dlist.delta);
|
||||||
vtlp->lasttime = lasttime;
|
vtlp->lasttime = lasttime;
|
||||||
|
|
||||||
// TODO, remove this assert, it is triggered also by some valid cases.
|
// TODO, remove this assert, it is triggered also by some valid cases.
|
||||||
chDbgAssert((int)chTimeDiffX(vtlp->lasttime, now) >= 0, "back in time");
|
chDbgAssert((int)chTimeDiffX(vtlp->lasttime, now) >= 0, "back in time");
|
||||||
|
|
||||||
/* Removing the timer from the list, marking it as not armed.*/
|
/* Removing the timer from the list, marking it as not armed.*/
|
||||||
(void) ch_dlist_dequeue(dlp);
|
(void) ch_dlist_dequeue(&vtp->dlist);
|
||||||
dlp->next = NULL;
|
vtp->dlist.next = NULL;
|
||||||
|
|
||||||
/* If the list becomes empty then the alarm is disabled.*/
|
/* If the list becomes empty then the alarm is disabled.*/
|
||||||
if (ch_dlist_isempty(&vtlp->dlist)) {
|
if (ch_dlist_isempty(&vtlp->dlist)) {
|
||||||
|
@ -481,9 +487,6 @@ void chVTDoTickI(void) {
|
||||||
ch_dlist_insert(&vtlp->dlist, &vtp->dlist, delta);
|
ch_dlist_insert(&vtlp->dlist, &vtp->dlist, delta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Next element in the list.*/
|
|
||||||
dlp = vtlp->dlist.next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the list is empty, nothing else to do.*/
|
/* If the list is empty, nothing else to do.*/
|
||||||
|
@ -492,7 +495,7 @@ void chVTDoTickI(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculating the delta to the next alarm time.*/
|
/* Calculating the delta to the next alarm time.*/
|
||||||
delta = dlp->delta - nowdelta;
|
delta = vtp->dlist.delta - nowdelta;
|
||||||
|
|
||||||
/* Limit delta to CH_CFG_ST_TIMEDELTA.*/
|
/* Limit delta to CH_CFG_ST_TIMEDELTA.*/
|
||||||
if (delta < (sysinterval_t)CH_CFG_ST_TIMEDELTA) {
|
if (delta < (sysinterval_t)CH_CFG_ST_TIMEDELTA) {
|
||||||
|
|
Loading…
Reference in New Issue