Example #1
0
//****************************************************************************
//
//! Initialize the watchdog timer
//!
//! \param fpAppWDTCB is the WDT interrupt handler to be registered
//! \param uiReloadVal is the reload value to be set to the WDT
//! 
//! This function  
//!        1. Initializes the WDT
//!
//! \return None.
//
//****************************************************************************
void WDT_IF_Init(fAPPWDTDevCallbk fpAppWDTCB,
                   unsigned int uiReloadVal)
{
    //
    // Enable the peripherals used by this example.
    //
    MAP_PRCMPeripheralClkEnable(PRCM_WDT, PRCM_RUN_MODE_CLK);

    //
    // Unlock to be able to configure the registers
    //
    MAP_WatchdogUnlock(WDT_BASE);

    if(fpAppWDTCB != NULL)
    {
#ifdef USE_TIRTOS
        osi_InterruptRegister(INT_WDT, fpAppWDTCB, INT_PRIORITY_LVL_1);
#else
        MAP_WatchdogIntRegister(WDT_BASE,fpAppWDTCB);
#endif
    }

    //
    // Set the watchdog timer reload value
    //
    MAP_WatchdogReloadSet(WDT_BASE,uiReloadVal);

    //
    // Start the timer. Once the timer is started, it cannot be disable.
    //
    MAP_WatchdogEnable(WDT_BASE);

}
Example #2
0
void Watchdog::stop() {
  MAP_WatchdogUnlock(WDT_BASE);

  MAP_WatchdogIntClear(WDT_BASE);

  MAP_WatchdogIntUnregister(WDT_BASE);

  Thread::stop();
}
Example #3
0
/*---------------------------------------------------------------------------*/
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
}
Example #4
0
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;
}
Example #5
0
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);
}
Example #6
0
//****************************************************************************
//
//! DeInitialize the watchdog timer
//!
//! \param None
//! 
//! This function  
//!        1. DeInitializes the WDT
//!
//! \return None.
//
//****************************************************************************
void WDT_IF_DeInit()
{
    //
    // Unlock to be able to configure the registers
    //
    MAP_WatchdogUnlock(WDT_BASE);

    //
    // Disable stalling of the watchdog timer during debug events
    //
    MAP_WatchdogStallDisable(WDT_BASE);

    //
    // Clear the interrupt
    //
    MAP_WatchdogIntClear(WDT_BASE);

    //
    // Unregister the interrupt
    //
    MAP_WatchdogIntUnregister(WDT_BASE);
}
Example #7
0
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;
}
Example #8
0
/******************************************************************************
* name:
* description:
* param description:
* return value description:
******************************************************************************/
ERROR_CODE ineedmd_watchdog_setup(void)
{
#ifdef USING_TIRTOS
  ERROR_CODE eEC = ER_FAIL;

  Watchdog_Params_init(&params);
  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, &params);
  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
}