Experimental code.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/rt5_dev_point1@10816 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2017-10-13 08:52:00 +00:00
parent 750a8f14b6
commit 72d563b45f
4 changed files with 25 additions and 13 deletions

View File

@ -5,7 +5,7 @@
# Compiler options here. # Compiler options here.
ifeq ($(USE_OPT),) ifeq ($(USE_OPT),)
USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
endif endif
# C specific options here (added to USE_OPT). # C specific options here (added to USE_OPT).

View File

@ -49,7 +49,7 @@
* @details Frequency of the system timer that drives the system ticks. This * @details Frequency of the system timer that drives the system ticks. This
* setting also defines the system tick time unit. * setting also defines the system tick time unit.
*/ */
#define CH_CFG_ST_FREQUENCY 10000 #define CH_CFG_ST_FREQUENCY 100000
/** /**
* @brief Time intervals data size. * @brief Time intervals data size.

View File

@ -395,19 +395,26 @@ static inline void chVTDoTickI(void) {
systime_t now; systime_t now;
sysinterval_t delta; sysinterval_t delta;
/* First timer to be processed.*/ /* Looping through timers.*/
vtp = ch.vtlist.next; vtp = ch.vtlist.next;
now = chVTGetSystemTimeX(); while (true) {
/* 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)) {
vtfunc_t fn; 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.*/ /* The "last time" becomes this timer's expiration time.*/
ch.vtlist.lasttime = chTimeAddX(ch.vtlist.lasttime, vtp->delta); 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; vtp->next->prev = (virtual_timer_t *)&ch.vtlist;
ch.vtlist.next = vtp->next; ch.vtlist.next = vtp->next;
@ -431,10 +438,8 @@ static inline void chVTDoTickI(void) {
of the list.*/ of the list.*/
chSysLockFromISR(); chSysLockFromISR();
/* Next element in the list, the current time could have advanced so /* Next element in the list.*/
recalculating the time window.*/
vtp = ch.vtlist.next; vtp = ch.vtlist.next;
now = chVTGetSystemTimeX();
} }
/* if the list is empty, nothing else to do.*/ /* if the list is empty, nothing else to do.*/

View File

@ -125,6 +125,13 @@ void chVTDoSetI(virtual_timer_t *vtp, sysinterval_t delay,
vtp->prev = (virtual_timer_t *)&ch.vtlist; vtp->prev = (virtual_timer_t *)&ch.vtlist;
vtp->delta = delay; 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.*/ /* Being the first element in the list the alarm timer is started.*/
port_timer_start_alarm(chTimeAddX(ch.vtlist.lasttime, delay)); port_timer_start_alarm(chTimeAddX(ch.vtlist.lasttime, delay));