/*---------------------------------------------------------------------------*/ void watchdog_reboot(void) { #if WATCHDOG_ENABLED == 1 watchdog_start(); if(MAP_WatchdogLockState(WATCHDOG0_BASE) == true) { MAP_WatchdogUnlock(WATCHDOG0_BASE); } MAP_WatchdogReloadSet(WATCHDOG0_BASE, (MAP_SysCtlClockGet() / 4)); // 250ms while(1); //loop #endif }
void watchdog_init(void) { MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0); delay_us(5); /* * Check to see if the registers are locked, and if so, unlock them. * Locking prevents stray access from modifying register content */ if(MAP_WatchdogLockState(WATCHDOG0_BASE) == true) { MAP_WatchdogUnlock(WATCHDOG0_BASE); } MAP_IntEnable(INT_WATCHDOG); /* Prevent watchdog reset during debugging */ MAP_WatchdogStallEnable(WATCHDOG0_BASE); /* 2 seconds */ MAP_WatchdogReloadSet(WATCHDOG0_BASE, (MAP_SysCtlClockGet() * 2)); MAP_WatchdogResetEnable(WATCHDOG0_BASE); }
/****************************************************************************** * name: * description: * param description: * return value description: ******************************************************************************/ ERROR_CODE ineedmd_watchdog_setup(void) { #ifdef USING_TIRTOS ERROR_CODE eEC = ER_FAIL; Watchdog_Params_init(¶ms); params.resetMode = Watchdog_RESET_OFF; #ifdef DEBUG //For debugging Watchdog counter will stop while stepping through code and reset is disabled // ineedmd_watchdog_debug_mode(); #endif params.callbackFxn = vINMD_watchdog_callback; handle = Watchdog_open(Board_WATCHDOG0, ¶ms); if (!handle) { System_printf("Watchdog did not open"); eEC = ER_FAIL; } else { Watchdog_setReload(handle, WD_BIG_PAT); eEC = ER_OK; } return eEC; #else ERROR_CODE eEC = ER_OK; uint32_t uiWD_shake = 0; MAP_SysCtlPeripheralEnable(WD_PHERF); MAP_SysCtlPeripheralReset(WD_PHERF); eMaster_int_enable(); //Unlock the watchdog // if(MAP_WatchdogLockState(WD_BASE) == true) { MAP_WatchdogUnlock(WD_BASE); } //Enable the Watchdog timer interrupt // MAP_WatchdogIntEnable(WD_BASE); MAP_IntEnable(INT_WATCHDOG); MAP_WatchdogIntClear(WD_BASE); //Set the watchdog default timeout // MAP_WatchdogReloadSet(WD_BASE, WD_PAT); //Enable the watchdog to reset the system // MAP_WatchdogResetEnable(WD_BASE); #ifdef DEBUG //For debugging Watchdog counter will stop while stepping through code and reset is disabled // ineedmd_watchdog_debug_mode(); // MAP_WatchdogResetDisable(WD_BASE); #endif //Finally enable the watchdog // MAP_WatchdogEnable(WD_BASE); //Check to make sure the watchdog is running // uiWD_shake = MAP_WatchdogValueGet(WD_BASE); if(uiWD_shake < WD_PAT) { eEC = ER_OK; } else { eEC = ER_FAIL; } return eEC; #endif //#ifdef USING_TIRTOS }