/* * Stop hardware timer and read time elapsed since last start. * * returns * The elapsed time since last start in units of 16us. * */ SK_U32 SkHwtRead( SK_AC *pAC, /* Adapters context */ SK_IOC Ioc) /* IoContext */ { SK_U32 TRead; SK_U32 IStatus; if (pAC->Hwt.TActive) { SkHwtStop(pAC, Ioc); SK_IN32(Ioc, B2_TI_VAL, &TRead); TRead /= SK_HWT_FAC; SK_IN32(Ioc, B0_ISRC, &IStatus); /* Check if timer expired (or wraped around) */ if ((TRead > pAC->Hwt.TStart) || (IStatus & IS_TIMINT)) { SkHwtStop(pAC, Ioc); pAC->Hwt.TStop = pAC->Hwt.TStart; } else { pAC->Hwt.TStop = pAC->Hwt.TStart - TRead; } } return(pAC->Hwt.TStop); }
/* * Stop hardware timer and read time elapsed since last start. * * returns * The elapsed time since last start in units of 1 us. * */ SK_U32 SkHwtRead( SK_AC *pAC, /* Adapter Context */ SK_IOC IoC) /* I/O Context */ { SK_U32 TRead; SK_U32 IStatus; SK_U32 TimerInt; TimerInt = CHIP_ID_YUKON_2(pAC) ? Y2_IS_TIMINT : IS_TIMINT; if (pAC->Hwt.TActive) { SkHwtStop(pAC, IoC); SK_IN32(IoC, B2_TI_VAL, &TRead); TRead /= SK_HWT_FAC; SK_IN32(IoC, B0_ISRC, &IStatus); /* Check if timer expired (or wrapped around) */ if ((TRead > pAC->Hwt.TStart) || ((IStatus & TimerInt) != 0)) { SkHwtStop(pAC, IoC); pAC->Hwt.TStop = pAC->Hwt.TStart; } else { pAC->Hwt.TStop = pAC->Hwt.TStart - TRead; } } return(pAC->Hwt.TStop); }
/* * Stops a high level timer * - If a timer is not in the queue the function returns normally, too. */ void SkTimerStop( SK_AC *pAC, /* Adapters context */ SK_IOC Ioc, /* IoContext */ SK_TIMER *pTimer) /* Timer Pointer to be started */ { SK_TIMER **ppTimPrev ; SK_TIMER *pTm ; /* * remove timer from queue */ pTimer->TmActive = SK_FALSE ; if (pAC->Tim.StQueue == pTimer && !pTimer->TmNext) { SkHwtStop(pAC,Ioc) ; } for (ppTimPrev = &pAC->Tim.StQueue ; (pTm = *ppTimPrev) ; ppTimPrev = &pTm->TmNext ) { if (pTm == pTimer) { /* * Timer found in queue * - dequeue it and * - correct delta of the next timer */ *ppTimPrev = pTm->TmNext ; if (pTm->TmNext) { /* correct delta of next timer in queue */ pTm->TmNext->TmDelta += pTm->TmDelta ; } return ; } } }
/* * interrupt source= timer */ void SkHwtIsr( SK_AC *pAC, /* Adapters context */ SK_IOC Ioc) /* IoContext */ { SkHwtStop(pAC,Ioc); pAC->Hwt.TStop = pAC->Hwt.TStart; SkTimerDone(pAC,Ioc) ; }
/* * Initialize hardware timer. * * Must be called during init level 1. */ void SkHwtInit( SK_AC *pAC, /* Adapters context */ SK_IOC Ioc) /* IoContext */ { pAC->Hwt.TStart = 0 ; pAC->Hwt.TStop = 0 ; pAC->Hwt.TActive = SK_FALSE; SkHwtStop(pAC, Ioc); }