XilinxProcessorIPLib/drivers/wdttb/examples/xwdttb_gwdt_example.c
int GWdtTbExample(u16 DeviceId)
{
        int Status;
        int RefreshReg=0;
        XWdtTb_Config *Config;

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

        /*
         * Initialize the watchdog timer  driver so that
         * it is ready to use.
         */
        Status = XWdtTb_CfgInitialize(&GWatchdog, 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(&GWatchdog);
        if (Status != XST_SUCCESS)
        {
                return XST_FAILURE;
        }
        xil_printf("\nSelf test completed \n\r");

        /* Update GWOR Register */
        XWdtTb_SetGenericWdtWindow(&GWatchdog, WDTPSV_GWOR_COUNT);

        /*
         * Start the watchdog timer, the General Watchdog  is automatically reset
         * when this occurs.
         */
        XWdtTb_Start(&GWatchdog);

        /*
         * Verify Whether the Generic WatchDog Refresh Status has been set in the next two
         * expire state.
         */
        while (1) {
                xil_printf(".");
                /* Refresh  General Watchdog timer if generic_wdt_interrupt occurred */
                if(RefreshReg<=2)
                {
                        if(XWdtTb_IsGenericWdtFWExpired(&GWatchdog))
                        {
                                XWdtTb_RestartWdt(&GWatchdog);
                        RefreshReg++;
                        xil_printf("\n Refresh kick%d\n\r",RefreshReg);
                        }
                }
                /*
                 * If the watchdog timer expired, then restart it.
                 */
                if (XWdtTb_IsWdtExpired(&GWatchdog))
                {

                        xil_printf("\n\rGeneric watchdog second window expired\n\r");
                        XWdtTb_Stop(&GWatchdog);
                        break;
                }

        }

        return XST_SUCCESS;
}
/*****************************************************************************/
/**
 *This function tests the functioning of the Generic watch dog Timer Feature
 * in Polled mode
 * In this function polls up to First window completion, once we reached to
 * generic_wdt_interrupt  point it will Refresh.
 * In this function once we reach to Second window time out point
 * It means generating generic_wdt_reset ,We are going to Refresh.
 *
 * @param        DeviceId is the XPAR_<WDTPSV_instance>_DEVICE_ID value from
 *                xparameters.h.
 * @return
 *               - XST_SUCCESS, in window, there is no bad event.
 *               - XST_FAILURE, otherwise.
 *
 * @note         None.
 *
 ****************************************************************************/
This function tests the functioning of the Generic watch dog Timer Feature
in Polled mode
In this function polls up to First window completion, once we reached to
generic_wdt_interrupt  point it will Refresh.
In this function once we reach to Second window time out point
It means generating generic_wdt_reset ,We are going to Refresh.

@param        DeviceId is the XPAR__DEVICE_ID value from
xparameters.h.
@return
- XST_SUCCESS, in window, there is no bad event.

@note         None.
This function tests the functioning of the Generic watch dog Timer Feature in Polled mode In this function polls up to First window completion once we reached to generic_wdt_interrupt point it will Refresh . In this function once we reach to Second window time out point It means generating generic_wdt_reset We are going to Refresh . @param DeviceId is the XPAR__DEVICE_ID value from xparameters . h . @return - XST_SUCCESS in window there is no bad event . @note None .
int GWdtTbExample(u16 DeviceId)
{
        int Status;
        int RefreshReg=0;
        XWdtTb_Config *Config;
        Config = XWdtTb_LookupConfig(DeviceId);
        if (NULL == Config) {
                return XST_FAILURE;
        }
        Status = XWdtTb_CfgInitialize(&GWatchdog, Config,
                        Config->BaseAddr);
        if (Status != XST_SUCCESS)
        {
                return XST_FAILURE;
        }
        Status = XWdtTb_SelfTest(&GWatchdog);
        if (Status != XST_SUCCESS)
        {
                return XST_FAILURE;
        }
        xil_printf("\nSelf test completed \n\r");
        XWdtTb_SetGenericWdtWindow(&GWatchdog, WDTPSV_GWOR_COUNT);
        XWdtTb_Start(&GWatchdog);
        while (1) {
                xil_printf(".");
                if(RefreshReg<=2)
                {
                        if(XWdtTb_IsGenericWdtFWExpired(&GWatchdog))
                        {
                                XWdtTb_RestartWdt(&GWatchdog);
                        RefreshReg++;
                        xil_printf("\n Refresh kick%d\n\r",RefreshReg);
                        }
                }
                if (XWdtTb_IsWdtExpired(&GWatchdog))
                {
                        xil_printf("\n\rGeneric watchdog second window expired\n\r");
                        XWdtTb_Stop(&GWatchdog);
                        break;
                }
        }
        return XST_SUCCESS;
}
int GWdtTbExample ( u16 DeviceId ) { int Status ; int RefreshReg = 0 ; XWdtTb_Config * Config ; Config = XWdtTb_LookupConfig ( DeviceId ) ; if ( NULL == Config ) { return XST_FAILURE ; } Status = XWdtTb_CfgInitialize ( & GWatchdog , Config , Config -> BaseAddr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = XWdtTb_SelfTest ( & GWatchdog ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } xil_printf ( " \n \n \r " ) ; XWdtTb_SetGenericWdtWindow ( & GWatchdog , WDTPSV_GWOR_COUNT ) ; XWdtTb_Start ( & GWatchdog ) ; while ( 1 ) { xil_printf ( " " ) ; if ( RefreshReg <= 2 ) { if ( XWdtTb_IsGenericWdtFWExpired ( & GWatchdog ) ) { XWdtTb_RestartWdt ( & GWatchdog ) ; RefreshReg ++ ; xil_printf ( " \n \n \r " , RefreshReg ) ; } } if ( XWdtTb_IsWdtExpired ( & GWatchdog ) ) { xil_printf ( " \n \r \n \r " ) ; XWdtTb_Stop ( & GWatchdog ) ; break ; } } return XST_SUCCESS ; }
This function tests the functioning of the Generic watch dog Timer Feature
 in Polled mode
 In this function polls up to First window completion, once we reached to
 generic_wdt_interrupt  point it will Refresh.
This function tests the functioning of the Generic watch dog Timer Feature in Polled mode In this function polls up to First window completion once we reached to generic_wdt_interrupt point it will Refresh .
/*
         * Initialize the WDTPSV driver so that it's ready to use look up
         * configuration in the config table, then initialize it.
         */ /*
         * Initialize the watchdog timer  driver so that
         * it is ready to use.
         */ /*
         * Perform a self-test to ensure that the hardware was built
         * correctly
         */ /* Update GWOR Register */ /*
         * Start the watchdog timer, the General Watchdog  is automatically reset
         * when this occurs.
         */ /*
         * Verify Whether the Generic WatchDog Refresh Status has been set in the next two
         * expire state.
         */ /* Refresh  General Watchdog timer if generic_wdt_interrupt occurred */ /*
                 * If the watchdog timer expired, then restart it.
                 */