XilinxProcessorIPLib/drivers/wdttb/examples/xwdttb_winwdt_intr_example.c
int WinWdtIntrExample(INTC *IntcInstancePtr,
			XWdtTb *WdtTbInstancePtr,
			u16 WdtTbDeviceId,
			u16 WdtTbIntrId)
{
	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(WdtTbDeviceId);
	if (NULL == Config) {
		return XST_FAILURE;
	}

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

	if(!WdtTbInstancePtr->Config.IsPl) {
		/*Enable Window Watchdog Feature in WWDT */
		XWdtTb_ConfigureWDTMode(WdtTbInstancePtr, XWT_WWDT);
	}

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

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

	/* Set register space to writable */
	XWdtTb_SetRegSpaceAccessMode(WdtTbInstancePtr, 1);

	/* Configure first and second window */
	XWdtTb_SetWindowCount(WdtTbInstancePtr, 0, WIN_WDT_SW_COUNT);

	/* Set interrupt position */
	XWdtTb_SetByteCount(WdtTbInstancePtr, WIN_WDT_SBC_COUNT);
	XWdtTb_SetByteSegment(WdtTbInstancePtr, WIN_WDT_BSS_COUNT);

	/* Disable Secondary Sequence Timer (SST) */
	XWdtTb_DisableSst(WdtTbInstancePtr);

	/* Disable Program Sequence Monitor (PSM) */
	XWdtTb_DisablePsm(WdtTbInstancePtr);

	/* Disable Fail Counter */
	XWdtTb_DisableFailCounter(WdtTbInstancePtr);

	/*
	 * Start the watchdog timer as a normal application would
	 */
	XWdtTb_Start(WdtTbInstancePtr);
	WdtExpired = FALSE;

	/* Set register space to writable */
	XWdtTb_SetRegSpaceAccessMode(WdtTbInstancePtr, 1);

	/*
	 * Wait for the first occurrence of interrupt programmed point.
	 */
	while (WdtExpired != TRUE);


	/* Clear interrupt point */
	XWdtTb_IntrClear(WdtTbInstancePtr);
	WdtExpired = FALSE;

	/* Wait for the second occurrence of interrupt programmed point */
	while (WdtExpired != TRUE);

	/* Clear interrupt point */
	XWdtTb_IntrClear(WdtTbInstancePtr);
	WdtExpired = FALSE;

	/* Check for last event */
	if (XWdtTb_GetLastEvent(WdtTbInstancePtr) != XWDTTB_NO_BAD_EVENT) {
		/* Disable and disconnect the interrupt system */
		WdtTbDisableIntrSystem(IntcInstancePtr, WdtTbIntrId);

		/* Stop the timer */
		XWdtTb_Stop(WdtTbInstancePtr);
		return XST_FAILURE;
	}

	/* Disable and disconnect the interrupt system */
	WdtTbDisableIntrSystem(IntcInstancePtr, WdtTbIntrId);

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

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function tests the functioning of the Window Watchdog Timer in the
* interrupt mode.
*
* This function waits for interrupt programmed point in second window. If the
* interrupt has occurred, interrupt handler sets a flag and restarts the timer.
* This function then clears the interrupt, flag and waits for second interrupt
* to occur and continue waiting for second interrupt as mentioned above.
*
* This function assumes that the reset output of the Window Watchdog Timer
* is not connected to the reset of the processor. The function allows the
* Window Watchdog Timer to timeout such that a reset will occur if it is
* connected.
*
* @param	IntcInstancePtr is a pointer to the instance of the INTC
*		driver.
* @param	WdtTbInstancePtr is a pointer to the instance of WdtTb driver.
* @param	WdtTbDeviceId is the Device ID of the WdtTb Device and is
*		typically XPAR_<WDTTB_instance>_DEVICE_ID value from
*		xparameters.h.
* @param	WdtTbIntrId is the Interrupt Id of the WatchDog and is
*		typically XPAR_<INTC_instance>_<WDTTB_instance>_WDT_
*		INTERRUPT_VEC_ID value from xparameters.h.
*
* @return
*		- XST_SUCCESS if interrupt example run successfully.
*		- XST_FAILURE, if reset has occurred.
*
* @note		None.
*
******************************************************************************/
This function tests the functioning of the Window Watchdog Timer in the
interrupt mode.

This function waits for interrupt programmed point in second window. If the
interrupt has occurred, interrupt handler sets a flag and restarts the timer.
This function then clears the interrupt, flag and waits for second interrupt
to occur and continue waiting for second interrupt as mentioned above.

This function assumes that the reset output of the Window Watchdog Timer
is not connected to the reset of the processor. The function allows the
Window Watchdog Timer to timeout such that a reset will occur if it is
connected.
This function tests the functioning of the Window Watchdog Timer in the interrupt mode . This function waits for interrupt programmed point in second window . If the interrupt has occurred interrupt handler sets a flag and restarts the timer . This function then clears the interrupt flag and waits for second interrupt to occur and continue waiting for second interrupt as mentioned above . This function assumes that the reset output of the Window Watchdog Timer is not connected to the reset of the processor . The function allows the Window Watchdog Timer to timeout such that a reset will occur if it is connected .
int WinWdtIntrExample(INTC *IntcInstancePtr,
			XWdtTb *WdtTbInstancePtr,
			u16 WdtTbDeviceId,
			u16 WdtTbIntrId)
{
	int Status;
	XWdtTb_Config *Config;
	Config = XWdtTb_LookupConfig(WdtTbDeviceId);
	if (NULL == Config) {
		return XST_FAILURE;
	}
	Status = XWdtTb_CfgInitialize(WdtTbInstancePtr, Config,
				      Config->BaseAddr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	if(!WdtTbInstancePtr->Config.IsPl) {
		XWdtTb_ConfigureWDTMode(WdtTbInstancePtr, XWT_WWDT);
	}
	Status = XWdtTb_SelfTest(WdtTbInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = WdtTbSetupIntrSystem(IntcInstancePtr,
					WdtTbInstancePtr,
					WdtTbIntrId);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XWdtTb_SetRegSpaceAccessMode(WdtTbInstancePtr, 1);
	XWdtTb_SetWindowCount(WdtTbInstancePtr, 0, WIN_WDT_SW_COUNT);
	XWdtTb_SetByteCount(WdtTbInstancePtr, WIN_WDT_SBC_COUNT);
	XWdtTb_SetByteSegment(WdtTbInstancePtr, WIN_WDT_BSS_COUNT);
	XWdtTb_DisableSst(WdtTbInstancePtr);
	XWdtTb_DisablePsm(WdtTbInstancePtr);
	XWdtTb_DisableFailCounter(WdtTbInstancePtr);
	XWdtTb_Start(WdtTbInstancePtr);
	WdtExpired = FALSE;
	XWdtTb_SetRegSpaceAccessMode(WdtTbInstancePtr, 1);
	while (WdtExpired != TRUE);
	XWdtTb_IntrClear(WdtTbInstancePtr);
	WdtExpired = FALSE;
	while (WdtExpired != TRUE);
	XWdtTb_IntrClear(WdtTbInstancePtr);
	WdtExpired = FALSE;
	if (XWdtTb_GetLastEvent(WdtTbInstancePtr) != XWDTTB_NO_BAD_EVENT) {
		WdtTbDisableIntrSystem(IntcInstancePtr, WdtTbIntrId);
		XWdtTb_Stop(WdtTbInstancePtr);
		return XST_FAILURE;
	}
	WdtTbDisableIntrSystem(IntcInstancePtr, WdtTbIntrId);
	XWdtTb_Stop(WdtTbInstancePtr);
	return XST_SUCCESS;
}
int WinWdtIntrExample ( INTC * IntcInstancePtr , XWdtTb * WdtTbInstancePtr , u16 WdtTbDeviceId , u16 WdtTbIntrId ) { int Status ; XWdtTb_Config * Config ; Config = XWdtTb_LookupConfig ( WdtTbDeviceId ) ; if ( NULL == Config ) { return XST_FAILURE ; } Status = XWdtTb_CfgInitialize ( WdtTbInstancePtr , Config , Config -> BaseAddr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } if ( ! WdtTbInstancePtr -> Config . IsPl ) { XWdtTb_ConfigureWDTMode ( WdtTbInstancePtr , XWT_WWDT ) ; } Status = XWdtTb_SelfTest ( WdtTbInstancePtr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = WdtTbSetupIntrSystem ( IntcInstancePtr , WdtTbInstancePtr , WdtTbIntrId ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XWdtTb_SetRegSpaceAccessMode ( WdtTbInstancePtr , 1 ) ; XWdtTb_SetWindowCount ( WdtTbInstancePtr , 0 , WIN_WDT_SW_COUNT ) ; XWdtTb_SetByteCount ( WdtTbInstancePtr , WIN_WDT_SBC_COUNT ) ; XWdtTb_SetByteSegment ( WdtTbInstancePtr , WIN_WDT_BSS_COUNT ) ; XWdtTb_DisableSst ( WdtTbInstancePtr ) ; XWdtTb_DisablePsm ( WdtTbInstancePtr ) ; XWdtTb_DisableFailCounter ( WdtTbInstancePtr ) ; XWdtTb_Start ( WdtTbInstancePtr ) ; WdtExpired = FALSE ; XWdtTb_SetRegSpaceAccessMode ( WdtTbInstancePtr , 1 ) ; while ( WdtExpired != TRUE ) ; XWdtTb_IntrClear ( WdtTbInstancePtr ) ; WdtExpired = FALSE ; while ( WdtExpired != TRUE ) ; XWdtTb_IntrClear ( WdtTbInstancePtr ) ; WdtExpired = FALSE ; if ( XWdtTb_GetLastEvent ( WdtTbInstancePtr ) != XWDTTB_NO_BAD_EVENT ) { WdtTbDisableIntrSystem ( IntcInstancePtr , WdtTbIntrId ) ; XWdtTb_Stop ( WdtTbInstancePtr ) ; return XST_FAILURE ; } WdtTbDisableIntrSystem ( IntcInstancePtr , WdtTbIntrId ) ; XWdtTb_Stop ( WdtTbInstancePtr ) ; return XST_SUCCESS ; }
This function tests the functioning of the Window Watchdog Timer in the
interrupt mode.
This function tests the functioning of the Window Watchdog Timer in the interrupt mode .
/*
	 * 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.
	 */ /*Enable Window Watchdog Feature in WWDT */ /*
	 * Perform a self-test to ensure that the hardware was built correctly
	 */ /*
	 * Connect the WdtTb to the interrupt subsystem so that interrupts
	 * can occur
	 */ /* Set register space to writable */ /* Configure first and second window */ /* Set interrupt position */ /* Disable Secondary Sequence Timer (SST) */ /* Disable Program Sequence Monitor (PSM) */ /* Disable Fail Counter */ /*
	 * Start the watchdog timer as a normal application would
	 */ /* Set register space to writable */ /*
	 * Wait for the first occurrence of interrupt programmed point.
	 */ /* Clear interrupt point */ /* Wait for the second occurrence of interrupt programmed point */ /* Clear interrupt point */ /* Check for last event */ /* Disable and disconnect the interrupt system */ /* Stop the timer */ /* Disable and disconnect the interrupt system */ /* Stop the timer */