This is an automated email from the ASF dual-hosted git repository.
janc 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 d991f0969 hw/mcu/nrf5340: Conditionally enable watchdog stopping
d991f0969 is described below
commit d991f0969f37641c1e3db5c5f9030dfc1842b237
Author: Szymon Czapracki <[email protected]>
AuthorDate: Fri Jan 30 15:37:44 2026 +0100
hw/mcu/nrf5340: Conditionally enable watchdog stopping
When NRF5340_WDT_STOP is enabled, the watchdog is now able to be
stopped when the CPU enters stop mode.
If the syscfg option is not set,
the watchdog remains configured to run in sleep mode only.
---
hw/bsp/nordic_pca10095_net/syscfg.yml | 4 ++++
hw/mcu/nordic/nrf5340_net/src/hal_watchdog.c | 8 ++++++++
2 files changed, 12 insertions(+)
diff --git a/hw/bsp/nordic_pca10095_net/syscfg.yml
b/hw/bsp/nordic_pca10095_net/syscfg.yml
index 915b502cf..baf349607 100644
--- a/hw/bsp/nordic_pca10095_net/syscfg.yml
+++ b/hw/bsp/nordic_pca10095_net/syscfg.yml
@@ -23,6 +23,10 @@ syscfg.defs:
description: 'Set to indicate that BSP has NRF5340 NET'
value: 1
+ BSP_NRF5340_WDT_STOP:
+ description: 'Enable WDT STOP/STOPEN mode on nRF5340'
+ value: 0
+
COREDUMP_SKIP_UNUSED_HEAP:
description: >
Store whole RAM in crash dump.
diff --git a/hw/mcu/nordic/nrf5340_net/src/hal_watchdog.c
b/hw/mcu/nordic/nrf5340_net/src/hal_watchdog.c
index 3b2489784..cd5da162d 100644
--- a/hw/mcu/nordic/nrf5340_net/src/hal_watchdog.c
+++ b/hw/mcu/nordic/nrf5340_net/src/hal_watchdog.c
@@ -36,6 +36,9 @@ nrf5340_net_wdt_irq_handler(void)
os_trace_isr_enter();
if (NRF_WDT_NS->INTENSET & WDT_INTENSET_TIMEOUT_Msk) {
NRF_WDT_NS->EVENTS_TIMEOUT = 0;
+#if MYNEWT_VAL(BSP_NRF5340_WDT_STOP)
+ NRF_WDT_NS->TASKS_STOP = 1;
+#endif
nrf5340_net_hal_wdt_default_handler();
}
os_trace_isr_exit();
@@ -46,7 +49,12 @@ hal_watchdog_init(uint32_t expire_msecs)
{
uint64_t expiration;
+#if MYNEWT_VAL(BSP_NRF5340_WDT_STOP)
+ NRF_WDT_NS->CONFIG = WDT_CONFIG_SLEEP_Msk | WDT_CONFIG_STOPEN_Msk;
+ NRF_WDT_NS->TSEN = WDT_TSEN_TSEN_Enable;
+#else
NRF_WDT_NS->CONFIG = WDT_CONFIG_SLEEP_Msk;
+#endif
/* Convert msec timeout to counts of a 32768 crystal */
expiration = ((uint64_t)expire_msecs * 32768) / 1000;