From 61916c69dda8c5cf9d9ed1ac4a6778e26a06b441 Mon Sep 17 00:00:00 2001 From: Marcin Jabrzyk Date: Tue, 11 Oct 2022 20:56:54 +0200 Subject: [PATCH] drivers: watchdog: Fix RP2040 watchdog load time RP2040 requires watchdog load time in us, but Zephyr watchdog window values are in ms. Make sure that it is adjusted to hardware requirements. Signed-off-by: Marcin Jabrzyk --- drivers/watchdog/wdt_rpi_pico.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/wdt_rpi_pico.c b/drivers/watchdog/wdt_rpi_pico.c index 4f82627b5e8..83285ba659e 100644 --- a/drivers/watchdog/wdt_rpi_pico.c +++ b/drivers/watchdog/wdt_rpi_pico.c @@ -9,6 +9,7 @@ #include #include #include +#include #include LOG_MODULE_REGISTER(wdt_rpi_pico, CONFIG_WDT_LOG_LEVEL); @@ -101,7 +102,7 @@ static int wdt_rpi_pico_install_timeout(const struct device *dev, const struct w if (cfg->window.min != 0U || cfg->window.max == 0U) { return -EINVAL; - } else if (cfg->window.max > RPI_PICO_MAX_WDT_TIME) { + } else if (cfg->window.max * USEC_PER_MSEC > RPI_PICO_MAX_WDT_TIME) { return -EINVAL; } else if (cfg->callback != NULL) { return -ENOTSUP; @@ -113,7 +114,7 @@ static int wdt_rpi_pico_install_timeout(const struct device *dev, const struct w return -EINVAL; } - data->load = (cfg->window.max * RPI_PICO_WDT_TIME_MULTIPLICATION_FACTOR); + data->load = (cfg->window.max * USEC_PER_MSEC * RPI_PICO_WDT_TIME_MULTIPLICATION_FACTOR); data->reset_type = (cfg->flags & WDT_FLAG_RESET_MASK); return 0;