示例#1
0
文件: wdt_if.c 项目: ArunBoddu/CC3200
//****************************************************************************
//
//! 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);

}
示例#2
0
/*---------------------------------------------------------------------------*/
void
watchdog_start(void)
{
#if WATCHDOG_ENABLED == 1
		/* Start the watchdog */
		MAP_WatchdogEnable(WATCHDOG0_BASE);
		/* Prevent unwanted watchdog register changes */
		MAP_WatchdogLock(WATCHDOG0_BASE);
#endif  
}
示例#3
0
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();
}
示例#4
0
//*****************************************************************************
//
//!	main function demonstrates the use of the watchdog timer to perform system
//! reset.
//!
//! \param  None
//!
//! \return None
//
//*****************************************************************************
void main(void)
{
    tBoolean bRetcode;
    //
    // Initialize the board
    //
    BoardInit();
    //
    // Pinmuxing for LEDs
    //
    PinMuxConfig();
    //
    // configure RED LED
    //
    GPIO_IF_LedConfigure(LED1);

	GPIO_IF_LedOff(MCU_RED_LED_GPIO);

    //
    // Enable the peripherals used by this example.
    //
    MAP_PRCMPeripheralClkEnable(PRCM_WDT, PRCM_RUN_MODE_CLK);

    //
    // Set up the watchdog interrupt handler.
    //
    WDT_IF_Init(WatchdogIntHandler, MILLISECONDS_TO_TICKS(WD_PERIOD_MS));
    
    //
    // Start the timer. Once the timer is started, it cannot be disable.
    //
    MAP_WatchdogEnable(WDT_BASE);
    bRetcode = MAP_WatchdogRunning(WDT_BASE);
    if(!bRetcode)
    {
       WDT_IF_DeInit();
    }

    //
    // Loop forever while the LED winks as watchdog interrupts are handled.
    //
    while(FOREVER)
    {

    }
}
示例#5
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;
}
示例#6
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;
}
示例#7
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
}