/*
 *  ======== WatchdogCC26XX_setReload ========
 */
void WatchdogCC26XX_setReload(Watchdog_Handle handle, uint32_t value)
{
    WatchdogCC26XX_Object        *object;

    /* get the pointer to the object and hwAttrs */
    object = handle->object;

    /* udpate the watchdog object with the new reload value */
    object->reloadValue = value;

    /* unlock the Watchdog configuration registers */
    WatchdogUnlock();

    /* make sure the Watchdog is unlocked before continuing */
    while(WatchdogLockState() == WATCHDOG_LOCK_LOCKED)
    { }

    /* update the reload value */
    WatchdogReloadSet(object->reloadValue);

    /* lock register access */
    WatchdogLock();

    Log_print2(Diags_USER1, "Watchdog: WDT with handle 0x%x has been set to "
               "reload to 0x%x", (UArg)handle, value);
}
Пример #2
0
/*
 * trigger HW-watchdog -> must be done periodically with less than "intervalMilliseconds" ms
 */
void hwTriggerWatchdog() {
	//if (WatchdogIntStatus(WATCHDOG_BASE,false)){ // check raw interrupt status
	//	xprintf("WD interrupt\n");
		WatchdogIntClear(WATCHDOG_BASE);
	//}

	WatchdogUnlock(WATCHDOG_BASE);			// unlock WD register
	WatchdogReloadSet(WATCHDOG_BASE,glWDLoad);
	WatchdogLock(WATCHDOG_BASE);			// lock WD register
}
/*
 *  ======== WatchdogCC26XX_hwInit ========
 *  This functions initializes the Watchdog hardware module.
 *
 *  @pre    Function assumes that the Watchdog handle is pointing to a hardware
 *          module which has already been opened.
 */
