This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new ca6ba0ebb hw/mcu: Improve watchdog handling on LPC55xx
ca6ba0ebb is described below
commit ca6ba0ebb1def03dd019303851d96970b426883f
Author: Wiktor Kwiatkowski <[email protected]>
AuthorDate: Mon Aug 11 10:45:44 2025 +0200
hw/mcu: Improve watchdog handling on LPC55xx
Added watchdog reset on timeout instead of interrupt as before.
Implemented proper conversion from milliseconds to watchdog
register value (fixed incorrect *1000 scaling).
Added static assertion to ensure watchdog interval does not
exceed hardware limits.
---
hw/mcu/nxp/lpc55xx/src/hal_watchdog.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/hw/mcu/nxp/lpc55xx/src/hal_watchdog.c
b/hw/mcu/nxp/lpc55xx/src/hal_watchdog.c
index 3e4b77509..baa78a9af 100644
--- a/hw/mcu/nxp/lpc55xx/src/hal_watchdog.c
+++ b/hw/mcu/nxp/lpc55xx/src/hal_watchdog.c
@@ -21,10 +21,13 @@
#include <fsl_wwdt.h>
-#ifndef WATCHDOG_STUB
+#if MYNEWT_VAL(WATCHDOG_INTERVAL) > 0
+_Static_assert(((1ULL << 24) * 4 * 1000) / 1000000 >=
MYNEWT_VAL(WATCHDOG_INTERVAL),
+ "Watchdog interval out of range, decrease value
WATCHDOG_INTERVAL in syscfg.yml");
#endif
-int hal_watchdog_init(uint32_t expire_msecs)
+int
+hal_watchdog_init(uint32_t expire_msecs)
{
#ifndef WATCHDOG_STUB
wwdt_config_t config;
@@ -34,21 +37,26 @@ int hal_watchdog_init(uint32_t expire_msecs)
WWDT_GetDefaultConfig(&config);
config.clockFreq_Hz = 1000000;
- config.timeoutValue = expire_msecs * 1000;
+ config.enableWatchdogReset = true;
+ /* Convert timeout from milliseconds to watchdog timer ticks
+ * (1 tick = 4 us due to fixed prescaler of 4) */
+ config.timeoutValue = expire_msecs * 250;
WWDT_Init(WWDT, &config);
#endif
return 0;
}
-void hal_watchdog_enable(void)
+void
+hal_watchdog_enable(void)
{
#ifndef WATCHDOG_STUB
WWDT_Enable(WWDT);
#endif
}
-void hal_watchdog_tickle(void)
+void
+hal_watchdog_tickle(void)
{
#ifndef WATCHDOG_STUB
WWDT_Refresh(WWDT);