/* * ======== WatchdogCC26XX_open ======== */ Watchdog_Handle WatchdogCC26XX_open(Watchdog_Handle handle, Watchdog_Params *params) { unsigned int key; Hwi_Params hwiParams; Watchdog_Params watchdogParams; WatchdogCC26XX_HWAttrs const *hwAttrs; WatchdogCC26XX_Object *object; Types_FreqHz freq; /* get the pointer to the object and hwAttrs */ object = handle->object; hwAttrs = handle->hwAttrs; /* disable preemption while checking if the WatchDog is open. */ key = Hwi_disable(); /* Check if the Watchdog is open already with the HWAttrs */ if (object->isOpen == true) { Hwi_restore(key); Log_warning1("Watchdog: Handle %x already in use.", (UArg)handle); return (NULL); } object->isOpen = true; Hwi_restore(key); /* if params are NULL use defaults. */ if (params == NULL) { Watchdog_Params_init(&watchdogParams); params = &watchdogParams; } /* initialize the Watchdog object */ object->debugStallMode = params->debugStallMode; object->resetMode = params->resetMode; /* 1 second period at default CPU clock frequency */ BIOS_getCpuFreq(&freq); object->reloadValue = freq.lo/2; /* Construct Hwi object for Watchdog */ Hwi_Params_init(&hwiParams); hwiParams.arg = (UArg)handle; /* setup callback function if defined */ if (params->callbackFxn != NULL) { Hwi_construct(&(object->hwi), hwAttrs->intNum, params->callbackFxn, &hwiParams, NULL); } /* initialize the watchdog hardware */ // WatchdogIntClear(); WatchdogCC26XX_initHw(handle); Log_print1(Diags_USER1, "Watchdog: handle %x opened" ,(UArg)handle); /* register notification functions */ Power_registerNotify(&object->watchdogPreObj, PowerCC26XX_ENTERING_STANDBY, (Fxn)watchdogPreNotify, (uint32_t)handle); Power_registerNotify(&object->watchdogPostObj, PowerCC26XX_AWAKE_STANDBY, (Fxn)watchdogPostNotify, (uint32_t)handle); /* return handle of the Watchdog object */ return (handle); }
/****************************************************************************** * 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 }