Пример #1
0
void
mcu_watchdog_enable (void)
{
    /* Enable watchdog with 2s timeout.  */
    WDT->WDT_MR = WDT_MR_WDD(0x200) | WDT_MR_WDRSTEN | WDT_MR_WDDBGHLT;
    mcu_watchdog_reset ();
}
Пример #2
0
void watchdogEnable (uint32_t timeout)
{
	/* this assumes the slow clock is running at 32.768 kHz
	   watchdog frequency is therefore 32768 / 128 = 256 Hz */
	timeout = timeout * 256 / 1000; 
	if (timeout == 0)
		timeout = 1;
	else if (timeout > 0xFFF)
		timeout = 0xFFF;
	timeout = WDT_MR_WDRSTEN | WDT_MR_WDV(timeout) | WDT_MR_WDD(timeout);
	WDT_Enable (WDT, timeout);
}
Пример #3
0
// Configures the watchdog timer to 16s (can only be called once).
void wdt_start(void) {
	if(wdt_has_error()) {
		// If there is an error in the wdt status register the watchdog
		// timer reached 0 since last call of start
		wdt_counter++;
	}

	WDT->WDT_MR = WDT_MR_WDV(WDT_TIMEOUT_16S) |
	              WDT_MR_WDD(WDT_TIMEOUT_16S) |
	              WDT_MR_WDFIEN |
	              WDT_MR_WDRSTEN |
	              WDT_MR_WDDBGHLT |
	              WDT_MR_WDIDLEHLT;
}
Пример #4
0
void
watchdog_init(void)
{
    uint32_t timeout = 500 * 32768 / 128 / 1000;  // 500ms timeout
    WDT->WDT_MR = WDT_MR_WDRSTEN | WDT_MR_WDV(timeout) | WDT_MR_WDD(timeout);
}
Пример #5
0
/**
 * \brief Initialize watchdog timer with the given mode.
 *
 * \param p_wdt Pointer to a WDT instance.
 * \param ul_mode Bitmask of watchdog timer mode.
 * \param us_counter The value loaded in the 12-bit Watchdog Counter.
 * \param us_delta The permitted range for reloading the Watchdog Timer.
 */
void wdt_init(Wdt *p_wdt, uint32_t ul_mode, uint16_t us_counter,
              uint16_t us_delta)
{
    p_wdt->WDT_MR = ul_mode |
                    WDT_MR_WDV(us_counter) | WDT_MR_WDD(us_delta);
}