XilinxProcessorIPLib/drivers/scutimer/examples/xscutimer_intr_example.c
int ScuTimerIntrExample(XScuGic *IntcInstancePtr, XScuTimer * TimerInstancePtr,
			u16 TimerDeviceId, u16 TimerIntrId)
{
	int Status;
	int LastTimerExpired = 0;
	XScuTimer_Config *ConfigPtr;

	/*
	 * Initialize the Scu Private Timer driver.
	 */
	ConfigPtr = XScuTimer_LookupConfig(TimerDeviceId);

	/*
	 * This is where the virtual address would be used, this example
	 * uses physical address.
	 */
	Status = XScuTimer_CfgInitialize(TimerInstancePtr, ConfigPtr,
					ConfigPtr->BaseAddr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Perform a self-test to ensure that the hardware was built correctly.
	 */
	Status = XScuTimer_SelfTest(TimerInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Connect the device to interrupt subsystem so that interrupts
	 * can occur.
	 */
	Status = TimerSetupIntrSystem(IntcInstancePtr,
					TimerInstancePtr, TimerIntrId);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Enable Auto reload mode.
	 */
	XScuTimer_EnableAutoReload(TimerInstancePtr);

	/*
	 * Load the timer counter register.
	 */
	XScuTimer_LoadTimer(TimerInstancePtr, TIMER_LOAD_VALUE);

	/*
	 * Start the timer counter and then wait for it
	 * to timeout a number of times.
	 */
	XScuTimer_Start(TimerInstancePtr);

	while (1) {
		/*
		 * Wait for the first timer counter to expire as indicated by
		 * the shared variable which the handler will increment.
		 */
		while (TimerExpired == LastTimerExpired) {
		}

		LastTimerExpired = TimerExpired;
		/*
		 * If it has expired a number of times, then stop the timer
		 * counter and stop this example.
		 */
		if (TimerExpired == 3) {
			XScuTimer_Stop(TimerInstancePtr);
			break;
		}
	}
	/*
	 * Disable and disconnect the interrupt system.
	 */
	TimerDisableIntrSystem(IntcInstancePtr, TimerIntrId);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function tests the functioning of the Cortex A9 Scu Private Timer driver
* and hardware using interrupts.
*
* @param	IntcInstancePtr is a pointer to the instance of XScuGic driver.
* @param	TimerInstancePtr is a pointer to the instance of XScuTimer
*		driver.
* @param	TimerDeviceId is the Device ID of the XScuTimer device.
* @param	TimerIntrId is the Interrupt Id of the XScuTimer device.
*
* @return	XST_SUCCESS if successful, otherwise XST_FAILURE.
*
* @note		None.
*
******************************************************************************/
This function tests the functioning of the Cortex A9 Scu Private Timer driver
and hardware using interrupts.
This function tests the functioning of the Cortex A9 Scu Private Timer driver and hardware using interrupts .
int ScuTimerIntrExample(XScuGic *IntcInstancePtr, XScuTimer * TimerInstancePtr,
			u16 TimerDeviceId, u16 TimerIntrId)
{
	int Status;
	int LastTimerExpired = 0;
	XScuTimer_Config *ConfigPtr;
	ConfigPtr = XScuTimer_LookupConfig(TimerDeviceId);
	Status = XScuTimer_CfgInitialize(TimerInstancePtr, ConfigPtr,
					ConfigPtr->BaseAddr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = XScuTimer_SelfTest(TimerInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = TimerSetupIntrSystem(IntcInstancePtr,
					TimerInstancePtr, TimerIntrId);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XScuTimer_EnableAutoReload(TimerInstancePtr);
	XScuTimer_LoadTimer(TimerInstancePtr, TIMER_LOAD_VALUE);
	XScuTimer_Start(TimerInstancePtr);
	while (1) {
		while (TimerExpired == LastTimerExpired) {
		}
		LastTimerExpired = TimerExpired;
		if (TimerExpired == 3) {
			XScuTimer_Stop(TimerInstancePtr);
			break;
		}
	}
	TimerDisableIntrSystem(IntcInstancePtr, TimerIntrId);
	return XST_SUCCESS;
}
int ScuTimerIntrExample ( XScuGic * IntcInstancePtr , XScuTimer * TimerInstancePtr , u16 TimerDeviceId , u16 TimerIntrId ) { int Status ; int LastTimerExpired = 0 ; XScuTimer_Config * ConfigPtr ; ConfigPtr = XScuTimer_LookupConfig ( TimerDeviceId ) ; Status = XScuTimer_CfgInitialize ( TimerInstancePtr , ConfigPtr , ConfigPtr -> BaseAddr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = XScuTimer_SelfTest ( TimerInstancePtr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = TimerSetupIntrSystem ( IntcInstancePtr , TimerInstancePtr , TimerIntrId ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XScuTimer_EnableAutoReload ( TimerInstancePtr ) ; XScuTimer_LoadTimer ( TimerInstancePtr , TIMER_LOAD_VALUE ) ; XScuTimer_Start ( TimerInstancePtr ) ; while ( 1 ) { while ( TimerExpired == LastTimerExpired ) { } LastTimerExpired = TimerExpired ; if ( TimerExpired == 3 ) { XScuTimer_Stop ( TimerInstancePtr ) ; break ; } } TimerDisableIntrSystem ( IntcInstancePtr , TimerIntrId ) ; return XST_SUCCESS ; }
This function tests the functioning of the Cortex A9 Scu Private Timer driver
and hardware using interrupts.
This function tests the functioning of the Cortex A9 Scu Private Timer driver and hardware using interrupts .
/*
	 * Initialize the Scu Private Timer driver.
	 */ /*
	 * This is where the virtual address would be used, this example
	 * uses physical address.
	 */ /*
	 * Perform a self-test to ensure that the hardware was built correctly.
	 */ /*
	 * Connect the device to interrupt subsystem so that interrupts
	 * can occur.
	 */ /*
	 * Enable Auto reload mode.
	 */ /*
	 * Load the timer counter register.
	 */ /*
	 * Start the timer counter and then wait for it
	 * to timeout a number of times.
	 */ /*
		 * Wait for the first timer counter to expire as indicated by
		 * the shared variable which the handler will increment.
		 */ /*
		 * If it has expired a number of times, then stop the timer
		 * counter and stop this example.
		 */ /*
	 * Disable and disconnect the interrupt system.
	 */