PUBLIC void ZTIMER_vTask(void)
{
……………………..
/* If no ticks to process, exit */
if(ZTIMER_sCommon.u8Ticks == 0)
{
return;
}
/* Decrement the tick counter */
ZTIMER_sCommon.u8Ticks--;
/* Process all of the timers */
for(n = 0; n < ZTIMER_sCommon.u8NumTimers; n++)
{
psTimer = &ZTIMER_sCommon.psTimers[n];
/* If this timer is not opened and running, skip it */
if(psTimer->eState != E_ZTIMER_STATE_RUNNING)
{
continue;
}
/* Decrement the time */
psTimer->u32Time--;
/* If the timer has not expired, move on to the next one */
if(psTimer->u32Time > 0)
{
continue;
}
psTimer->eState = E_ZTIMER_STATE_EXPIRED;
/* If this timer should prevent sleeping while running, decrement the activity count */
if(psTimer->u8Flags & ZTIMER_FLAG_PREVENT_SLEEP)
{
PWRM_eFinishActivity();
}
/* If the timer has a valid callback, call it */
if(psTimer->pfCallback != NULL)
{
psTimer->pfCallback(psTimer->pvParameters);
}
}
}