From de5760cc81a00966c61d668c41f6e3e4709f0283 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Tue, 14 Oct 2025 13:23:50 +0200 Subject: feat: improve nrf54 support using new nrf-pac * Update nrf-pac to version that modifies nrf52 register layout to match nrf54 to reduce the amount of cfg needed for nrf54 support. * Make the following peripherals available on nrf54: twim, twis, spim, spis, uart, buffered uarte, dppi, gpiote, pwm, saadc * Add examples tested on the nrf54 dk Some code is based on or copied from other pull requests, modified to match the new nrf-pac layout. Co-authored-by: Dmitry Tarnyagin --- tests/nrf/.cargo/config.toml | 4 ++-- tests/nrf/src/bin/buffered_uart_spam.rs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/nrf/.cargo/config.toml b/tests/nrf/.cargo/config.toml index 8f9bccbc0..0192c10ae 100644 --- a/tests/nrf/.cargo/config.toml +++ b/tests/nrf/.cargo/config.toml @@ -1,6 +1,6 @@ [target.'cfg(all(target_arch = "arm", target_os = "none"))'] -#runner = "teleprobe local run --chip nRF52840_xxAA --elf" -runner = "teleprobe client run" +runner = "teleprobe local run --chip nRF52840_xxAA --elf" +#runner = "teleprobe client run" [build] #target = "thumbv6m-none-eabi" diff --git a/tests/nrf/src/bin/buffered_uart_spam.rs b/tests/nrf/src/bin/buffered_uart_spam.rs index 24ddd06f3..6d862e19d 100644 --- a/tests/nrf/src/bin/buffered_uart_spam.rs +++ b/tests/nrf/src/bin/buffered_uart_spam.rs @@ -55,14 +55,14 @@ async fn main(_spawner: Spawner) { static mut TX_BUF: [u8; NSPAM] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; let _spam = UarteTx::new(peri!(p, UART1), irqs!(UART1), peri!(p, PIN_A), config.clone()); let spam_peri = pac::UARTE1; - let event = unsafe { Event::new_unchecked(NonNull::new_unchecked(spam_peri.events_endtx().as_ptr())) }; - let task = unsafe { Task::new_unchecked(NonNull::new_unchecked(spam_peri.tasks_starttx().as_ptr())) }; + let event = unsafe { Event::new_unchecked(NonNull::new_unchecked(spam_peri.events_dma().tx().end().as_ptr())) }; + let task = unsafe { Task::new_unchecked(NonNull::new_unchecked(spam_peri.tasks_dma().tx().start().as_ptr())) }; let mut spam_ppi = Ppi::new_one_to_one(p.PPI_CH2, event, task); spam_ppi.enable(); let p = (&raw mut TX_BUF) as *mut u8; - spam_peri.txd().ptr().write_value(p as u32); - spam_peri.txd().maxcnt().write(|w| w.set_maxcnt(NSPAM as _)); - spam_peri.tasks_starttx().write_value(1); + spam_peri.dma().tx().ptr().write_value(p as u32); + spam_peri.dma().tx().maxcnt().write(|w| w.set_maxcnt(NSPAM as _)); + spam_peri.tasks_dma().tx().start().write_value(1); let mut i = 0; let mut total = 0; -- cgit From 98de11e5e3ae437676198a105ffab8c0f4977513 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 29 Oct 2025 17:49:55 +0100 Subject: net-esp-hosted: add Interface trait. --- tests/nrf/src/bin/wifi_esp_hosted_perf.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs index 091a70ce9..ac082dbb8 100644 --- a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs +++ b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs @@ -29,8 +29,7 @@ const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud"; async fn wifi_task( runner: hosted::Runner< 'static, - ExclusiveDevice, Output<'static>, Delay>, - Input<'static>, + hosted::SpiInterface, Output<'static>, Delay>, Input<'static>>, Output<'static>, >, ) -> ! { @@ -64,15 +63,11 @@ async fn main(spawner: Spawner) { let spi = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config); let spi = ExclusiveDevice::new(spi, cs, Delay); + let iface = hosted::SpiInterface::new(spi, handshake, ready); + static STATE: StaticCell = StaticCell::new(); - let (device, mut control, runner) = embassy_net_esp_hosted::new( - STATE.init(embassy_net_esp_hosted::State::new()), - spi, - handshake, - ready, - reset, - ) - .await; + let (device, mut control, runner) = + embassy_net_esp_hosted::new(STATE.init(embassy_net_esp_hosted::State::new()), iface, reset).await; spawner.spawn(unwrap!(wifi_task(runner))); -- cgit From d25b5ce3bec44f4a023403a8b479e034d8386275 Mon Sep 17 00:00:00 2001 From: xoviat Date: Mon, 3 Nov 2025 13:02:08 -0600 Subject: low_power: update api to allow reconfig --- tests/stm32/src/bin/stop.rs | 3 --- 1 file changed, 3 deletions(-) (limited to 'tests') diff --git a/tests/stm32/src/bin/stop.rs b/tests/stm32/src/bin/stop.rs index 833ca05d0..cb3a5774c 100644 --- a/tests/stm32/src/bin/stop.rs +++ b/tests/stm32/src/bin/stop.rs @@ -70,9 +70,6 @@ async fn async_main(spawner: Spawner) { rtc.set_datetime(now.into()).expect("datetime not set"); - static RTC: StaticCell = StaticCell::new(); - let rtc = RTC.init(rtc); - stop_with_rtc(rtc); spawner.spawn(task_1().unwrap()); -- cgit From 5043f1483e12ce5dbe7a394d5a87c657ff203625 Mon Sep 17 00:00:00 2001 From: xoviat Date: Mon, 3 Nov 2025 13:12:12 -0600 Subject: rustfmt --- tests/stm32/src/bin/stop.rs | 1 - 1 file changed, 1 deletion(-) (limited to 'tests') diff --git a/tests/stm32/src/bin/stop.rs b/tests/stm32/src/bin/stop.rs index cb3a5774c..73580f0f2 100644 --- a/tests/stm32/src/bin/stop.rs +++ b/tests/stm32/src/bin/stop.rs @@ -14,7 +14,6 @@ use embassy_stm32::low_power::{Executor, StopMode, stop_ready, stop_with_rtc}; use embassy_stm32::rcc::LsConfig; use embassy_stm32::rtc::{Rtc, RtcConfig}; use embassy_time::Timer; -use static_cell::StaticCell; #[entry] fn main() -> ! { -- cgit From c93aa229a8965a5e0a45a507b04f07d825fe1a1a Mon Sep 17 00:00:00 2001 From: xoviat Date: Tue, 4 Nov 2025 12:47:55 -0600 Subject: stm32: fix rtc test --- tests/stm32/src/bin/rtc.rs | 18 +++++++++++++++++- tests/stm32/src/bin/stop.rs | 11 +++-------- 2 files changed, 20 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/stm32/src/bin/rtc.rs b/tests/stm32/src/bin/rtc.rs index 5fe98d807..5c80eb250 100644 --- a/tests/stm32/src/bin/rtc.rs +++ b/tests/stm32/src/bin/rtc.rs @@ -9,10 +9,14 @@ use chrono::{NaiveDate, NaiveDateTime}; use common::*; use defmt::assert; use embassy_executor::Spawner; +#[cfg(feature = "stop")] +use embassy_stm32::low_power::reconfigure_rtc; use embassy_stm32::rcc::LsConfig; +#[cfg(feature = "stop")] +use embassy_stm32::rtc::RtcTimeProvider; +#[cfg(not(feature = "stop"))] use embassy_stm32::rtc::{Rtc, RtcConfig}; use embassy_time::Timer; - #[embassy_executor::main] async fn main(_spawner: Spawner) { let mut config = config(); @@ -26,14 +30,26 @@ async fn main(_spawner: Spawner) { .and_hms_opt(10, 30, 15) .unwrap(); + #[cfg(not(feature = "stop"))] let mut rtc = Rtc::new(p.RTC, RtcConfig::default()); + #[cfg(feature = "stop")] + let time_provider = RtcTimeProvider::new(p.RTC); + + #[cfg(not(feature = "stop"))] rtc.set_datetime(now.into()).expect("datetime not set"); + #[cfg(feature = "stop")] + reconfigure_rtc(|rtc| rtc.set_datetime(now.into()).expect("datetime not set")); + info!("Waiting 5 seconds"); Timer::after_millis(5000).await; + #[cfg(not(feature = "stop"))] let then: NaiveDateTime = rtc.now().unwrap().into(); + #[cfg(feature = "stop")] + let then: NaiveDateTime = time_provider.now().unwrap().into(); + let seconds = (then - now).num_seconds(); info!("measured = {}", seconds); diff --git a/tests/stm32/src/bin/stop.rs b/tests/stm32/src/bin/stop.rs index 73580f0f2..a9dbac676 100644 --- a/tests/stm32/src/bin/stop.rs +++ b/tests/stm32/src/bin/stop.rs @@ -10,9 +10,8 @@ use common::*; use cortex_m_rt::entry; use embassy_executor::Spawner; use embassy_stm32::Config; -use embassy_stm32::low_power::{Executor, StopMode, stop_ready, stop_with_rtc}; +use embassy_stm32::low_power::{Executor, StopMode, reconfigure_rtc, stop_ready}; use embassy_stm32::rcc::LsConfig; -use embassy_stm32::rtc::{Rtc, RtcConfig}; use embassy_time::Timer; #[entry] @@ -57,7 +56,7 @@ async fn async_main(spawner: Spawner) { config.rcc.hsi = Some(HSIPrescaler::DIV4); // 64 MHz HSI will need a /4 } - let p = init_with_config(config); + let _p = init_with_config(config); info!("Hello World!"); let now = NaiveDate::from_ymd_opt(2020, 5, 15) @@ -65,11 +64,7 @@ async fn async_main(spawner: Spawner) { .and_hms_opt(10, 30, 15) .unwrap(); - let mut rtc = Rtc::new(p.RTC, RtcConfig::default()); - - rtc.set_datetime(now.into()).expect("datetime not set"); - - stop_with_rtc(rtc); + reconfigure_rtc(|rtc| rtc.set_datetime(now.into()).expect("datetime not set")); spawner.spawn(task_1().unwrap()); spawner.spawn(task_2().unwrap()); -- cgit From b9559c7713bc7f773cdef0df14f1158840d06d06 Mon Sep 17 00:00:00 2001 From: xoviat Date: Tue, 4 Nov 2025 16:35:07 -0600 Subject: rtc: use consistent api between stop and non-stop --- tests/stm32/Cargo.toml | 1 + tests/stm32/src/bin/rtc.rs | 15 ++++++--------- tests/stm32/src/bin/stop.rs | 11 ++++++++--- 3 files changed, 15 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 1161e827b..e75a4ebb1 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -94,6 +94,7 @@ rand_core = { version = "0.9.1", default-features = false } rand_chacha = { version = "0.9.0", default-features = false } static_cell = "2" portable-atomic = { version = "1.5", features = [] } +critical-section = "1.1" chrono = { version = "^0.4", default-features = false, optional = true} sha2 = { version = "0.10.8", default-features = false } diff --git a/tests/stm32/src/bin/rtc.rs b/tests/stm32/src/bin/rtc.rs index 5c80eb250..43cf4a411 100644 --- a/tests/stm32/src/bin/rtc.rs +++ b/tests/stm32/src/bin/rtc.rs @@ -9,11 +9,9 @@ use chrono::{NaiveDate, NaiveDateTime}; use common::*; use defmt::assert; use embassy_executor::Spawner; -#[cfg(feature = "stop")] -use embassy_stm32::low_power::reconfigure_rtc; use embassy_stm32::rcc::LsConfig; #[cfg(feature = "stop")] -use embassy_stm32::rtc::RtcTimeProvider; +use embassy_stm32::rtc::Rtc; #[cfg(not(feature = "stop"))] use embassy_stm32::rtc::{Rtc, RtcConfig}; use embassy_time::Timer; @@ -31,23 +29,22 @@ async fn main(_spawner: Spawner) { .unwrap(); #[cfg(not(feature = "stop"))] - let mut rtc = Rtc::new(p.RTC, RtcConfig::default()); + let (mut rtc, time_provider) = Rtc::new(p.RTC, RtcConfig::default()); #[cfg(feature = "stop")] - let time_provider = RtcTimeProvider::new(p.RTC); + let (rtc, time_provider) = Rtc::new(p.RTC); #[cfg(not(feature = "stop"))] rtc.set_datetime(now.into()).expect("datetime not set"); #[cfg(feature = "stop")] - reconfigure_rtc(|rtc| rtc.set_datetime(now.into()).expect("datetime not set")); + critical_section::with(|cs| { + rtc.borrow_mut(cs).set_datetime(now.into()).expect("datetime not set"); + }); info!("Waiting 5 seconds"); Timer::after_millis(5000).await; - #[cfg(not(feature = "stop"))] - let then: NaiveDateTime = rtc.now().unwrap().into(); - #[cfg(feature = "stop")] let then: NaiveDateTime = time_provider.now().unwrap().into(); let seconds = (then - now).num_seconds(); diff --git a/tests/stm32/src/bin/stop.rs b/tests/stm32/src/bin/stop.rs index a9dbac676..4b3a775bb 100644 --- a/tests/stm32/src/bin/stop.rs +++ b/tests/stm32/src/bin/stop.rs @@ -10,8 +10,9 @@ use common::*; use cortex_m_rt::entry; use embassy_executor::Spawner; use embassy_stm32::Config; -use embassy_stm32::low_power::{Executor, StopMode, reconfigure_rtc, stop_ready}; +use embassy_stm32::low_power::{Executor, StopMode, stop_ready}; use embassy_stm32::rcc::LsConfig; +use embassy_stm32::rtc::Rtc; use embassy_time::Timer; #[entry] @@ -56,7 +57,7 @@ async fn async_main(spawner: Spawner) { config.rcc.hsi = Some(HSIPrescaler::DIV4); // 64 MHz HSI will need a /4 } - let _p = init_with_config(config); + let p = init_with_config(config); info!("Hello World!"); let now = NaiveDate::from_ymd_opt(2020, 5, 15) @@ -64,7 +65,11 @@ async fn async_main(spawner: Spawner) { .and_hms_opt(10, 30, 15) .unwrap(); - reconfigure_rtc(|rtc| rtc.set_datetime(now.into()).expect("datetime not set")); + let (rtc, _time_provider) = Rtc::new(p.RTC); + + critical_section::with(|cs| { + rtc.borrow_mut(cs).set_datetime(now.into()).expect("datetime not set"); + }); spawner.spawn(task_1().unwrap()); spawner.spawn(task_2().unwrap()); -- cgit From 141f826e10802a40ac1bca8fdcdfa3da821e0f28 Mon Sep 17 00:00:00 2001 From: Cristian Milatinov Date: Wed, 9 Jul 2025 20:35:01 -0400 Subject: feat: stm32 spi driver slave mode Add SPI slave constructors Fix SPI slave constructors Fix embedded hal async trait One more constructor fix Set SSM bit in SPI driver according to CommunicationMode Fix embedded_hal_async trait to be generic for both master and slave Fix I2S driver to use async master SPI Forgot import from spi mode Fix CommunicationMode associated const conditionals Duplicate doc for CommunicationMode const Add missing nss argument Fix existing SPI tests not compiling Fix stm32h7rs examples not compiling Fix failing stm32l4 example Fix stm32h7 example Fix stm32h7 spi_bdma example Fix stm32h7 spi example Fix stm32f4 example docs: added entry in changelog.md fix: spi_v3 vals mismatch + rise_fall_speed renamed to gpio_speed fix: added spi_v6 conditional compilation feature fix: use if_afio macro in slave constructors fix: add missing trait bound fix: if_afio for cs pin trait fix: changelog message fix: broken rebase --- tests/stm32/src/bin/spi.rs | 7 ++++--- tests/stm32/src/bin/spi_dma.rs | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index e8310866a..cedff772c 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs @@ -8,6 +8,7 @@ use defmt::assert_eq; use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::mode::Blocking; +use embassy_stm32::spi::mode::Master; use embassy_stm32::spi::{self, Spi, Word}; use embassy_stm32::time::Hertz; @@ -65,7 +66,7 @@ async fn main(_spawner: Spawner) { cortex_m::asm::bkpt(); } -fn test_txrx + defmt::Format + Eq>(spi: &mut Spi<'_, Blocking>) +fn test_txrx + defmt::Format + Eq>(spi: &mut Spi<'_, Blocking, Master>) where W: core::ops::Not, { @@ -109,7 +110,7 @@ where spi.blocking_write::(&[]).unwrap(); } -fn test_rx + defmt::Format + Eq>(spi: &mut Spi<'_, Blocking>, mosi_out: &mut Output<'_>) +fn test_rx + defmt::Format + Eq>(spi: &mut Spi<'_, Blocking, Master>, mosi_out: &mut Output<'_>) where W: core::ops::Not, { @@ -125,7 +126,7 @@ where spi.blocking_read::(&mut []).unwrap(); } -fn test_tx + defmt::Format + Eq>(spi: &mut Spi<'_, Blocking>) +fn test_tx + defmt::Format + Eq>(spi: &mut Spi<'_, Blocking, Master>) where W: core::ops::Not, { diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index b4fdb8faa..c8cd92401 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs @@ -8,6 +8,7 @@ use defmt::assert_eq; use embassy_executor::Spawner; use embassy_stm32::gpio::{Level, Output, Speed}; use embassy_stm32::mode::Async; +use embassy_stm32::spi::mode::Master; use embassy_stm32::spi::{self, Spi, Word}; use embassy_stm32::time::Hertz; @@ -78,7 +79,7 @@ async fn main(_spawner: Spawner) { cortex_m::asm::bkpt(); } -async fn test_txrx + defmt::Format + Eq>(spi: &mut Spi<'_, Async>) +async fn test_txrx + defmt::Format + Eq>(spi: &mut Spi<'_, Async, Master>) where W: core::ops::Not, { @@ -142,7 +143,7 @@ where spi.write(&buf).await.unwrap(); } -async fn test_rx + defmt::Format + Eq>(spi: &mut Spi<'_, Async>, mosi_out: &mut Output<'_>) +async fn test_rx + defmt::Format + Eq>(spi: &mut Spi<'_, Async, Master>, mosi_out: &mut Output<'_>) where W: core::ops::Not, { @@ -168,7 +169,7 @@ where spi.blocking_read::(&mut []).unwrap(); } -async fn test_tx + defmt::Format + Eq>(spi: &mut Spi<'_, Async>) +async fn test_tx + defmt::Format + Eq>(spi: &mut Spi<'_, Async, Master>) where W: core::ops::Not, { -- cgit From 2f26c3c5f1380535c5fdd74cd39962338ed51204 Mon Sep 17 00:00:00 2001 From: xoviat Date: Wed, 5 Nov 2025 07:13:15 -0600 Subject: tests: disable rtc for h563 on non-stop --- tests/stm32/Cargo.toml | 2 +- tests/stm32/src/bin/rtc.rs | 4 ++++ tests/stm32/src/bin/stop.rs | 1 + tests/stm32/src/common.rs | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index e75a4ebb1..b92b47be2 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -73,7 +73,7 @@ teleprobe-meta = "1" embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "tick-hz-131_072", "defmt-timestamp-uptime"] } -embassy-stm32 = { version = "0.4.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "memory-x", "time-driver-any"] } +embassy-stm32 = { version = "0.4.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "memory-x", "time-driver-any", "_allow-disable-rtc"] } embassy-futures = { version = "0.1.2", path = "../../embassy-futures" } embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", optional = true, features = ["defmt", "stm32wb55rg", "ble"] } embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } diff --git a/tests/stm32/src/bin/rtc.rs b/tests/stm32/src/bin/rtc.rs index 43cf4a411..eb27af4ca 100644 --- a/tests/stm32/src/bin/rtc.rs +++ b/tests/stm32/src/bin/rtc.rs @@ -19,6 +19,10 @@ use embassy_time::Timer; async fn main(_spawner: Spawner) { let mut config = config(); config.rcc.ls = LsConfig::default_lse(); + #[cfg(feature = "stop")] + { + config.rtc._disable_rtc = false; + } let p = init_with_config(config); info!("Hello World!"); diff --git a/tests/stm32/src/bin/stop.rs b/tests/stm32/src/bin/stop.rs index 4b3a775bb..1fe65d867 100644 --- a/tests/stm32/src/bin/stop.rs +++ b/tests/stm32/src/bin/stop.rs @@ -49,6 +49,7 @@ async fn async_main(spawner: Spawner) { let mut config = Config::default(); config.rcc.ls = LsConfig::default_lse(); + config.rtc._disable_rtc = false; // System Clock seems cannot be greater than 16 MHz #[cfg(any(feature = "stm32h563zi", feature = "stm32h503rb"))] diff --git a/tests/stm32/src/common.rs b/tests/stm32/src/common.rs index 2bd934d6f..096cce947 100644 --- a/tests/stm32/src/common.rs +++ b/tests/stm32/src/common.rs @@ -468,6 +468,8 @@ pub fn config() -> Config { config.rcc.apb3_pre = APBPrescaler::DIV1; config.rcc.sys = Sysclk::PLL1_P; config.rcc.voltage_scale = VoltageScale::Scale0; + + config.rtc._disable_rtc = true; } #[cfg(feature = "stm32h503rb")] -- cgit