lib/bsp/standalone/examples/xil_nested_interrupts_example.c
int TmrNestedInterruptExample()
{
	u32 Status;
	u32 IntrPriority;
	u32 DeviceID;
	u32 TtcTickIntrID;

	/*
	 * Connect the Intc to the interrupt subsystem such that interrupts can
	 * occur.  This function is application specific.
	 */

	Status = SetupInterruptSystem(INTC_DEVICE_ID, &InterruptController);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * TTC timers are configured to start at the same time with
	 * different frequency
	 */

	/* Configure counter 0 */
	DeviceID = TTC_CNT0_TICK_DEVICE_ID;
	TtcTickIntrID = TTC_CNT0_TICK_INTR_ID;

	/* configure the priority for counter 0 */
	IntrPriority = XScuGic_DistReadReg(&InterruptController,
			XSCUGIC_PRIORITY_OFFSET_CALC(TtcTickIntrID));
	IntrPriority = (IntrPriority & ~( XSCUGIC_PRIORITY_MASK << ((TtcTickIntrID % 4) * 8)))
							| (TTC_CNT0_INTR_PRIORITY << ((TtcTickIntrID%4) * 8));
	XScuGic_DistWriteReg(&InterruptController,
					XSCUGIC_PRIORITY_OFFSET_CALC(TtcTickIntrID),IntrPriority);
	Status = SetupTicker(&TtcPsInst0,DeviceID,TtcTickIntrID, (void*) TtcInst0TickHandler,
						&InterruptController, SettingsTable0);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/* Configure counter 1 */
	DeviceID = TTC_CNT1_TICK_DEVICE_ID;
	TtcTickIntrID = TTC_CNT1_TICK_INTR_ID;

	/* configure the priority for counter 1 */
	IntrPriority = XScuGic_DistReadReg(&InterruptController,
				XSCUGIC_PRIORITY_OFFSET_CALC(TtcTickIntrID));
	IntrPriority = (IntrPriority & ~( XSCUGIC_PRIORITY_MASK << ((TtcTickIntrID % 4) * 8)))
						| (TTC_CNT1_INTR_PRIORITY << ((TtcTickIntrID%4) * 8));
	XScuGic_DistWriteReg(&InterruptController,
						XSCUGIC_PRIORITY_OFFSET_CALC(TtcTickIntrID),IntrPriority);

	Status = SetupTicker(&TtcPsInst1,DeviceID,TtcTickIntrID, (void*) TtcInst1TickHandler,
						&InterruptController,SettingsTable1);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/* start all the timer at once */
	XTtcPs_Start(&TtcPsInst0);

	XTtcPs_Start(&TtcPsInst1);


	while(LowPriorityIntrFlag==0 || HighPriorityIntrFlag==0);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This is the main function of the nested interrupt example.
*
* @param	None
*
* @return	XST_SUCCESS to indicate success, else XST_FAILURE to indicate
*		a Failure.
*
****************************************************************************/
This is the main function of the nested interrupt example.
This is the main function of the nested interrupt example .
int TmrNestedInterruptExample()
{
	u32 Status;
	u32 IntrPriority;
	u32 DeviceID;
	u32 TtcTickIntrID;
	Status = SetupInterruptSystem(INTC_DEVICE_ID, &InterruptController);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	DeviceID = TTC_CNT0_TICK_DEVICE_ID;
	TtcTickIntrID = TTC_CNT0_TICK_INTR_ID;
	IntrPriority = XScuGic_DistReadReg(&InterruptController,
			XSCUGIC_PRIORITY_OFFSET_CALC(TtcTickIntrID));
	IntrPriority = (IntrPriority & ~( XSCUGIC_PRIORITY_MASK << ((TtcTickIntrID % 4) * 8)))
							| (TTC_CNT0_INTR_PRIORITY << ((TtcTickIntrID%4) * 8));
	XScuGic_DistWriteReg(&InterruptController,
					XSCUGIC_PRIORITY_OFFSET_CALC(TtcTickIntrID),IntrPriority);
	Status = SetupTicker(&TtcPsInst0,DeviceID,TtcTickIntrID, (void*) TtcInst0TickHandler,
						&InterruptController, SettingsTable0);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	DeviceID = TTC_CNT1_TICK_DEVICE_ID;
	TtcTickIntrID = TTC_CNT1_TICK_INTR_ID;
	IntrPriority = XScuGic_DistReadReg(&InterruptController,
				XSCUGIC_PRIORITY_OFFSET_CALC(TtcTickIntrID));
	IntrPriority = (IntrPriority & ~( XSCUGIC_PRIORITY_MASK << ((TtcTickIntrID % 4) * 8)))
						| (TTC_CNT1_INTR_PRIORITY << ((TtcTickIntrID%4) * 8));
	XScuGic_DistWriteReg(&InterruptController,
						XSCUGIC_PRIORITY_OFFSET_CALC(TtcTickIntrID),IntrPriority);
	Status = SetupTicker(&TtcPsInst1,DeviceID,TtcTickIntrID, (void*) TtcInst1TickHandler,
						&InterruptController,SettingsTable1);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XTtcPs_Start(&TtcPsInst0);
	XTtcPs_Start(&TtcPsInst1);
	while(LowPriorityIntrFlag==0 || HighPriorityIntrFlag==0);
	return XST_SUCCESS;
}
int TmrNestedInterruptExample ( ) { u32 Status ; u32 IntrPriority ; u32 DeviceID ; u32 TtcTickIntrID ; Status = SetupInterruptSystem ( INTC_DEVICE_ID , & InterruptController ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } DeviceID = TTC_CNT0_TICK_DEVICE_ID ; TtcTickIntrID = TTC_CNT0_TICK_INTR_ID ; IntrPriority = XScuGic_DistReadReg ( & InterruptController , XSCUGIC_PRIORITY_OFFSET_CALC ( TtcTickIntrID ) ) ; IntrPriority = ( IntrPriority & ~ ( XSCUGIC_PRIORITY_MASK << ( ( TtcTickIntrID % 4 ) * 8 ) ) ) | ( TTC_CNT0_INTR_PRIORITY << ( ( TtcTickIntrID % 4 ) * 8 ) ) ; XScuGic_DistWriteReg ( & InterruptController , XSCUGIC_PRIORITY_OFFSET_CALC ( TtcTickIntrID ) , IntrPriority ) ; Status = SetupTicker ( & TtcPsInst0 , DeviceID , TtcTickIntrID , ( void * ) TtcInst0TickHandler , & InterruptController , SettingsTable0 ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } DeviceID = TTC_CNT1_TICK_DEVICE_ID ; TtcTickIntrID = TTC_CNT1_TICK_INTR_ID ; IntrPriority = XScuGic_DistReadReg ( & InterruptController , XSCUGIC_PRIORITY_OFFSET_CALC ( TtcTickIntrID ) ) ; IntrPriority = ( IntrPriority & ~ ( XSCUGIC_PRIORITY_MASK << ( ( TtcTickIntrID % 4 ) * 8 ) ) ) | ( TTC_CNT1_INTR_PRIORITY << ( ( TtcTickIntrID % 4 ) * 8 ) ) ; XScuGic_DistWriteReg ( & InterruptController , XSCUGIC_PRIORITY_OFFSET_CALC ( TtcTickIntrID ) , IntrPriority ) ; Status = SetupTicker ( & TtcPsInst1 , DeviceID , TtcTickIntrID , ( void * ) TtcInst1TickHandler , & InterruptController , SettingsTable1 ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XTtcPs_Start ( & TtcPsInst0 ) ; XTtcPs_Start ( & TtcPsInst1 ) ; while ( LowPriorityIntrFlag == 0 || HighPriorityIntrFlag == 0 ) ; return XST_SUCCESS ; }
This is the main function of the nested interrupt example.
This is the main function of the nested interrupt example .
/*
	 * Connect the Intc to the interrupt subsystem such that interrupts can
	 * occur.  This function is application specific.
	 */ /*
	 * TTC timers are configured to start at the same time with
	 * different frequency
	 */ /* Configure counter 0 */ /* configure the priority for counter 0 */ /* Configure counter 1 */ /* configure the priority for counter 1 */ /* start all the timer at once */