Platform/ECM3532/M3/hw/hal/common/timer/src/timer_hal.c
/**
 * Start a timer. Timer fires after its period
 * configured with create call
 *
 * @param sHalTmr timer handle
 * @param tick
 *
 * @return int
 */
Start a timer. Timer fires after its period
configured with create call

@param sHalTmr timer handle
@param tick

@return int
Start a timer . Timer fires after its period configured with create call @param sHalTmr timer handle @param tick @return int
int32_t HalTmrStart(tHalTmr *sHalTmr)
{
    tHalTmr *sCurrTmr;
    struct sDevTmr *sDev;
    uint32_t ui32Ticks;
    int32_t i32Ret = 0;
    UBaseType_t uxSavedInterruptStatus;
    sDev = sHalTmr->sDev;
    if (!sHalTmr || !sDev)
        return -EINVAL;
    uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
    ui32Ticks = ECM3531TimerCurrTicks(sDev);
    sHalTmr->ui32Expiry =  sHalTmr->ui32TmrPrd + ui32Ticks;
    sHalTmr->ui32StartTime = ui32Ticks;
    if (TAILQ_EMPTY(&sDev->sHalTmrQ))
    {
        TAILQ_INSERT_HEAD(&sDev->sHalTmrQ, sHalTmr, sLink);
    }
    else
    {
        TAILQ_FOREACH(sCurrTmr, &sDev->sHalTmrQ, sLink)
        {
            if ((int32_t)(sHalTmr->ui32Expiry - sCurrTmr->ui32Expiry) < 0)
            {
                TAILQ_INSERT_BEFORE(sCurrTmr, sHalTmr, sLink);
                break;
            }
        }
        if (sCurrTmr == NULL)
        {
            TAILQ_INSERT_TAIL(&sDev->sHalTmrQ, sHalTmr, sLink);
        }
    }
    if (sHalTmr == TAILQ_FIRST(&sDev->sHalTmrQ))
    {
        i32Ret = ECM3531TimerSetCmpAt(sDev, sHalTmr->ui32Expiry);
        if (i32Ret >= 0)
        {
            sHalTmr->iTmrSt = HalTmrRunning;
        }
        else
        {
            ECM3531TimerChkQ(sDev);
        }
    }
    taskEXIT_CRITICAL_FROM_ISR(uxSavedInterruptStatus);
    return 0;
}
int32_t HalTmrStart ( tHalTmr * sHalTmr ) { tHalTmr * sCurrTmr ; struct sDevTmr * sDev ; uint32_t ui32Ticks ; int32_t i32Ret = 0 ; UBaseType_t uxSavedInterruptStatus ; sDev = sHalTmr -> sDev ; if ( ! sHalTmr || ! sDev ) return - EINVAL ; uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR ( ) ; ui32Ticks = ECM3531TimerCurrTicks ( sDev ) ; sHalTmr -> ui32Expiry = sHalTmr -> ui32TmrPrd + ui32Ticks ; sHalTmr -> ui32StartTime = ui32Ticks ; if ( TAILQ_EMPTY ( & sDev -> sHalTmrQ ) ) { TAILQ_INSERT_HEAD ( & sDev -> sHalTmrQ , sHalTmr , sLink ) ; } else { TAILQ_FOREACH ( sCurrTmr , & sDev -> sHalTmrQ , sLink ) { if ( ( int32_t ) ( sHalTmr -> ui32Expiry - sCurrTmr -> ui32Expiry ) < 0 ) { TAILQ_INSERT_BEFORE ( sCurrTmr , sHalTmr , sLink ) ; break ; } } if ( sCurrTmr == NULL ) { TAILQ_INSERT_TAIL ( & sDev -> sHalTmrQ , sHalTmr , sLink ) ; } } if ( sHalTmr == TAILQ_FIRST ( & sDev -> sHalTmrQ ) ) { i32Ret = ECM3531TimerSetCmpAt ( sDev , sHalTmr -> ui32Expiry ) ; if ( i32Ret >= 0 ) { sHalTmr -> iTmrSt = HalTmrRunning ; } else { ECM3531TimerChkQ ( sDev ) ; } } taskEXIT_CRITICAL_FROM_ISR ( uxSavedInterruptStatus ) ; return 0 ; }
Start a timer.
Start a timer .