Platform/ECM3532/M3/hw/hal/common/timer/src/timer_hal.c
/**
 * Executes callbacks for all expired timers in a BSP timer's queue.  This
 * function is called when a timer interrupt is handled.
 */
Executes callbacks for all expired timers in a BSP timer's queue.  This
function is called when a timer interrupt is handled.
Executes callbacks for all expired timers in a BSP timer ' s queue . This function is called when a timer interrupt is handled .
static void ECM3531TimerChkQ(struct sDevTmr *sDev)
{
    tHalTmr *sHalTmr;
    uint32_t ui32Ticks;
    UBaseType_t uxSavedInterruptStatus;
    uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
    while ((sHalTmr = TAILQ_FIRST(&sDev->sHalTmrQ)) != NULL)
    {
        ui32Ticks = ECM3531TimerCurrTicks(sDev);
        sDev->ui32AtExpiry = ui32Ticks;
        if ((int32_t)(ui32Ticks - sHalTmr->ui32Expiry) >= 0)
        {
            TAILQ_REMOVE(&sDev->sHalTmrQ, sHalTmr, sLink);
            sHalTmr->sLink.tqe_prev = NULL;
            sHalTmr->fTmrCb(sHalTmr->vCbArg);
            sHalTmr->iTmrSt = HalTmrExpired;
            if(sHalTmr->iTmrTyp == HalTmrPeriodic)
                HalTmrStart(sHalTmr);
        }
        else
        {
            break;
        }
    }
    sHalTmr = TAILQ_FIRST(&sDev->sHalTmrQ);
    if (sHalTmr != NULL)
    {
        if (!ECM3531TimerSetCmpAt(sDev, sHalTmr->ui32Expiry))
        {
            sDev->ui32NextExpiry = sHalTmr->ui32Expiry;
        }
        else
        {
            taskEXIT_CRITICAL_FROM_ISR(uxSavedInterruptStatus);
            ECM3531TimerChkQ(sDev);
            return;
        }
    }
    taskEXIT_CRITICAL_FROM_ISR(uxSavedInterruptStatus);
}
static void ECM3531TimerChkQ ( struct sDevTmr * sDev ) { tHalTmr * sHalTmr ; uint32_t ui32Ticks ; UBaseType_t uxSavedInterruptStatus ; uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR ( ) ; while ( ( sHalTmr = TAILQ_FIRST ( & sDev -> sHalTmrQ ) ) != NULL ) { ui32Ticks = ECM3531TimerCurrTicks ( sDev ) ; sDev -> ui32AtExpiry = ui32Ticks ; if ( ( int32_t ) ( ui32Ticks - sHalTmr -> ui32Expiry ) >= 0 ) { TAILQ_REMOVE ( & sDev -> sHalTmrQ , sHalTmr , sLink ) ; sHalTmr -> sLink . tqe_prev = NULL ; sHalTmr -> fTmrCb ( sHalTmr -> vCbArg ) ; sHalTmr -> iTmrSt = HalTmrExpired ; if ( sHalTmr -> iTmrTyp == HalTmrPeriodic ) HalTmrStart ( sHalTmr ) ; } else { break ; } } sHalTmr = TAILQ_FIRST ( & sDev -> sHalTmrQ ) ; if ( sHalTmr != NULL ) { if ( ! ECM3531TimerSetCmpAt ( sDev , sHalTmr -> ui32Expiry ) ) { sDev -> ui32NextExpiry = sHalTmr -> ui32Expiry ; } else { taskEXIT_CRITICAL_FROM_ISR ( uxSavedInterruptStatus ) ; ECM3531TimerChkQ ( sDev ) ; return ; } } taskEXIT_CRITICAL_FROM_ISR ( uxSavedInterruptStatus ) ; }
Executes callbacks for all expired timers in a BSP timer's queue.
Executes callbacks for all expired timers in a BSP timer ' s queue .
/*
     * Remove and process each expired timer in the sorted queue
     */ /*
     * If any timers remain, schedule an interrupt
     * for the timer that expires next.
     */