/* Sets the WatchDog Timer Control register to the  */
static void wdt_set_ctrl(uint32_t ctrl)
/* Sets the WatchDog Timer Control register to the  */
static void wdt_set_ctrl(uint32_t ctrl)
{
	volatile uint32_t dly;
	if ((WDT->WDT_CTRL & WDT_CTRL_CSSEL) == WDT_CLK_SRC_RCSYS) {
		dly = div_ceil(sysclk_get_cpu_hz() * 2, OSC_RCSYS_NOMINAL_HZ);
	} else {
		dly = div_ceil(sysclk_get_cpu_hz() * 2, OSC_RC32K_NOMINAL_HZ);
	}
	dly >>= 3;
	while(dly--);
	WDT->WDT_CTRL = ctrl | WDT_CTRL_KEY(WDT_FIRST_KEY);
	WDT->WDT_CTRL = ctrl | WDT_CTRL_KEY(WDT_SECOND_KEY);
}