示例#1
0
void LPC24XX_TIME_Driver::ISR( void* Param )
{
    //DEBUG_TRACE0(TRACE_SETCOMPARE,"LPC24XX_TIME_Driver::ISR\r\n");

    if(LPC24XX_TIMER_Driver::DidCompareHit( LPC24XX_Driver::c_SystemTime_Timer ))
    {
        LPC24XX_TIMER_Driver::ResetCompareHit( LPC24XX_Driver::c_SystemTime_Timer );
    }

    g_LPC24XX_TIME_Driver.m_lastRead = CounterValue();

    if(g_LPC24XX_TIME_Driver.m_lastRead >= g_LPC24XX_TIME_Driver.m_nextCompare)
    {
        // this also schedules the next one, if there is one
        HAL_COMPLETION::DequeueAndExec();
    }
    else
    {
        //
        // Because we are limited in the resolution of timer,
        // resetting the compare will properly configure the next interrupt.
        //
        SetCompareValue( g_LPC24XX_TIME_Driver.m_nextCompare );
    }
}
void AT91_TIME_Driver::SetCompareValue( UINT64 CompareValue )
{
    GLOBAL_LOCK(irq);

    g_AT91_TIME_Driver.m_nextCompare = CompareValue;

    bool fForceInterrupt = false;

    UINT64 CntrValue = CounterValue();

    if(CompareValue <= CntrValue)
    {
        fForceInterrupt = true;
    }
    else
    {
        UINT32 diff;

        if((CompareValue - CntrValue) > AT91_TIMER_Driver::c_MaxTimerValue)
        {
            diff = AT91_TIMER_Driver::c_MaxTimerValue;
        }
        else
        {
            diff = (UINT32)(CompareValue - CntrValue);
        }        

        AT91_TIMER_Driver::SetCompare( AT91_TIMER_Driver::c_SystemTimer, 
            (UINT16)(AT91_TIMER_Driver::ReadCounter( AT91_TIMER_Driver::c_SystemTimer ) + diff) );

        if(CounterValue() > CompareValue)
        {
            fForceInterrupt = true;
        }
    }

    if(fForceInterrupt)
    {
        // Force interrupt to process this.
        AT91_TIMER_Driver::ForceInterrupt( AT91_TIMER_Driver::c_SystemTimer);
    }
}
void SetCompareValue(UINT64 CompareValue)
{
	GLOBAL_LOCK(irq);

	m_nextCompare = CompareValue;

	bool fForceInterrupt = false;

	UINT64 CntrValue = CounterValue();

	if (CompareValue <= CntrValue)
	{
		fForceInterrupt = true;
	}
	else
	{
		UINT32 diff;

		if ((CompareValue - CntrValue) > SAMA5D3_TIMER_Driver::c_MaxTimerValue)
		{
			diff = SAMA5D3_TIMER_Driver::c_MaxTimerValue;
		}
		else
		{
			diff = (UINT32)(CompareValue - CntrValue);
		}

		SAMA5D3_TIMER_Driver::SetCompare(SAMA5D3_TIMER_Driver::c_SystemTimer,
			SAMA5D3_TIMER_Driver::ReadCounter(SAMA5D3_TIMER_Driver::c_SystemTimer) + diff);

		if (CounterValue() > CompareValue)
		{
			fForceInterrupt = true;
		}
	}

	if (fForceInterrupt)
	{
		// Force interrupt to process this.
		SAMA5D3_TIMER_Driver::ForceInterrupt(SAMA5D3_TIMER_Driver::c_SystemTimer);
	}
}
示例#4
0
INT64 LPC24XX_TIME_Driver::CurrentTime()
{
    //return Time_TicksToTime(Time_CurrentTicks());
    // we collapse the above to improve perf on a high hit function

    INT64 Time = CPU_TicksToTime( CounterValue() );

#if defined(HAL_TIMEWARP)
    return s_timewarp_compensate + Time;
#else
    return Time;
#endif
}
void AT91_TIME_Driver::ISR( void* Param )
{
    if(CounterValue() >= g_AT91_TIME_Driver.m_nextCompare)
    {
        // this also schedules the next one, if there is one
        HAL_COMPLETION::DequeueAndExec();
    }
    else
    {
        //
        // Because we are limited in the resolution of timer,
        // resetting the compare will properly configure the next interrupt.
        //
        SetCompareValue( g_AT91_TIME_Driver.m_nextCompare );
    }
}
INT64 AT91_TIME_Driver::CurrentTime()
{
    return CPU_TicksToTime( CounterValue() );
}
INT64 HAL_Time_CurrentTime()
{
	return CPU_TicksToTime(CounterValue());
}
UINT64 HAL_Time_CurrentTicks()
{
	return CounterValue();
}