lib/bsp/standalone/src/arm/common/xil_sleeptimer.c
void Xil_SleepTTCCommon(u32 delay, u64 frequency)
{
	u64 tEnd = 0U;
	u64 tCur = 0U;
	XCntrVal TimeHighVal = 0U;
	XCntrVal TimeLowVal1 = 0U;
	XCntrVal TimeLowVal2 = 0U;

	TimeLowVal1 = XSleep_ReadCounterVal(SLEEP_TIMER_BASEADDR +
			XSLEEP_TIMER_TTC_COUNT_VALUE_OFFSET);
	tEnd = (u64)TimeLowVal1 + ((u64)(delay) * frequency);
	do
	{
		TimeLowVal2 = XSleep_ReadCounterVal(SLEEP_TIMER_BASEADDR +
				                  XSLEEP_TIMER_TTC_COUNT_VALUE_OFFSET);
		if (TimeLowVal2 < TimeLowVal1) {
			TimeHighVal++;
		}
		TimeLowVal1 = TimeLowVal2;
		tCur = (((u64) TimeHighVal) << XSLEEP_TIMER_REG_SHIFT) |
								(u64)TimeLowVal2;
	}while (tCur < tEnd);
}
/****************************************************************************/
/**
*
* This is a helper function used by sleep/usleep APIs to
* have delay in sec/usec
*
* @param            delay - delay time in seconds/micro seconds
*
* @param            frequency - Number of counts per second/micro second
*
* @return           none
*
* @note             none
*
*****************************************************************************/
This is a helper function used by sleep/usleep APIs to
have delay in sec/usec
This is a helper function used by sleep / usleep APIs to have delay in sec / usec
void Xil_SleepTTCCommon(u32 delay, u64 frequency)
{
	u64 tEnd = 0U;
	u64 tCur = 0U;
	XCntrVal TimeHighVal = 0U;
	XCntrVal TimeLowVal1 = 0U;
	XCntrVal TimeLowVal2 = 0U;
	TimeLowVal1 = XSleep_ReadCounterVal(SLEEP_TIMER_BASEADDR +
			XSLEEP_TIMER_TTC_COUNT_VALUE_OFFSET);
	tEnd = (u64)TimeLowVal1 + ((u64)(delay) * frequency);
	do
	{
		TimeLowVal2 = XSleep_ReadCounterVal(SLEEP_TIMER_BASEADDR +
				                  XSLEEP_TIMER_TTC_COUNT_VALUE_OFFSET);
		if (TimeLowVal2 < TimeLowVal1) {
			TimeHighVal++;
		}
		TimeLowVal1 = TimeLowVal2;
		tCur = (((u64) TimeHighVal) << XSLEEP_TIMER_REG_SHIFT) |
								(u64)TimeLowVal2;
	}while (tCur < tEnd);
}
void Xil_SleepTTCCommon ( u32 delay , u64 frequency ) { u64 tEnd = 0U ; u64 tCur = 0U ; XCntrVal TimeHighVal = 0U ; XCntrVal TimeLowVal1 = 0U ; XCntrVal TimeLowVal2 = 0U ; TimeLowVal1 = XSleep_ReadCounterVal ( SLEEP_TIMER_BASEADDR + XSLEEP_TIMER_TTC_COUNT_VALUE_OFFSET ) ; tEnd = ( u64 ) TimeLowVal1 + ( ( u64 ) ( delay ) * frequency ) ; do { TimeLowVal2 = XSleep_ReadCounterVal ( SLEEP_TIMER_BASEADDR + XSLEEP_TIMER_TTC_COUNT_VALUE_OFFSET ) ; if ( TimeLowVal2 < TimeLowVal1 ) { TimeHighVal ++ ; } TimeLowVal1 = TimeLowVal2 ; tCur = ( ( ( u64 ) TimeHighVal ) << XSLEEP_TIMER_REG_SHIFT ) | ( u64 ) TimeLowVal2 ; } while ( tCur < tEnd ) ; }
This is a helper function used by sleep/usleep APIs to
have delay in sec/usec
This is a helper function used by sleep / usleep APIs to have delay in sec / usec