Skip to content

Commit 1f02f39

Browse files
JordanYateskartben
authored andcommitted
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: Jordan Yates <jordan@embeint.com>
1 parent 8a4fd9b commit 1f02f39

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/watchdog/wdt_cmsdk_apb.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ static int wdog_cmsdk_apb_setup(const struct device *dev, uint8_t options)
8888
ARG_UNUSED(dev);
8989
ARG_UNUSED(options);
9090

91+
/* Reset pending interrupts before starting */
92+
wdog->intclr = CMSDK_APB_WDOG_INTCLR;
93+
wdog->load = reload_cycles;
94+
9195
/* Start the watchdog counter with INTEN bit */
9296
wdog->ctrl = (CMSDK_APB_WDOG_CTRL_RESEN | CMSDK_APB_WDOG_CTRL_INTEN);
9397

0 commit comments

Comments
 (0)