XilinxProcessorIPLib/drivers/wdttb/examples/xwdttb_gwdt_intr_example.c
int GWdtIntrExample(XScuGic *IntcInstancePtr, XWdtTb *GWdtInstancePtr,
		    u16 GWdtDeviceId,
		    u16 GWdtIntrId)
{
	int Status;
	XWdtTb_Config *Config;

	/*
	 * Initialize the WDTTB driver so that it's ready to use look up
	 * configuration in the config table, then initialize it.
	 */
	Config = XWdtTb_LookupConfig(GWdtDeviceId);
	if (NULL == Config) {
		return XST_FAILURE;
	}

	/*
	 * Initialize the watchdog timer and timebase driver so that
	 * it is ready to use.
	 */
	Status = XWdtTb_CfgInitialize(GWdtInstancePtr, Config,
				      Config->BaseAddr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

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

	/*
	 * Stop the timer to start the test for interrupt mode
	 */
	XWdtTb_Stop(GWdtInstancePtr);

	/*
	 * Connect the WdtTb to the interrupt subsystem so that interrupts
	 * can occur
	 */
	Status = GWdtSetupIntrSystem(IntcInstancePtr, GWdtInstancePtr,
				      GWdtIntrId);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/* Update GWOR Register */
	XWdtTb_SetGenericWdtWindow(GWdtInstancePtr, WDTPSV_GWOR_COUNT);

	/*
	 * Start the WdtTb device
	 */
	GWdtExpired = FALSE;
	XWdtTb_Start(GWdtInstancePtr);

	/*
	 * Wait for the first expiration of the GWDT
	 */
	while (GWdtExpired != TRUE);
	GWdtExpired = FALSE;

	/*
	 * Wait for the second expiration of the GWDT
	 */
	while (GWdtExpired != TRUE);
	GWdtExpired = FALSE;

	/*
	 * Disable and disconnect the interrupt system
	 */
	GWdtDisableIntrSystem(IntcInstancePtr, GWdtIntrId);

	/*
	 * Stop the timer
	 */
	XWdtTb_Stop(GWdtInstancePtr);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function tests the functioning of the Generic WatchDog Timer module
* in the Interrupt mode (for the gwdt_ws0 interrupt).
*
* After one expiration of the GWDT timeout interval, an interrupt is generated
* and the GWS[1] state bit is set to one in the Generic Watchdog Control and
* Status Register register.
* If the system can attempt to take corrective action that includes refreshing
* the watchdog within the second watch period. If the refresh is successful,
* the system returns to the previous normal operation. If it fails, then the
* second watch period expires and a second signal is generated.
* A GWDT reset sets the GWS[2] reset status bit in the status register so that
* the application code can determine if the last system reset was a WDT reset.
*
* This function assumes that the reset output of the GWDT device is not
* connected to the reset of the processor. The function allows the watchdog
* timer to timeout such that a reset will occur if it is connected.
*
* @param	IntcInstancePtr is a pointer to the instance of the XScuGic
*		driver.
* @param	GWdtInstancePtr is a pointer to the instance of WdtTb driver.
* @param	GWdtDeviceId is the Device ID of the GWDT Device and is
*		typically XPAR_<GWDT_instance>_DEVICE_ID value from
*		xparameters.h.
* @param	GWdtIntrId is the Interrupt Id of the WatchDog and is typically
*		XPAR_<FABRIC_instance>_<GWDT_instance>_INTERRUPT_VEC_ID
*		value from xparameters.h.
*
* @return
*		- XST_SUCCESS if successful.
*		- XST_FAILURE, otherwise.
*
* @note		This example will not return if the interrupts are not working.
*
******************************************************************************/
This function tests the functioning of the Generic WatchDog Timer module
in the Interrupt mode (for the gwdt_ws0 interrupt).

After one expiration of the GWDT timeout interval, an interrupt is generated
and the GWS[1] state bit is set to one in the Generic Watchdog Control and
Status Register register.
If the system can attempt to take corrective action that includes refreshing
the watchdog within the second watch period. If the refresh is successful,
the system returns to the previous normal operation. If it fails, then the
second watch period expires and a second signal is generated.
A GWDT reset sets the GWS[2] reset status bit in the status register so that
the application code can determine if the last system reset was a WDT reset.

This function assumes that the reset output of the GWDT device is not
connected to the reset of the processor. The function allows the watchdog
timer to timeout such that a reset will occur if it is connected.
This function tests the functioning of the Generic WatchDog Timer module in the Interrupt mode ( for the gwdt_ws0 interrupt ) . After one expiration of the GWDT timeout interval an interrupt is generated and the GWS [ 1 ] state bit is set to one in the Generic Watchdog Control and Status Register register . If the system can attempt to take corrective action that includes refreshing the watchdog within the second watch period . If the refresh is successful the system returns to the previous normal operation . If it fails then the second watch period expires and a second signal is generated . A GWDT reset sets the GWS [ 2 ] reset status bit in the status register so that the application code can determine if the last system reset was a WDT reset . This function assumes that the reset output of the GWDT device is not connected to the reset of the processor . The function allows the watchdog timer to timeout such that a reset will occur if it is connected .
int GWdtIntrExample(XScuGic *IntcInstancePtr, XWdtTb *GWdtInstancePtr,
		    u16 GWdtDeviceId,
		    u16 GWdtIntrId)
{
	int Status;
	XWdtTb_Config *Config;
	Config = XWdtTb_LookupConfig(GWdtDeviceId);
	if (NULL == Config) {
		return XST_FAILURE;
	}
	Status = XWdtTb_CfgInitialize(GWdtInstancePtr, Config,
				      Config->BaseAddr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = XWdtTb_SelfTest(GWdtInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XWdtTb_Stop(GWdtInstancePtr);
	Status = GWdtSetupIntrSystem(IntcInstancePtr, GWdtInstancePtr,
				      GWdtIntrId);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XWdtTb_SetGenericWdtWindow(GWdtInstancePtr, WDTPSV_GWOR_COUNT);
	GWdtExpired = FALSE;
	XWdtTb_Start(GWdtInstancePtr);
	while (GWdtExpired != TRUE);
	GWdtExpired = FALSE;
	while (GWdtExpired != TRUE);
	GWdtExpired = FALSE;
	GWdtDisableIntrSystem(IntcInstancePtr, GWdtIntrId);
	XWdtTb_Stop(GWdtInstancePtr);
	return XST_SUCCESS;
}
int GWdtIntrExample ( XScuGic * IntcInstancePtr , XWdtTb * GWdtInstancePtr , u16 GWdtDeviceId , u16 GWdtIntrId ) { int Status ; XWdtTb_Config * Config ; Config = XWdtTb_LookupConfig ( GWdtDeviceId ) ; if ( NULL == Config ) { return XST_FAILURE ; } Status = XWdtTb_CfgInitialize ( GWdtInstancePtr , Config , Config -> BaseAddr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = XWdtTb_SelfTest ( GWdtInstancePtr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XWdtTb_Stop ( GWdtInstancePtr ) ; Status = GWdtSetupIntrSystem ( IntcInstancePtr , GWdtInstancePtr , GWdtIntrId ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XWdtTb_SetGenericWdtWindow ( GWdtInstancePtr , WDTPSV_GWOR_COUNT ) ; GWdtExpired = FALSE ; XWdtTb_Start ( GWdtInstancePtr ) ; while ( GWdtExpired != TRUE ) ; GWdtExpired = FALSE ; while ( GWdtExpired != TRUE ) ; GWdtExpired = FALSE ; GWdtDisableIntrSystem ( IntcInstancePtr , GWdtIntrId ) ; XWdtTb_Stop ( GWdtInstancePtr ) ; return XST_SUCCESS ; }
This function tests the functioning of the Generic WatchDog Timer module
in the Interrupt mode (for the gwdt_ws0 interrupt).
This function tests the functioning of the Generic WatchDog Timer module in the Interrupt mode ( for the gwdt_ws0 interrupt ) .
/*
	 * Initialize the WDTTB driver so that it's ready to use look up
	 * configuration in the config table, then initialize it.
	 */ /*
	 * Initialize the watchdog timer and timebase driver so that
	 * it is ready to use.
	 */ /*
	 * Perform a self-test to ensure that the hardware was built correctly
	 */ /*
	 * Stop the timer to start the test for interrupt mode
	 */ /*
	 * Connect the WdtTb to the interrupt subsystem so that interrupts
	 * can occur
	 */ /* Update GWOR Register */ /*
	 * Start the WdtTb device
	 */ /*
	 * Wait for the first expiration of the GWDT
	 */ /*
	 * Wait for the second expiration of the GWDT
	 */ /*
	 * Disable and disconnect the interrupt system
	 */ /*
	 * Stop the timer
	 */