Пример #1
0
void TimerHwDelayMs( uint32_t delay )
{
    uint64_t delayValue = 0;
    uint64_t timeout = 0;

    delayValue = delay * 1000;

    timeout = TimerHwGetTimerValue( );

    while( ( ( TimerHwGetTimerValue( ) - timeout  ) * HW_TIMER_TIME_BASE ) < delayValue )
    {
    }
}
void TimerHwStart( uint32_t val )
{
    TimerTickCounterContext = TimerHwGetTimerValue( );

    if( val <= HW_TIMER_TIME_BASE + 1 )
    {
        TimeoutCntValue = TimerTickCounterContext + 1;
    }
    else
    {
        TimeoutCntValue = TimerTickCounterContext + ( ( val - 1 ) / HW_TIMER_TIME_BASE );
    }
}
TimerTime_t TimerHwGetTime( void )
{

    return TimerHwGetTimerValue( ) * HW_TIMER_TIME_BASE;
}
TimerTime_t TimerHwGetElapsedTime( void )
{
     return( ( ( TimerHwGetTimerValue( ) - TimerTickCounterContext ) + 1 )  * HW_TIMER_TIME_BASE );
}