static void WatchdogCC26XX_initHw(Watchdog_Handle handle) {
    WatchdogCC26XX_Object        *object;

    /* get the pointer to the object and hwAttrs */
    object = handle->object;

    /* unlock the Watchdog configuration registers */
    WatchdogUnlock();

    /* make sure the Watchdog is unlocked before continuing */
    while(WatchdogLockState() == WATCHDOG_LOCK_LOCKED)
    { }

    WatchdogReloadSet(object->reloadValue);

#ifndef CCWARE
    /* set reset mode */
    if (object->resetMode == Watchdog_RESET_ON) {
        WatchdogResetEnable();
    }
    else {
        WatchdogResetDisable();
    }
#endif

    /* set debug stall mode */
    if (object->debugStallMode == Watchdog_DEBUG_STALL_ON) {
        WatchdogStallEnable();
    }
    else {
        WatchdogStallDisable();
    }

    /* enable the Watchdog interrupt as a non-maskable interrupt */
    WatchdogIntTypeSet(WATCHDOG_INT_TYPE_NMI);

    /* enable interrupts */
    WatchdogIntEnable();

    /* enable the Watchdog */
    WatchdogEnable();

    /* lock the Watchdog configuration registers */
    WatchdogLock();
}
Пример #4
0
void hwInitWatchdog(long intervalMilliseconds) {
	if (SysCtlPeripheralPresent(SYSCTL_PERIPH_WDOG)){
		SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG);

		WatchdogUnlock(WATCHDOG_BASE);			// unlock WD register

		WatchdogResetEnable(WATCHDOG_BASE);		// enable reset capability on second timeout
		/* watchdog resets the system on the second timeout!
		 * -> so we have to divide the time by 2
		 * -> on the first time-out only an interrupt is generated
		 */
		glWDLoad = (SysCtlClockGet()/1000) * (intervalMilliseconds/2);
		WatchdogReloadSet(WATCHDOG_BASE, glWDLoad);
		WatchdogStallEnable(WATCHDOG_BASE); 	// stops the watchdog during debug break
		WatchdogIntUnregister(WATCHDOG_BASE); 	// mask interrupt -> interrupts are not seen and handled by processor
		WatchdogEnable(WATCHDOG_BASE);

		WatchdogLock(WATCHDOG_BASE);			// lock WD register
	}
}
Пример #5
0
//*****************************************************************************
//
//! \brief xwdt001 test execute main body.
//!
//! \return None.
//
//*****************************************************************************
static void xwdt001Execute(void)
{
    unsigned long i       = 0;
    unsigned long tmp     = 0;
    unsigned long WdtBase = 0;

    //
    // Reset Enable/Disable Test
    //
    for(i = 0; i < WDT_NUM; i++)
    {
        WdtBase = WdtBaseTbl[i];

        //
        // Reset Enable Test
        //
        if(WdtBase == WATCHDOG1_BASE)
        {
            Watchdog1WriteSync();
        }
        WatchdogResetEnable(WdtBase);
        tmp = xHWREG(WdtBase + WDT_O_CTL) & WDT_CTL_RESEN;
        TestAssert((0 != tmp),
                "WDT Test 001: Res%set Enable Failed");

        //
        // Reset Disable Test
        //

        if(WdtBase == WATCHDOG1_BASE)
        {
            Watchdog1WriteSync();
        }
        WatchdogResetDisable(WdtBase);
        tmp = xHWREG(WdtBase + WDT_O_CTL) & WDT_CTL_RESEN;
        TestAssert((0 == tmp),
                "WDT Test 001: Reset Disable Failed");
    }

    //
    // Lock/Unlock/GetState Test
    //
    for(i = 0; i < WDT_NUM; i++)
    {
        WdtBase = WdtBaseTbl[i];

        //
        // Lock Test
        //
        if(WdtBase == WATCHDOG1_BASE)
        {
            Watchdog1WriteSync();
        }
        WatchdogLock(WdtBase);
        tmp = xHWREG(WdtBase + WDT_O_LOCK);
        TestAssert((tmp == WDT_LOCK_LOCKED),
                "WDT Test 001: Lock Failed");

        //
        // Get Lock State Test
        //
        tmp = WatchdogLockState(WdtBase);
        TestAssert((tmp == xtrue),
                "WDT Test 001: Get Lock State Failed");

        //
        // Unlock Test
        //
        if(WdtBase == WATCHDOG1_BASE)
        {
            Watchdog1WriteSync();
        }
        WatchdogUnlock(WdtBase);
        tmp = xHWREG(WdtBase + WDT_O_LOCK);
        TestAssert((tmp == WDT_LOCK_UNLOCKED),
                "WDT Test 001: Unlock Failed");

        //
        // Get Lock State Test
        //
        tmp = WatchdogLockState(WdtBase);
        TestAssert((tmp == xfalse),
                "WDT Test 001: Get Lock State Failed");
    }


    //
    // Reload Set/Get Test
    //

    for(i = 0; i < 1; i++)
    {
        unsigned long j       = 0;
        unsigned long TblSize = 0;

        WdtBase = WdtBaseTbl[i];
        TblSize = sizeof(ReloadValueTbl) / sizeof(ReloadValueTbl[0]);
        for(j = 0; j < TblSize; j++)
        {
            //
            // Reload Set Test
            //
            if(WdtBase == WATCHDOG1_BASE)
            {
                Watchdog1WriteSync();
            }
            WatchdogReloadSet(WdtBase, ReloadValueTbl[j]);

            tmp = xHWREG(WdtBase + WDT_O_LOAD);
            TestAssert((ReloadValueTbl[j] == tmp),
                    "WDT Test 001: Wdt Reload Set Failed");

            //
            // Reload Get Test
            //
            tmp = WatchdogReloadGet(WdtBase);
            TestAssert((ReloadValueTbl[j] == tmp),
                    "WDT Test 001: Wdt Reload Get Failed");
        }
    }

    //
    // Stall Enable/Disable Test
    //
    for(i = 0; i < WDT_NUM; i++)
    {
        WdtBase = WdtBaseTbl[i];
        //
        // Stall Enable Test
        //
        if(WdtBase == WATCHDOG1_BASE)
        {
            Watchdog1WriteSync();
        }
        WatchdogStallEnable(WdtBase);
        tmp = xHWREG(WdtBase + WDT_O_TEST) & WDT_TEST_STALL;
        TestAssert((0 != tmp),
                "WDT Test 001: Stall Enable Failed");

        //
        // Stall Disable Test
        //
        if(WdtBase == WATCHDOG1_BASE)
        {
            Watchdog1WriteSync();
        }
        WatchdogStallDisable(WdtBase);
        tmp = xHWREG(WdtBase + WDT_O_TEST) & WDT_TEST_STALL;
        TestAssert((0 == tmp),
                "WDT Test 001: Stall Disable Failed");
    }

    //
    // Enable/Running Test
    //
    for(i = 0; i < WDT_NUM; i++)
    {
        WdtBase = WdtBaseTbl[i];
        //
        // Enable Test
        //
        WatchdogEnable(WdtBase);
        tmp = xHWREG(WdtBase + WDT_O_CTL) & WDT_CTL_INTEN;
        TestAssert((0 != tmp),
                "WDT Test 001: Enable Failed");

        //
        // IsRunning Test
        //
        tmp = WatchdogRunning(WdtBase);
        TestAssert((0 != tmp),
                "WDT Test 001: IsRunning Failed");
    }

}