Platform/ECM3532/DSP/framework/src/timer.c
/* subtract time from all timers, enabling any that run out along the way */
/* Also identifies timer with least byteCnt, which is going to expire*/
subtract time from all timers, enabling any that run out along the way
Also identifies timer with least byteCnt, which is going to expire
subtract time from all timers enabling any that run out along the way Also identifies timer with least byteCnt which is going to expire
static void timers_update(TIME time)
{
    static struct timer timer_last = {
        0,
        0,
        VERY_LONG_TIME    ,
        FALSE     ,
    };
    struct timer* t;
    int doReparse = 0;
    timer_next = &timer_last;
    for (t = timers; t < &timers[MAX_TIMERS]; t++) {
        if (t->inUse) {
            if (time < t->time) { 
                t->time -= time;
                if (t->time < timer_next->time)
                    timer_next = t;
            }
            else { 
                t->timerCb(t->context);
                if (t->periodic == 0) {
                    t->inUse = 0; 
                }                    
                else {
                    doReparse = 1;
                    t->time = t->periodTime;
                } 
            }
        }
    }
    if (doReparse) {
        timer_next = &timer_last;
        for (t = timers; t < &timers[MAX_TIMERS]; t++) {
            if (t->inUse) {  
                if (t->time < timer_next->time)
                    timer_next = t;
            }
        }
    }
    if (!timer_next->inUse) {
        timer_next = 0;
        time_now = 0;
        time_timer_set = 0;
        physical_timer_tick_set = 0;
    }
}
static void timers_update ( TIME time ) { static struct timer timer_last = { 0 , 0 , VERY_LONG_TIME , FALSE , } ; struct timer * t ; int doReparse = 0 ; timer_next = & timer_last ; for ( t = timers ; t < & timers [ MAX_TIMERS ] ; t ++ ) { if ( t -> inUse ) { if ( time < t -> time ) { t -> time -= time ; if ( t -> time < timer_next -> time ) timer_next = t ; } else { t -> timerCb ( t -> context ) ; if ( t -> periodic == 0 ) { t -> inUse = 0 ; } else { doReparse = 1 ; t -> time = t -> periodTime ; } } } } if ( doReparse ) { timer_next = & timer_last ; for ( t = timers ; t < & timers [ MAX_TIMERS ] ; t ++ ) { if ( t -> inUse ) { if ( t -> time < timer_next -> time ) timer_next = t ; } } } if ( ! timer_next -> inUse ) { timer_next = 0 ; time_now = 0 ; time_timer_set = 0 ; physical_timer_tick_set = 0 ; } }
subtract time from all timers, enabling any that run out along the way
Also identifies timer with least byteCnt, which is going to expire
subtract time from all timers enabling any that run out along the way Also identifies timer with least byteCnt which is going to expire
/* time */ /* in use */ /* unexpired */ /* expired */ /* tell scheduler */ /* remove timer */ //Now reparse the list to find the shortest timer /* reset timer_next if no timers found */