/* * ======== 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(); }
//***************************************************************************** // //! \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"); } }