git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/stable_16.1.x@9856 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2016-10-10 12:20:18 +00:00
parent 4dfc65d170
commit e7b320c916
2 changed files with 20 additions and 6 deletions

View File

@ -131,23 +131,36 @@ void chVTDoSetI(virtual_timer_t *vtp, systime_t delay,
return; return;
} }
/* Special case where the timer will be placed as first element in a /* Pointer to the first element in the delta list, which is non-empty.*/
non-empty list, the alarm needs to be recalculated.*/ p = ch.vtlist.vt_next;
delta = now + delay - ch.vtlist.vt_lasttime;
if (delta < ch.vtlist.vt_next->vt_delta) {
/* New alarm deadline.*/ /* Delay as delta from 'lasttime'. Note, it can overflow and the value
becomes lower than 'now'.*/
delta = now - ch.vtlist.vt_lasttime + delay;
if (delta < now - ch.vtlist.vt_lasttime) {
/* Scenario where a very large delay excedeed the numeric range, it
requires a special handling. We need to skip the first element and
adjust the delta to wrap back in the previous numeric range.*/
delta -= p->vt_delta;
p = p->vt_next;
}
else if (delta < p->vt_delta) {
/* A small delay that will become the first element in the delta list
and next deadline.*/
port_timer_set_alarm(ch.vtlist.vt_lasttime + delta); port_timer_set_alarm(ch.vtlist.vt_lasttime + delta);
} }
} }
#else /* CH_CFG_ST_TIMEDELTA == 0 */ #else /* CH_CFG_ST_TIMEDELTA == 0 */
/* Delta is initially equal to the specified delay.*/ /* Delta is initially equal to the specified delay.*/
delta = delay; delta = delay;
/* Pointer to the first element in the delta list.*/
p = ch.vtlist.vt_next;
#endif /* CH_CFG_ST_TIMEDELTA == 0 */ #endif /* CH_CFG_ST_TIMEDELTA == 0 */
/* The delta list is scanned in order to find the correct position for /* The delta list is scanned in order to find the correct position for
this timer. */ this timer. */
p = ch.vtlist.vt_next;
while (p->vt_delta < delta) { while (p->vt_delta < delta) {
delta -= p->vt_delta; delta -= p->vt_delta;
p = p->vt_next; p = p->vt_next;

View File

@ -73,6 +73,7 @@
***************************************************************************** *****************************************************************************
*** 16.1.6 *** *** 16.1.6 ***
- RT: Fixed tick-less mode can fail in RT for very large delays (bug #784).
- HAL: Fixed STM32L0xx CCIPR initialization (bug #783). - HAL: Fixed STM32L0xx CCIPR initialization (bug #783).
- HAL: Fixed STM32F105 port not compiling (bug #782). - HAL: Fixed STM32F105 port not compiling (bug #782).
- HAL: Fixed wrong registry for STM32F205xx and STM32F215xx port - HAL: Fixed wrong registry for STM32F205xx and STM32F215xx port