From 427c6a495d5d3a9b76da7f1673a85f45ad6e1227 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Mon, 8 Dec 2025 11:43:51 +0100 Subject: chore: use feature guards for nrf54 in examples --- examples/boot/application/nrf/Cargo.toml | 13 +++++++------ examples/boot/application/nrf/src/bin/a.rs | 24 ++++++++++++++++++------ examples/boot/application/nrf/src/bin/b.rs | 4 +++- 3 files changed, 28 insertions(+), 13 deletions(-) (limited to 'examples') diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml index 4176fd499..79286e295 100644 --- a/examples/boot/application/nrf/Cargo.toml +++ b/examples/boot/application/nrf/Cargo.toml @@ -33,13 +33,14 @@ defmt = [ "embassy-boot-nrf/defmt", "embassy-sync/defmt", ] +nrf54 = ["embassy-nrf/time-driver-grtc"] [package.metadata.embassy] build = [ - { target = "thumbv7em-none-eabi", features = ["embassy-nrf/nrf52840", "skip-include"], artifact-dir = "out/examples/boot/nrf52840" }, - { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9160-ns", "skip-include"], artifact-dir = "out/examples/boot/nrf9160" }, - { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9120-ns", "skip-include"], artifact-dir = "out/examples/boot/nrf9120" }, - { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9151-ns", "skip-include"], artifact-dir = "out/examples/boot/nrf9151" }, - { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9161-ns", "skip-include"], artifact-dir = "out/examples/boot/nrf9161" }, - { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf54l15-app-s", "skip-include"], artifact-dir = "out/examples/boot/nrf54l15" } + { target = "thumbv7em-none-eabi", features = ["embassy-nrf/nrf52840", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf52840" }, + { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9160-ns", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf9160" }, + { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9120-ns", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf9120" }, + { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9151-ns", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf9151" }, + { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9161-ns", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf9161" }, + { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf54l15-app-s", "nrf54", "skip-include"], artifact-dir = "out/examples/boot/nrf54l15" } ] diff --git a/examples/boot/application/nrf/src/bin/a.rs b/examples/boot/application/nrf/src/bin/a.rs index f317414fc..035ffe214 100644 --- a/examples/boot/application/nrf/src/bin/a.rs +++ b/examples/boot/application/nrf/src/bin/a.rs @@ -23,14 +23,20 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); async fn main(_spawner: Spawner) { let p = embassy_nrf::init(Default::default()); + #[cfg(not(feature = "nrf54"))] let mut button = Input::new(p.P0_11, Pull::Up); + #[cfg(not(feature = "nrf54"))] let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); + #[cfg(not(feature = "nrf54"))] let mut led_reverted = Output::new(p.P0_14, Level::High, OutputDrive::Standard); // nRF54 DK - // let mut button = Input::new(p.P1_13, Pull::Up); - // let mut led = Output::new(p.P1_14, Level::Low, OutputDrive::Standard); - // let mut led_reverted = Output::new(p.P2_09, Level::High, OutputDrive::Standard); + #[cfg(feature = "nrf54")] + let mut button = Input::new(p.P1_13, Pull::Up); + #[cfg(feature = "nrf54")] + let mut led = Output::new(p.P1_14, Level::Low, OutputDrive::Standard); + #[cfg(feature = "nrf54")] + let mut led_reverted = Output::new(p.P2_09, Level::High, OutputDrive::Standard); //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); //let mut button = Input::new(p.P1_02, Pull::Up); @@ -45,8 +51,12 @@ async fn main(_spawner: Spawner) { // the watchdog will cause the device to reset as per its configured timeout in the bootloader. // This helps is avoid a situation where new firmware might be bad and block our executor. // If firmware is bad in this way then the bootloader will revert to any previous version. - let wdt_config = wdt::Config::try_new(&p.WDT0).unwrap(); - let (_wdt, [_wdt_handle]) = match Watchdog::try_new(p.WDT0, wdt_config) { + #[cfg(feature = "nrf54")] + let wdt = p.WDT0; + #[cfg(not(feature = "nrf54"))] + let wdt = p.WDT; + let wdt_config = wdt::Config::try_new(&wdt).unwrap(); + let (_wdt, [_wdt_handle]) = match Watchdog::try_new(wdt, wdt_config) { Ok(x) => x, Err(_) => { // Watchdog already active with the wrong number of handles, waiting for it to timeout... @@ -57,7 +67,9 @@ async fn main(_spawner: Spawner) { }; // RRAMC for nRF54 - // let nvmc = Nvmc::new(p.RRAMC); + #[cfg(feature = "nrf54")] + let nvmc = Nvmc::new(p.RRAMC); + #[cfg(not(feature = "nrf54"))] let nvmc = Nvmc::new(p.NVMC); let nvmc = Mutex::new(BlockingAsync::new(nvmc)); diff --git a/examples/boot/application/nrf/src/bin/b.rs b/examples/boot/application/nrf/src/bin/b.rs index 7ed78ea85..6718df5a1 100644 --- a/examples/boot/application/nrf/src/bin/b.rs +++ b/examples/boot/application/nrf/src/bin/b.rs @@ -10,13 +10,15 @@ use panic_reset as _; #[embassy_executor::main] async fn main(_spawner: Spawner) { let p = embassy_nrf::init(Default::default()); + #[cfg(not(feature = "nrf54"))] let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); // let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); // nRF91 DK // let mut led = Output::new(p.P0_02, Level::Low, OutputDrive::Standard); // nrf54l15 dk - // let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); + #[cfg(feature = "nrf54")] + let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); loop { led.set_high(); -- cgit