aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-08-08 23:20:47 +0200
committerGitHub <[email protected]>2025-08-08 23:20:47 +0200
commit1f19430f2ebda4d686057a854f6b74b8643cd56b (patch)
tree6e3669596380599c38535a3da7a403b178028abb
parent68b2c1fb4b39115800e82c0b26d736e13c8711dc (diff)
parent3a6d927ed5a85fd2381d7896455265b5cd24c42d (diff)
Merge pull request #4518 from nerwalt/nrf54l15-wdt
Adds WDT support for the nrf54l15
-rw-r--r--embassy-nrf/Cargo.toml2
-rw-r--r--embassy-nrf/src/chips/nrf54l15_app.rs15
-rw-r--r--embassy-nrf/src/lib.rs1
-rw-r--r--embassy-nrf/src/wdt.rs8
-rw-r--r--examples/nrf54l15/src/bin/wdt.rs42
5 files changed, 62 insertions, 6 deletions
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml
index 95ec83824..92378db0b 100644
--- a/embassy-nrf/Cargo.toml
+++ b/embassy-nrf/Cargo.toml
@@ -88,7 +88,7 @@ nrf5340-app-ns = ["_nrf5340-app", "_ns"]
88## nRF5340 network core 88## nRF5340 network core
89nrf5340-net = ["_nrf5340-net"] 89nrf5340-net = ["_nrf5340-net"]
90## nRF54L15 application core in Secure mode 90## nRF54L15 application core in Secure mode
91nrf54l15-app-s = ["_nrf54l15-app", "_s"] 91nrf54l15-app-s = ["_nrf54l15-app", "_s", "_multi_wdt"]
92## nRF54L15 application core in Non-Secure mode 92## nRF54L15 application core in Non-Secure mode
93nrf54l15-app-ns = ["_nrf54l15-app", "_ns"] 93nrf54l15-app-ns = ["_nrf54l15-app", "_ns"]
94 94
diff --git a/embassy-nrf/src/chips/nrf54l15_app.rs b/embassy-nrf/src/chips/nrf54l15_app.rs
index 3a4e1ae4a..2bc346092 100644
--- a/embassy-nrf/src/chips/nrf54l15_app.rs
+++ b/embassy-nrf/src/chips/nrf54l15_app.rs
@@ -206,6 +206,14 @@ pub const EASY_DMA_SIZE: usize = (1 << 16) - 1;
206pub const FLASH_SIZE: usize = 1536 * 1024; 206pub const FLASH_SIZE: usize = 1536 * 1024;
207 207
208embassy_hal_internal::peripherals! { 208embassy_hal_internal::peripherals! {
209 // WDT
210 #[cfg(feature = "_ns")]
211 WDT,
212 #[cfg(feature = "_s")]
213 WDT0,
214 #[cfg(feature = "_s")]
215 WDT1,
216
209 #[cfg(feature = "_s")] 217 #[cfg(feature = "_s")]
210 // RRAMC 218 // RRAMC
211 RRAMC, 219 RRAMC,
@@ -291,6 +299,13 @@ impl_pin!(P2_08, 2, 8);
291impl_pin!(P2_09, 2, 9); 299impl_pin!(P2_09, 2, 9);
292impl_pin!(P2_10, 2, 10); 300impl_pin!(P2_10, 2, 10);
293 301
302#[cfg(feature = "_ns")]
303impl_wdt!(WDT, WDT31, WDT31, 0);
304#[cfg(feature = "_s")]
305impl_wdt!(WDT0, WDT31, WDT31, 0);
306#[cfg(feature = "_s")]
307impl_wdt!(WDT1, WDT30, WDT30, 1);
308
294embassy_hal_internal::interrupt_mod!( 309embassy_hal_internal::interrupt_mod!(
295 SWI00, 310 SWI00,
296 SWI01, 311 SWI01,
diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs
index d3c4b3bb1..9c1211f0a 100644
--- a/embassy-nrf/src/lib.rs
+++ b/embassy-nrf/src/lib.rs
@@ -174,7 +174,6 @@ pub mod uarte;
174 feature = "nrf52840" 174 feature = "nrf52840"
175))] 175))]
176pub mod usb; 176pub mod usb;
177#[cfg(not(feature = "_nrf54l"))] // TODO
178pub mod wdt; 177pub mod wdt;
179 178
180// This mod MUST go last, so that it sees all the `impl_foo!` macros 179// This mod MUST go last, so that it sees all the `impl_foo!` macros
diff --git a/embassy-nrf/src/wdt.rs b/embassy-nrf/src/wdt.rs
index 308071726..7ab9adc29 100644
--- a/embassy-nrf/src/wdt.rs
+++ b/embassy-nrf/src/wdt.rs
@@ -37,9 +37,9 @@ impl Config {
37 pub fn try_new<T: Instance>(_wdt: &Peri<'_, T>) -> Option<Self> { 37 pub fn try_new<T: Instance>(_wdt: &Peri<'_, T>) -> Option<Self> {
38 let r = T::REGS; 38 let r = T::REGS;
39 39
40 #[cfg(not(any(feature = "_nrf91", feature = "_nrf5340")))] 40 #[cfg(not(any(feature = "_nrf91", feature = "_nrf5340", feature = "_nrf54l")))]
41 let runstatus = r.runstatus().read().runstatus(); 41 let runstatus = r.runstatus().read().runstatus();
42 #[cfg(any(feature = "_nrf91", feature = "_nrf5340"))] 42 #[cfg(any(feature = "_nrf91", feature = "_nrf5340", feature = "_nrf54l"))]
43 let runstatus = r.runstatus().read().runstatuswdt(); 43 let runstatus = r.runstatus().read().runstatuswdt();
44 44
45 if runstatus { 45 if runstatus {
@@ -90,9 +90,9 @@ impl<T: Instance> Watchdog<T> {
90 let crv = config.timeout_ticks.max(MIN_TICKS); 90 let crv = config.timeout_ticks.max(MIN_TICKS);
91 let rren = crate::pac::wdt::regs::Rren((1u32 << N) - 1); 91 let rren = crate::pac::wdt::regs::Rren((1u32 << N) - 1);
92 92
93 #[cfg(not(any(feature = "_nrf91", feature = "_nrf5340")))] 93 #[cfg(not(any(feature = "_nrf91", feature = "_nrf5340", feature = "_nrf54l")))]
94 let runstatus = r.runstatus().read().runstatus(); 94 let runstatus = r.runstatus().read().runstatus();
95 #[cfg(any(feature = "_nrf91", feature = "_nrf5340"))] 95 #[cfg(any(feature = "_nrf91", feature = "_nrf5340", feature = "_nrf54l"))]
96 let runstatus = r.runstatus().read().runstatuswdt(); 96 let runstatus = r.runstatus().read().runstatuswdt();
97 97
98 if runstatus { 98 if runstatus {
diff --git a/examples/nrf54l15/src/bin/wdt.rs b/examples/nrf54l15/src/bin/wdt.rs
new file mode 100644
index 000000000..9fe37d080
--- /dev/null
+++ b/examples/nrf54l15/src/bin/wdt.rs
@@ -0,0 +1,42 @@
1#![no_std]
2#![no_main]
3
4use defmt::*;
5use embassy_executor::Spawner;
6use embassy_nrf::wdt::{Config, HaltConfig, Watchdog};
7use embassy_time::Timer;
8use {defmt_rtt as _, panic_probe as _};
9
10#[embassy_executor::main]
11async fn main(_spawner: Spawner) {
12 let p = embassy_nrf::init(Default::default());
13 info!("Hello WDT");
14
15 const TIMEOUT_S: u32 = 5;
16
17 let mut config = Config::default();
18 config.timeout_ticks = 32768 * TIMEOUT_S;
19
20 // This is needed for `probe-rs run` to be able to catch the panic message
21 // in the WDT interrupt. The core resets 2 ticks after firing the interrupt.
22 config.action_during_debug_halt = HaltConfig::PAUSE;
23
24 // The nrf54l15 has two watchdogs. Only one (WDT) is available in non-secure (ns) mode, as the
25 // other is reserved for the secure (s) environment. In secure mode, both are available as WDT0
26 // and WDT1.
27 info!("Watchdog launched with {} s timeout", TIMEOUT_S);
28 let (_wdt, [mut handle]) = match Watchdog::try_new(p.WDT1, config) {
29 Ok(x) => x,
30 Err(_) => {
31 info!("Watchdog already active with wrong config, waiting for it to timeout...");
32 loop {}
33 }
34 };
35
36 for wait in 1..=TIMEOUT_S {
37 info!("Waiting {} seconds ...", wait);
38 Timer::after_secs(wait as u64).await;
39 handle.pet();
40 info!("Pet watchdog");
41 }
42}