Commit 1f02f39b authored by Jordan Yates's avatar Jordan Yates Committed by Benjamin Cabé
Browse files

watchdog: cmsdk_apb: reset state before starting

Reset the watchdog back to the initial state before enabling the
expiry interrupt. This prevents the watchdog expiring immediately if
there is a long gap between `wdt_install_timeout` and `wdt_setup`.

Signed-off-by: default avatarJordan Yates <jordan@embeint.com>
parent 8a4fd9bb
Loading
Loading
Loading
Loading
+4 −0
Changes for drivers/watchdog/wdt_cmsdk_apb.c: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -88,6 +88,10 @@ static int wdog_cmsdk_apb_setup(const struct device *dev, uint8_t options)
	ARG_UNUSED(dev);
	ARG_UNUSED(options);

	/* Reset pending interrupts before starting */
	wdog->intclr = CMSDK_APB_WDOG_INTCLR;
	wdog->load = reload_cycles;

	/* Start the watchdog counter with INTEN bit */
	wdog->ctrl = (CMSDK_APB_WDOG_CTRL_RESEN | CMSDK_APB_WDOG_CTRL_INTEN);