ERROR_CODE ineedmd_watchdog_debug_mode(void) { #ifdef USING_TIRTOS ERROR_CODE eEC = ER_OK; params.debugStallMode = Watchdog_DEBUG_STALL_ON; return eEC; #else ERROR_CODE eEC = ER_OK; MAP_WatchdogStallEnable(WD_BASE); //todo: see if wd reg changes with the rom call and can be measured return eEC; #endif }
void hw_watchdog_init() { // Startup watchdog timer MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0); MAP_WatchdogReloadSet(WATCHDOG0_BASE, MAP_SysCtlClockGet() * 8); // 8s MAP_WatchdogResetEnable(WATCHDOG0_BASE); #ifdef DEBUG MAP_WatchdogStallEnable(WATCHDOG0_BASE); #endif // DEBUG MAP_IntEnable(INT_WATCHDOG); MAP_WatchdogEnable(WATCHDOG0_BASE); // can not be disabled hw_watchdog_clear(); }
STATIC mp_obj_t pyb_wdt_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { // check the arguments mp_map_t kw_args; mp_map_init_fixed_table(&kw_args, n_kw, all_args + n_args); mp_arg_val_t args[MP_ARRAY_SIZE(pyb_wdt_init_args)]; mp_arg_parse_all(n_args, all_args, &kw_args, MP_ARRAY_SIZE(args), pyb_wdt_init_args, args); if (args[0].u_obj != mp_const_none && mp_obj_get_int(args[0].u_obj) > 0) { mp_raise_msg(&mp_type_OSError, mpexception_os_resource_not_avaliable); } uint timeout_ms = args[1].u_int; if (timeout_ms < PYBWDT_MIN_TIMEOUT_MS) { mp_raise_ValueError(mpexception_value_invalid_arguments); } if (pyb_wdt_obj.running) { mp_raise_msg(&mp_type_OSError, mpexception_os_request_not_possible); } // Enable the WDT peripheral clock MAP_PRCMPeripheralClkEnable(PRCM_WDT, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK); // Unlock to be able to configure the registers MAP_WatchdogUnlock(WDT_BASE); #ifdef DEBUG // make the WDT stall when the debugger stops on a breakpoint MAP_WatchdogStallEnable (WDT_BASE); #endif // set the watchdog timer reload value // the WDT trigger a system reset after the second timeout // so, divide by 2 the timeout value received MAP_WatchdogReloadSet(WDT_BASE, PYBWDT_MILLISECONDS_TO_TICKS(timeout_ms / 2)); // start the timer. Once it's started, it cannot be disabled. MAP_WatchdogEnable(WDT_BASE); pyb_wdt_obj.base.type = &pyb_wdt_type; pyb_wdt_obj.running = true; return (mp_obj_t)&pyb_wdt_obj; }
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); }
Thread::Error Watchdog::start() { MAP_PRCMPeripheralClkEnable(PRCM_WDT, PRCM_RUN_MODE_CLK); MAP_WatchdogUnlock(WDT_BASE); MAP_WatchdogStallEnable(WDT_BASE); MAP_IntPrioritySet(INT_WDT, INT_PRIORITY_LVL_1); MAP_WatchdogIntRegister(WDT_BASE, isr); MAP_WatchdogReloadSet(WDT_BASE, 240000000UL); MAP_WatchdogEnable(WDT_BASE); Thread::Error err = Thread::start(); if (err != Thread::kOK) stop(); return err; }