From 4567beda7b7773c8cb11f19f0f4f146c1243508d Mon Sep 17 00:00:00 2001 From: 1-rafael-1 Date: Sun, 11 May 2025 17:26:36 +0200 Subject: rp235x overclocking --- tests/rp/src/bin/overclock.rs | 49 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'tests') diff --git a/tests/rp/src/bin/overclock.rs b/tests/rp/src/bin/overclock.rs index be8e85a3f..a568d7fed 100644 --- a/tests/rp/src/bin/overclock.rs +++ b/tests/rp/src/bin/overclock.rs @@ -7,14 +7,8 @@ teleprobe_meta::target!(b"rpi-pico"); teleprobe_meta::target!(b"pimoroni-pico-plus-2"); use defmt::info; -#[cfg(feature = "rp2040")] -use defmt::{assert, assert_eq}; use embassy_executor::Spawner; -use embassy_rp::clocks; -#[cfg(feature = "rp2040")] -use embassy_rp::clocks::ClockConfig; -#[cfg(feature = "rp2040")] -use embassy_rp::clocks::CoreVoltage; +use embassy_rp::clocks::{clk_sys_freq, core_voltage, ClockConfig, CoreVoltage}; use embassy_rp::config::Config; use embassy_time::Instant; use {defmt_rtt as _, panic_probe as _}; @@ -23,23 +17,26 @@ const COUNT_TO: i64 = 10_000_000; #[embassy_executor::main] async fn main(_spawner: Spawner) { - #[cfg(feature = "rp2040")] let mut config = Config::default(); - #[cfg(not(feature = "rp2040"))] - let config = Config::default(); - // Initialize with 200MHz clock configuration for RP2040, other chips will use default clock - #[cfg(feature = "rp2040")] + // Initialize with 200MHz clock configuration + config.clocks = ClockConfig::system_freq(200_000_000); + + // if we are rp235x, we need to manually set the core voltage. rp2040 should do this automatically + #[cfg(feature = "rp235xb")] { - config.clocks = ClockConfig::system_freq(200_000_000); - let voltage = config.clocks.core_voltage; - assert!(matches!(voltage, CoreVoltage::V1_15), "Expected voltage scale V1_15"); + config.clocks.core_voltage = CoreVoltage::V1_15; } let _p = embassy_rp::init(config); + // We should be at core voltage of 1.15V + assert_eq!(core_voltage().unwrap(), CoreVoltage::V1_15, "Core voltage is not 1.15V"); + // We should be at 200MHz + assert_eq!(clk_sys_freq(), 200_000_000, "System clock frequency is not 200MHz"); + // Test the system speed - let (time_elapsed, clk_sys_freq) = { + let time_elapsed = { let mut counter = 0; let start = Instant::now(); while counter < COUNT_TO { @@ -47,24 +44,26 @@ async fn main(_spawner: Spawner) { } let elapsed = Instant::now() - start; - (elapsed.as_millis(), clocks::clk_sys_freq()) + elapsed.as_millis() }; - // Report the elapsed time, so that the compiler doesn't optimize it away for chips other than RP2040 + // Tests will fail if unused variables are detected: + // Report the elapsed time, so that the compiler doesn't optimize it away for the chip not on test info!( "At {}Mhz: Elapsed time to count to {}: {}ms", - clk_sys_freq / 1_000_000, + clk_sys_freq() / 1_000_000, COUNT_TO, time_elapsed ); + // Check if the elapsed time is within expected limits + // for rp2040 we expect about 600ms #[cfg(feature = "rp2040")] - { - // we should be at 200MHz - assert_eq!(clk_sys_freq, 200_000_000, "System clock frequency is not 200MHz"); - // At 200MHz, the time to count to 10_000_000 should be at 600ms, testing with 1% margin - assert!(time_elapsed <= 606, "Elapsed time is too long"); - } + // allow 1% error + assert!(time_elapsed < 606, "Elapsed time is too long"); + // for rp235x we expect about 450ms + #[cfg(feature = "rp235xb")] + assert!(time_elapsed < 455, "Elapsed time is too long"); cortex_m::asm::bkpt(); } -- cgit From 79e452922a6b467f2e8547a6b28698ed5f409705 Mon Sep 17 00:00:00 2001 From: 1-rafael-1 Date: Mon, 12 May 2025 21:33:47 +0200 Subject: Add ClockError enum and update system_freq to return Result for error handling --- tests/rp/src/bin/overclock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/rp/src/bin/overclock.rs b/tests/rp/src/bin/overclock.rs index a568d7fed..167a26eb2 100644 --- a/tests/rp/src/bin/overclock.rs +++ b/tests/rp/src/bin/overclock.rs @@ -20,7 +20,7 @@ async fn main(_spawner: Spawner) { let mut config = Config::default(); // Initialize with 200MHz clock configuration - config.clocks = ClockConfig::system_freq(200_000_000); + config.clocks = ClockConfig::system_freq(200_000_000).unwrap(); // if we are rp235x, we need to manually set the core voltage. rp2040 should do this automatically #[cfg(feature = "rp235xb")] -- cgit From f41e8c45f68ca31819ea1b1eae5fbd019bf8f318 Mon Sep 17 00:00:00 2001 From: i509VCB Date: Tue, 13 May 2025 21:55:50 -0500 Subject: mspm0: generate feature per chip + package --- tests/mspm0/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/mspm0/Cargo.toml b/tests/mspm0/Cargo.toml index 0566807d7..d76aaff73 100644 --- a/tests/mspm0/Cargo.toml +++ b/tests/mspm0/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [features] -mspm0g3507 = [ "embassy-mspm0/mspm0g350x" ] +mspm0g3507 = [ "embassy-mspm0/mspm0g3507pm" ] [dependencies] teleprobe-meta = "1.1" -- cgit From e4fc48764491f8981e4a145a72e9b6e72df8c546 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sun, 18 May 2025 20:32:48 +0200 Subject: Add rand-core v0.9 support. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Aurélien Jacobs --- tests/rp/Cargo.toml | 1 - tests/rp/src/bin/ethernet_w5100s_perf.rs | 1 - tests/stm32/Cargo.toml | 4 ++-- tests/stm32/src/bin/eth.rs | 1 - tests/utils/Cargo.toml | 2 +- 5 files changed, 3 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 1335aa84b..46dc820ab 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -38,7 +38,6 @@ embedded-io-async = { version = "0.6.1" } embedded-storage = { version = "0.3" } static_cell = "2" portable-atomic = { version = "1.5", features = ["critical-section"] } -rand = { version = "0.8.5", default-features = false } # bootsel not currently supported on 2350 [[bin]] diff --git a/tests/rp/src/bin/ethernet_w5100s_perf.rs b/tests/rp/src/bin/ethernet_w5100s_perf.rs index ae2adfa55..89e0ad32e 100644 --- a/tests/rp/src/bin/ethernet_w5100s_perf.rs +++ b/tests/rp/src/bin/ethernet_w5100s_perf.rs @@ -14,7 +14,6 @@ use embassy_rp::peripherals::SPI0; use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; use embassy_time::Delay; use embedded_hal_bus::spi::ExclusiveDevice; -use rand::RngCore; use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 3a347e279..b230e619e 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -81,8 +81,8 @@ embedded-hal-async = { version = "1.0" } embedded-can = { version = "0.4" } micromath = "2.0.0" panic-probe = { version = "0.3.0", features = ["print-defmt"] } -rand_core = { version = "0.6", default-features = false } -rand_chacha = { version = "0.3", default-features = false } +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 = [] } diff --git a/tests/stm32/src/bin/eth.rs b/tests/stm32/src/bin/eth.rs index a7e76fd8e..bcb362b42 100644 --- a/tests/stm32/src/bin/eth.rs +++ b/tests/stm32/src/bin/eth.rs @@ -11,7 +11,6 @@ use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; use embassy_stm32::peripherals::ETH; use embassy_stm32::rng::Rng; use embassy_stm32::{bind_interrupts, eth, peripherals, rng}; -use rand_core::RngCore; use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; diff --git a/tests/utils/Cargo.toml b/tests/utils/Cargo.toml index 7b54a4f52..bda55ad32 100644 --- a/tests/utils/Cargo.toml +++ b/tests/utils/Cargo.toml @@ -4,5 +4,5 @@ version = "0.1.0" edition = "2021" [dependencies] -rand = "0.8" +rand = "0.9" serial = "0.4" -- cgit From ef0f29f0ede245671ffd82fcf384a9105f174c24 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sun, 18 May 2025 20:51:15 +0200 Subject: Update defmt dependencies --- tests/mspm0/Cargo.toml | 2 +- tests/nrf/Cargo.toml | 6 +++--- tests/perf-client/Cargo.toml | 2 +- tests/rp/Cargo.toml | 6 +++--- tests/stm32/Cargo.toml | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/mspm0/Cargo.toml b/tests/mspm0/Cargo.toml index 0566807d7..b77747e5d 100644 --- a/tests/mspm0/Cargo.toml +++ b/tests/mspm0/Cargo.toml @@ -23,7 +23,7 @@ cortex-m = { version = "0.7.6", features = [ "inline-asm", "critical-section-sin cortex-m-rt = "0.7.0" embedded-hal = { package = "embedded-hal", version = "1.0" } embedded-hal-async = { version = "1.0" } -panic-probe = { version = "0.3.0", features = ["print-defmt"] } +panic-probe = { version = "1.0.0", features = ["print-defmt"] } static_cell = "2" portable-atomic = { version = "1.5", features = ["critical-section"] } diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index 410d62bdd..32087940e 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -21,12 +21,12 @@ embedded-hal-bus = { version = "0.1", features = ["async"] } static_cell = "2" perf-client = { path = "../perf-client" } -defmt = "0.3" -defmt-rtt = "0.4" +defmt = "1.0.1" +defmt-rtt = "1.0.0" cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" -panic-probe = { version = "0.3", features = ["print-defmt"] } +panic-probe = { version = "1.0.0", features = ["print-defmt"] } portable-atomic = { version = "1.6.0" } [features] diff --git a/tests/perf-client/Cargo.toml b/tests/perf-client/Cargo.toml index 9620972c3..e31d6361b 100644 --- a/tests/perf-client/Cargo.toml +++ b/tests/perf-client/Cargo.toml @@ -7,4 +7,4 @@ edition = "2021" embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", ] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -defmt = "0.3" +defmt = "1.0.1" diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 46dc820ab..2c2ed73cc 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -24,8 +24,8 @@ cyw43 = { path = "../../cyw43", features = ["defmt", "firmware-logs"] } cyw43-pio = { path = "../../cyw43-pio", features = ["defmt"] } perf-client = { path = "../perf-client" } -defmt = "0.3" -defmt-rtt = "0.4" +defmt = "1.0.1" +defmt-rtt = "1.0.0" cortex-m = { version = "0.7.6" } cortex-m-rt = "0.7.0" @@ -33,7 +33,7 @@ embedded-hal = "0.2.6" embedded-hal-1 = { package = "embedded-hal", version = "1.0" } embedded-hal-async = { version = "1.0" } embedded-hal-bus = { version = "0.1", features = ["async"] } -panic-probe = { version = "0.3.0", features = ["print-defmt"] } +panic-probe = { version = "1.0.0", features = ["print-defmt"] } embedded-io-async = { version = "0.6.1" } embedded-storage = { version = "0.3" } static_cell = "2" diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index b230e619e..6036a5a97 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -70,8 +70,8 @@ embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", opt embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } perf-client = { path = "../perf-client" } -defmt = "0.3" -defmt-rtt = "0.4" +defmt = "1.0.1" +defmt-rtt = "1.0.0" cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" @@ -80,7 +80,7 @@ embedded-hal-1 = { package = "embedded-hal", version = "1.0" } embedded-hal-async = { version = "1.0" } embedded-can = { version = "0.4" } micromath = "2.0.0" -panic-probe = { version = "0.3.0", features = ["print-defmt"] } +panic-probe = { version = "1.0.0", features = ["print-defmt"] } rand_core = { version = "0.9.1", default-features = false } rand_chacha = { version = "0.9.0", default-features = false } static_cell = "2" -- cgit From 8b65f9cf0f4095080297bf5c3e09334296da8076 Mon Sep 17 00:00:00 2001 From: i509VCB Date: Tue, 20 May 2025 17:29:28 -0500 Subject: mspm0: link interrupt groups in tests --- tests/mspm0/build.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/mspm0/build.rs b/tests/mspm0/build.rs index 57b592abf..0b58fb9e9 100644 --- a/tests/mspm0/build.rs +++ b/tests/mspm0/build.rs @@ -19,6 +19,8 @@ fn main() -> Result<(), Box> { println!("cargo:rustc-link-arg-bins=-Tlink_ram.x"); println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); println!("cargo:rustc-link-arg-bins=-Tteleprobe.x"); + // You must tell cargo to link interrupt groups if the rt feature is enabled. + println!("cargo:rustc-link-arg-bins=-Tinterrupt_group.x"); Ok(()) } -- cgit From c88bc972316634da586589adcefa49bb02a2cf0f Mon Sep 17 00:00:00 2001 From: okhsunrog Date: Wed, 21 May 2025 22:33:44 +0300 Subject: added eeprom to tests --- tests/stm32/Cargo.toml | 10 ++++++++-- tests/stm32/src/bin/eeprom.rs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/stm32/src/bin/eeprom.rs (limited to 'tests') diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 6036a5a97..5a483849c 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -19,8 +19,8 @@ stm32h563zi = ["embassy-stm32/stm32h563zi", "spi-v345", "chrono", "eth", "rng", stm32h753zi = ["embassy-stm32/stm32h753zi", "spi-v345", "chrono", "not-gpdma", "eth", "rng", "fdcan", "hash", "cryp"] stm32h755zi = ["embassy-stm32/stm32h755zi-cm7", "spi-v345", "chrono", "not-gpdma", "eth", "dac", "rng", "fdcan", "hash", "cryp"] stm32h7a3zi = ["embassy-stm32/stm32h7a3zi", "spi-v345", "not-gpdma", "rng", "fdcan"] -stm32l073rz = ["embassy-stm32/stm32l073rz", "cm0", "not-gpdma", "rng"] -stm32l152re = ["embassy-stm32/stm32l152re", "spi-v1", "chrono", "not-gpdma"] +stm32l073rz = ["embassy-stm32/stm32l073rz", "cm0", "not-gpdma", "rng", "eeprom"] +stm32l152re = ["embassy-stm32/stm32l152re", "spi-v1", "chrono", "not-gpdma", "eeprom"] stm32l496zg = ["embassy-stm32/stm32l496zg", "not-gpdma", "rng"] stm32l4a6zg = ["embassy-stm32/stm32l4a6zg", "chrono", "not-gpdma", "rng", "hash"] stm32l4r5zi = ["embassy-stm32/stm32l4r5zi", "chrono", "not-gpdma", "rng", "dual-bank"] @@ -55,6 +55,7 @@ ucpd = [] cordic = ["dep:num-traits"] dual-bank = ["embassy-stm32/dual-bank"] single-bank = ["embassy-stm32/single-bank"] +eeprom = [] cm0 = ["portable-atomic/unsafe-assume-single-core"] @@ -119,6 +120,11 @@ name = "dac_l1" path = "src/bin/dac_l1.rs" required-features = [ "stm32l152re",] +[[bin]] +name = "eeprom" +path = "src/bin/eeprom.rs" +required-features = [ "eeprom",] + [[bin]] name = "eth" path = "src/bin/eth.rs" diff --git a/tests/stm32/src/bin/eeprom.rs b/tests/stm32/src/bin/eeprom.rs new file mode 100644 index 000000000..61d249fd7 --- /dev/null +++ b/tests/stm32/src/bin/eeprom.rs @@ -0,0 +1,30 @@ +#![no_std] +#![no_main] + +// required-features: eeprom + +#[path = "../common.rs"] +mod common; + +use common::*; +use defmt::assert_eq; +use embassy_executor::Spawner; +use embassy_stm32::flash::Flash; +use {defmt_rtt as _, panic_probe as _}; + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + // Initialize the board and obtain a Peripherals instance + let p: embassy_stm32::Peripherals = init(); + + let mut f = Flash::new_blocking(p.FLASH); + const ADDR: u32 = 0x0; + + unwrap!(f.eeprom_write_slice(ADDR, &[1, 2, 3, 4, 5, 6, 7, 8])); + let mut buf = [0u8; 8]; + unwrap!(f.eeprom_read_slice(ADDR, &mut buf)); + assert_eq!(&buf[..], &[1, 2, 3, 4, 5, 6, 7, 8]); + + info!("Test OK"); + cortex_m::asm::bkpt(); +} -- cgit From 5e49985ed678659e199c58c8100e3ed18d2f6227 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Thu, 22 May 2025 11:42:15 +0800 Subject: embassy-sync: bump to 0.7.0 --- tests/mspm0/Cargo.toml | 2 +- tests/nrf/Cargo.toml | 2 +- tests/riscv32/Cargo.toml | 2 +- tests/rp/Cargo.toml | 2 +- tests/stm32/Cargo.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/mspm0/Cargo.toml b/tests/mspm0/Cargo.toml index 386536bee..298522d09 100644 --- a/tests/mspm0/Cargo.toml +++ b/tests/mspm0/Cargo.toml @@ -10,7 +10,7 @@ mspm0g3507 = [ "embassy-mspm0/mspm0g3507pm" ] [dependencies] teleprobe-meta = "1.1" -embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = [ "defmt" ] } +embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = [ "defmt" ] } embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = [ "arch-cortex-m", "executor-thread", "defmt" ] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = [ "defmt" ] } embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = [ "rt", "defmt", "unstable-pac", "time-driver-any" ] } diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index 32087940e..30c4223b7 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" teleprobe-meta = "1" embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt", ] } +embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt", ] } embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.3.1", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } diff --git a/tests/riscv32/Cargo.toml b/tests/riscv32/Cargo.toml index 446326d8a..c5f6a1194 100644 --- a/tests/riscv32/Cargo.toml +++ b/tests/riscv32/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] critical-section = { version = "1.1.1", features = ["restore-state-bool"] } -embassy-sync = { version = "0.6.2", path = "../../embassy-sync" } +embassy-sync = { version = "0.7.0", path = "../../embassy-sync" } embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-riscv32", "executor-thread"] } embassy-time = { version = "0.4.0", path = "../../embassy-time" } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 2c2ed73cc..2be37f525 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -12,7 +12,7 @@ rp235xb = ["embassy-rp/rp235xb"] [dependencies] teleprobe-meta = "1.1" -embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", ] } embassy-rp = { version = "0.4.0", path = "../../embassy-rp", features = [ "defmt", "unstable-pac", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 6036a5a97..e78520e40 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -61,7 +61,7 @@ cm0 = ["portable-atomic/unsafe-assume-single-core"] [dependencies] teleprobe-meta = "1" -embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "tick-hz-131_072", "defmt-timestamp-uptime"] } embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "memory-x", "time-driver-any"] } -- cgit From ea36d121db8dc71ebd205040cdd4b99fe5c2086c Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 22 May 2025 14:01:40 -0700 Subject: embassy-rp: implement input/output inversion RP2040/RP23xx support inversion in HW of the inputs and outputs. Implement minimal support for that. --- tests/rp/src/bin/gpio.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests') diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs index 614b6317a..8bd0df8d8 100644 --- a/tests/rp/src/bin/gpio.rs +++ b/tests/rp/src/bin/gpio.rs @@ -67,6 +67,40 @@ async fn main(_spawner: Spawner) { } } + // Test input inversion + { + let mut b = Input::new(b.reborrow(), Pull::None); + b.set_inversion(true); + // no pull, the status is undefined + + let mut a = Output::new(a.reborrow(), Level::Low); + delay(); + assert!(b.is_high()); + a.set_high(); + delay(); + assert!(b.is_low()); + + b.set_inversion(false); + a.set_inversion(true); + + a.set_low(); + delay(); + assert!(b.is_high()); + + a.set_high(); + delay(); + assert!(b.is_low()); + + b.set_inversion(true); + a.set_high(); + delay(); + assert!(b.is_high()); + + a.set_high(); + delay(); + assert!(b.is_high()); + } + // Test input no pull { let b = Input::new(b.reborrow(), Pull::None); -- cgit From 84cc949df649c9b3625a65c2cc14e09155deeede Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 30 Jun 2025 00:18:44 +0200 Subject: stm32/dma: fix packing/unpacking not working. --- tests/stm32/src/bin/cryp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/stm32/src/bin/cryp.rs b/tests/stm32/src/bin/cryp.rs index 028775ac8..f54c99cc3 100644 --- a/tests/stm32/src/bin/cryp.rs +++ b/tests/stm32/src/bin/cryp.rs @@ -72,7 +72,7 @@ async fn main(_spawner: Spawner) { defmt::assert!(encrypt_tag == payload_vec[ciphertext.len()..ciphertext.len() + encrypt_tag.len()]); // Decrypt in software using AES-GCM 128-bit - let _ = cipher.decrypt_in_place(&iv.into(), &aad, &mut payload_vec); + cipher.decrypt_in_place(&iv.into(), &aad, &mut payload_vec).unwrap(); info!("Test OK"); cortex_m::asm::bkpt(); -- cgit From a29267752a382ff52b052233586ef9007fe84fed Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 4 Jul 2025 00:26:41 +0200 Subject: stm32/sdmmc: disable 1bit test. --- tests/stm32/src/bin/sdmmc.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/stm32/src/bin/sdmmc.rs b/tests/stm32/src/bin/sdmmc.rs index 34a53a725..9f9c526e1 100644 --- a/tests/stm32/src/bin/sdmmc.rs +++ b/tests/stm32/src/bin/sdmmc.rs @@ -95,6 +95,9 @@ async fn main(_spawner: Spawner) { drop(s); + // FIXME: this hangs on Rust 1.86 and higher. + // I haven't been able to figure out why. + /* // ======== Try 1bit. ============== info!("initializing in 1-bit mode..."); let mut s = Sdmmc::new_1bit( @@ -151,6 +154,7 @@ async fn main(_spawner: Spawner) { assert_eq!(&blocks, &patterns); drop(s); + */ info!("Test OK"); cortex_m::asm::bkpt(); -- cgit From e57dffafa5723931dd529afe8e22cba0c9ea09f0 Mon Sep 17 00:00:00 2001 From: i509VCB Date: Mon, 23 Jun 2025 23:15:09 -0500 Subject: mspm0: add dma driver --- tests/mspm0/Cargo.toml | 1 + tests/mspm0/build.rs | 3 + tests/mspm0/memory_g3519.x | 6 + tests/mspm0/src/bin/dma.rs | 503 ++++++++++++++++++++++++++++++++++++++++++++ tests/mspm0/src/bin/uart.rs | 5 +- 5 files changed, 517 insertions(+), 1 deletion(-) create mode 100644 tests/mspm0/memory_g3519.x create mode 100644 tests/mspm0/src/bin/dma.rs (limited to 'tests') diff --git a/tests/mspm0/Cargo.toml b/tests/mspm0/Cargo.toml index 386536bee..1c6f7d1cd 100644 --- a/tests/mspm0/Cargo.toml +++ b/tests/mspm0/Cargo.toml @@ -6,6 +6,7 @@ license = "MIT OR Apache-2.0" [features] mspm0g3507 = [ "embassy-mspm0/mspm0g3507pm" ] +mspm0g3519 = [ "embassy-mspm0/mspm0g3519pz" ] [dependencies] teleprobe-meta = "1.1" diff --git a/tests/mspm0/build.rs b/tests/mspm0/build.rs index 0b58fb9e9..43a9ac04f 100644 --- a/tests/mspm0/build.rs +++ b/tests/mspm0/build.rs @@ -8,6 +8,9 @@ fn main() -> Result<(), Box> { #[cfg(feature = "mspm0g3507")] let memory_x = include_bytes!("memory_g3507.x"); + #[cfg(feature = "mspm0g3519")] + let memory_x = include_bytes!("memory_g3519.x"); + fs::write(out.join("memory.x"), memory_x).unwrap(); println!("cargo:rustc-link-search={}", out.display()); diff --git a/tests/mspm0/memory_g3519.x b/tests/mspm0/memory_g3519.x new file mode 100644 index 000000000..d62f10360 --- /dev/null +++ b/tests/mspm0/memory_g3519.x @@ -0,0 +1,6 @@ +MEMORY +{ + FLASH : ORIGIN = 0x00000000, LENGTH = 128K + /* Select non-parity range of SRAM due to SRAM_ERR_01 errata in SLAZ758 */ + RAM : ORIGIN = 0x20200000, LENGTH = 64K +} diff --git a/tests/mspm0/src/bin/dma.rs b/tests/mspm0/src/bin/dma.rs new file mode 100644 index 000000000..6fd973a18 --- /dev/null +++ b/tests/mspm0/src/bin/dma.rs @@ -0,0 +1,503 @@ +#![no_std] +#![no_main] + +#[cfg(feature = "mspm0g3507")] +teleprobe_meta::target!(b"lp-mspm0g3507"); + +#[cfg(feature = "mspm0g3519")] +teleprobe_meta::target!(b"lp-mspm0g3519"); + +use core::slice; + +use defmt::{assert, assert_eq, *}; +use embassy_executor::Spawner; +use embassy_mspm0::dma::{Channel, Transfer, TransferMode, TransferOptions, Word}; +use embassy_mspm0::Peri; +use {defmt_rtt as _, panic_probe as _}; + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let mut p = embassy_mspm0::init(Default::default()); + info!("Hello World!"); + + { + info!("Single u8 read (blocking)"); + single_read(p.DMA_CH0.reborrow(), 0x41_u8); + + info!("Single u16 read (blocking)"); + single_read(p.DMA_CH0.reborrow(), 0xFF41_u16); + + info!("Single u32 read (blocking)"); + single_read(p.DMA_CH0.reborrow(), 0xFFEE_FF41_u32); + + info!("Single u64 read (blocking)"); + single_read(p.DMA_CH0.reborrow(), 0x0011_2233_FFEE_FF41_u64); + } + + // Widening transfers + { + info!("Single u8 read to u16"); + widening_single_read::(p.DMA_CH0.reborrow(), 0x41); + + info!("Single u8 read to u32"); + widening_single_read::(p.DMA_CH0.reborrow(), 0x43); + + info!("Single u8 read to u64"); + widening_single_read::(p.DMA_CH0.reborrow(), 0x47); + + info!("Single u16 read to u32"); + widening_single_read::(p.DMA_CH0.reborrow(), 0xAE43); + + info!("Single u16 read to u64"); + widening_single_read::(p.DMA_CH0.reborrow(), 0xAF47); + + info!("Single u32 read to u64"); + widening_single_read::(p.DMA_CH0.reborrow(), 0xDEAD_AF47); + } + + // Narrowing transfers. + { + info!("Single u16 read to u8"); + narrowing_single_read::(p.DMA_CH0.reborrow(), 0x4142); + + info!("Single u32 read to u8"); + narrowing_single_read::(p.DMA_CH0.reborrow(), 0x4142_2414); + + info!("Single u64 read to u8"); + narrowing_single_read::(p.DMA_CH0.reborrow(), 0x4142_2414_5153_7776); + + info!("Single u32 read to u16"); + narrowing_single_read::(p.DMA_CH0.reborrow(), 0x4142_2414); + + info!("Single u64 read to u16"); + narrowing_single_read::(p.DMA_CH0.reborrow(), 0x4142_2414_5153_7776); + + info!("Single u64 read to u32"); + narrowing_single_read::(p.DMA_CH0.reborrow(), 0x4142_2414_5153_7776); + } + + { + info!("Single u8 read (async)"); + async_single_read(p.DMA_CH0.reborrow(), 0x42_u8).await; + + info!("Single u16 read (async)"); + async_single_read(p.DMA_CH0.reborrow(), 0xAE42_u16).await; + + info!("Single u32 read (async)"); + async_single_read(p.DMA_CH0.reborrow(), 0xFE44_1500_u32).await; + + info!("Single u64 read (async)"); + async_single_read(p.DMA_CH0.reborrow(), 0x8F7F_6F5F_4F3F_2F1F_u64).await; + } + + { + info!("Multiple u8 reads (blocking)"); + block_read::<_, 16>(p.DMA_CH0.reborrow(), 0x98_u8); + + info!("Multiple u16 reads (blocking)"); + block_read::<_, 2>(p.DMA_CH0.reborrow(), 0x9801_u16); + + info!("Multiple u32 reads (blocking)"); + block_read::<_, 4>(p.DMA_CH0.reborrow(), 0x9821_9801_u32); + + info!("Multiple u64 reads (blocking)"); + block_read::<_, 4>(p.DMA_CH0.reborrow(), 0xABCD_EF01_2345_6789_u64); + } + + { + info!("Multiple u8 reads (async)"); + async_block_read::<_, 8>(p.DMA_CH0.reborrow(), 0x86_u8).await; + + info!("Multiple u16 reads (async)"); + async_block_read::<_, 6>(p.DMA_CH0.reborrow(), 0x7777_u16).await; + + info!("Multiple u32 reads (async)"); + async_block_read::<_, 3>(p.DMA_CH0.reborrow(), 0xA5A5_A5A5_u32).await; + + info!("Multiple u64 reads (async)"); + async_block_read::<_, 14>(p.DMA_CH0.reborrow(), 0x5A5A_5A5A_A5A5_A5A5_u64).await; + } + + // Intentionally skip testing multiple reads in single transfer mode. + // + // If the destination length is greater than 1 and single transfer mode is used then two transfers + // are performed in a trigger. Similarly with any other length of destination above 2, only 2 transfers + // are performed. Issuing another trigger (resume) results in no further progress. More than likely + // the test does not work due to some combination of a hardware bug and the datasheet being unclear + // regarding what ends a software trigger. + // + // However this case works fine with a hardware trigger (such as the ADC hardware trigger). + + { + info!("Single u8 write (blocking)"); + single_write(p.DMA_CH0.reborrow(), 0x41_u8); + + info!("Single u16 write (blocking)"); + single_write(p.DMA_CH0.reborrow(), 0x4142_u16); + + info!("Single u32 write (blocking)"); + single_write(p.DMA_CH0.reborrow(), 0x4142_4344_u32); + + info!("Single u64 write (blocking)"); + single_write(p.DMA_CH0.reborrow(), 0x4142_4344_4546_4748_u64); + } + + { + info!("Single u8 write (async)"); + async_single_write(p.DMA_CH0.reborrow(), 0xAA_u8).await; + + info!("Single u16 write (async)"); + async_single_write(p.DMA_CH0.reborrow(), 0xBBBB_u16).await; + + info!("Single u32 write (async)"); + async_single_write(p.DMA_CH0.reborrow(), 0xCCCC_CCCC_u32).await; + + info!("Single u64 write (async)"); + async_single_write(p.DMA_CH0.reborrow(), 0xDDDD_DDDD_DDDD_DDDD_u64).await; + } + + { + info!("Multiple u8 writes (blocking)"); + block_write(p.DMA_CH0.reborrow(), &[0xFF_u8, 0x7F, 0x3F, 0x1F]); + + info!("Multiple u16 writes (blocking)"); + block_write(p.DMA_CH0.reborrow(), &[0xFFFF_u16, 0xFF7F, 0xFF3F, 0xFF1F]); + + info!("Multiple u32 writes (blocking)"); + block_write( + p.DMA_CH0.reborrow(), + &[0xFF00_00FF_u32, 0xFF00_007F, 0x0000_FF3F, 0xFF1F_0000], + ); + + info!("Multiple u64 writes (blocking)"); + block_write( + p.DMA_CH0.reborrow(), + &[ + 0xFF00_0000_0000_00FF_u64, + 0x0000_FF00_007F_0000, + 0x0000_FF3F_0000_0000, + 0xFF1F_0000_1111_837A, + ], + ); + } + + { + info!("Multiple u8 writes (async)"); + async_block_write(p.DMA_CH0.reborrow(), &[0u8, 1, 2, 3]).await; + + info!("Multiple u16 writes (async)"); + async_block_write(p.DMA_CH0.reborrow(), &[0x9801u16, 0x9802, 0x9803, 0x9800, 0x9000]).await; + + info!("Multiple u32 writes (async)"); + async_block_write(p.DMA_CH0.reborrow(), &[0x9801_ABCDu32, 0xFFAC_9802, 0xDEAD_9803]).await; + + info!("Multiple u64 writes (async)"); + async_block_write( + p.DMA_CH0.reborrow(), + &[ + 0xA55A_1111_3333_5555_u64, + 0x1111_A55A_3333_5555, + 0x5555_A55A_3333_1111, + 0x01234_5678_89AB_CDEF, + ], + ) + .await; + } + + // TODO: Mixed byte and word transfers. + + info!("Test OK"); + cortex_m::asm::bkpt(); +} + +fn single_read(mut channel: Peri<'_, impl Channel>, mut src: W) { + let options = TransferOptions::default(); + let mut dst = W::default(); + + // SAFETY: src and dst outlive the transfer. + let transfer = unsafe { + unwrap!(Transfer::new_read( + channel.reborrow(), + Transfer::SOFTWARE_TRIGGER, + &mut src, + slice::from_mut(&mut dst), + options, + )) + }; + transfer.blocking_wait(); + + assert_eq!(src, dst); +} + +async fn async_single_read( + mut channel: Peri<'_, impl Channel>, + mut src: W, +) { + let options = TransferOptions::default(); + let mut dst = W::default(); + + // SAFETY: src and dst outlive the transfer. + let transfer = unsafe { + unwrap!(Transfer::new_read( + channel.reborrow(), + Transfer::SOFTWARE_TRIGGER, + &mut src, + slice::from_mut(&mut dst), + options, + )) + }; + transfer.await; + + assert_eq!(src, dst); +} + +fn block_read( + mut channel: Peri<'_, impl Channel>, + mut src: W, +) { + let mut options = TransferOptions::default(); + // Complete the entire transfer. + options.mode = TransferMode::Block; + + let mut dst = [W::default(); N]; + + // SAFETY: src and dst outlive the transfer. + let transfer = unsafe { + unwrap!(Transfer::new_read( + channel.reborrow(), + Transfer::SOFTWARE_TRIGGER, + &mut src, + &mut dst[..], + options, + )) + }; + transfer.blocking_wait(); + + assert_eq!(dst, [src; N]); +} + +async fn async_block_read( + mut channel: Peri<'_, impl Channel>, + mut src: W, +) { + let mut options = TransferOptions::default(); + // Complete the entire transfer. + options.mode = TransferMode::Block; + + let mut dst = [W::default(); N]; + + // SAFETY: src and dst outlive the transfer. + let transfer = unsafe { + unwrap!(Transfer::new_read( + channel.reborrow(), + Transfer::SOFTWARE_TRIGGER, + &mut src, + &mut dst[..], + options, + )) + }; + transfer.await; + + assert_eq!(dst, [src; N]); +} + +fn single_write(mut channel: Peri<'_, impl Channel>, src: W) { + let options = TransferOptions::default(); + let mut dst = W::default(); + + // SAFETY: src and dst outlive the transfer. + let transfer = unsafe { + unwrap!(Transfer::new_write( + channel.reborrow(), + Transfer::SOFTWARE_TRIGGER, + slice::from_ref(&src), + &mut dst, + options, + )) + }; + transfer.blocking_wait(); + + assert_eq!(src, dst); +} + +async fn async_single_write(mut channel: Peri<'_, impl Channel>, src: W) { + let options = TransferOptions::default(); + let mut dst = W::default(); + + // SAFETY: src and dst outlive the transfer. + let transfer = unsafe { + unwrap!(Transfer::new_write( + channel.reborrow(), + Transfer::SOFTWARE_TRIGGER, + slice::from_ref(&src), + &mut dst, + options, + )) + }; + transfer.await; + + assert_eq!(src, dst); +} + +fn block_write(mut channel: Peri<'_, impl Channel>, src: &[W]) { + let mut options = TransferOptions::default(); + // Complete the entire transfer. + options.mode = TransferMode::Block; + + let mut dst = W::default(); + + // Starting from 1 because a zero length transfer does nothing. + for i in 1..src.len() { + info!("-> {} write(s)", i); + + // SAFETY: src and dst outlive the transfer. + let transfer = unsafe { + unwrap!(Transfer::new_write( + channel.reborrow(), + Transfer::SOFTWARE_TRIGGER, + &src[..i], + &mut dst, + options, + )) + }; + transfer.blocking_wait(); + + // The result will be the last value written. + assert_eq!(dst, src[i - 1]); + } +} + +async fn async_block_write(mut channel: Peri<'_, impl Channel>, src: &[W]) { + let mut options = TransferOptions::default(); + // Complete the entire transfer. + options.mode = TransferMode::Block; + + let mut dst = W::default(); + + // Starting from 1 because a zero length transfer does nothing. + for i in 1..src.len() { + info!("-> {} write(s)", i); + // SAFETY: src and dst outlive the transfer. + let transfer = unsafe { + unwrap!(Transfer::new_write( + channel.reborrow(), + Transfer::SOFTWARE_TRIGGER, + &src[..i], + &mut dst, + options, + )) + }; + transfer.await; + + // The result will be the last value written. + assert_eq!(dst, src[i - 1]); + } +} + +/// [`single_read`], but testing when the destination is wider than the source. +/// +/// The MSPM0 DMA states that the upper bytes when the destination is longer than the source are zeroed. +/// This matches the behavior in Rust for all unsigned integer types. +fn widening_single_read(mut channel: Peri<'_, impl Channel>, mut src: SW) +where + SW: Word + Copy + Default + Eq + defmt::Format, + DW: Word + Copy + Default + Eq + defmt::Format + From, +{ + assert!( + DW::size() > SW::size(), + "This test only works when the destination is larger than the source" + ); + + let options = TransferOptions::default(); + let mut dst = DW::default(); + + // SAFETY: src and dst outlive the transfer. + let transfer = unsafe { + unwrap!(Transfer::new_read( + channel.reborrow(), + Transfer::SOFTWARE_TRIGGER, + &mut src, + slice::from_mut(&mut dst), + options, + )) + }; + transfer.blocking_wait(); + + assert_eq!(DW::from(src), dst); +} + +/// [`single_read`], but testing when the destination is narrower than the source. +/// +/// The MSPM0 DMA states that the upper bytes when the source is longer than the destination are dropped. +/// This matches the behavior in Rust for all unsigned integer types. +fn narrowing_single_read(mut channel: Peri<'_, impl Channel>, mut src: SW) +where + SW: Word + Copy + Default + Eq + defmt::Format + From, + DW: Word + Copy + Default + Eq + defmt::Format + Narrow, +{ + assert!( + SW::size() > DW::size(), + "This test only works when the source is larger than the destination" + ); + + let options = TransferOptions::default(); + let mut dst = DW::default(); + + // SAFETY: src and dst outlive the transfer. + let transfer = unsafe { + unwrap!(Transfer::new_read( + channel.reborrow(), + Transfer::SOFTWARE_TRIGGER, + &mut src, + slice::from_mut(&mut dst), + options, + )) + }; + transfer.blocking_wait(); + + // The expected value is the source value masked by the maximum destination value. + // This is effectively `src as DW as SW` to drop the upper byte(s). + let expect = SW::from(DW::narrow(src)); + assert_eq!(expect, dst.into()); +} + +/// A pseudo `as` trait to allow downcasting integer types (TryFrom could fail). +trait Narrow { + fn narrow(value: T) -> Self; +} + +impl Narrow for u8 { + fn narrow(value: u16) -> Self { + value as u8 + } +} + +impl Narrow for u8 { + fn narrow(value: u32) -> Self { + value as u8 + } +} + +impl Narrow for u8 { + fn narrow(value: u64) -> Self { + value as u8 + } +} + +impl Narrow for u16 { + fn narrow(value: u32) -> Self { + value as u16 + } +} + +impl Narrow for u16 { + fn narrow(value: u64) -> Self { + value as u16 + } +} + +impl Narrow for u32 { + fn narrow(value: u64) -> Self { + value as u32 + } +} diff --git a/tests/mspm0/src/bin/uart.rs b/tests/mspm0/src/bin/uart.rs index 458129d44..916ce0d4b 100644 --- a/tests/mspm0/src/bin/uart.rs +++ b/tests/mspm0/src/bin/uart.rs @@ -4,6 +4,9 @@ #[cfg(feature = "mspm0g3507")] teleprobe_meta::target!(b"lp-mspm0g3507"); +#[cfg(feature = "mspm0g3519")] +teleprobe_meta::target!(b"lp-mspm0g3519"); + use defmt::{assert_eq, unwrap, *}; use embassy_executor::Spawner; use embassy_mspm0::mode::Blocking; @@ -23,7 +26,7 @@ async fn main(_spawner: Spawner) { // TODO: Allow creating a looped-back UART (so pins are not needed). // Do not select default UART since the virtual COM port is attached to UART0. - #[cfg(feature = "mspm0g3507")] + #[cfg(any(feature = "mspm0g3507", feature = "mspm0g3519"))] let (mut tx, mut rx, mut uart) = (p.PA8, p.PA9, p.UART1); const MFCLK_BUAD_RATES: &[u32] = &[1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200]; -- cgit From 1df59ffec4eed74ade4086da496a32d376e4190a Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Mon, 14 Jul 2025 11:40:51 +0200 Subject: chore: update to `embassy-nrf` v0.4.0 --- tests/nrf/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index 30c4223b7..b46498a7a 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -11,7 +11,7 @@ embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt", ] } embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } -embassy-nrf = { version = "0.3.1", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } +embassy-nrf = { version = "0.4.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } embassy-net-esp-hosted = { version = "0.2.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } -- cgit From c7e33b28b8134662a0e0cf3e7215a78a00b2f1dd Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Mon, 14 Jul 2025 11:50:13 +0200 Subject: Revert "chore: update to `embassy-nrf` v0.4.0" This reverts commit 1df59ffec4eed74ade4086da496a32d376e4190a. --- tests/nrf/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index b46498a7a..30c4223b7 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -11,7 +11,7 @@ embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt", ] } embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } -embassy-nrf = { version = "0.4.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } +embassy-nrf = { version = "0.3.1", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } embassy-net-esp-hosted = { version = "0.2.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } -- cgit From 4f50c85221f11eecb334169e98d96b7fb94a2753 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Mon, 14 Jul 2025 11:40:51 +0200 Subject: chore: update to `embassy-nrf` v0.4.0 --- tests/nrf/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index 30c4223b7..b46498a7a 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -11,7 +11,7 @@ embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt", ] } embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } -embassy-nrf = { version = "0.3.1", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } +embassy-nrf = { version = "0.4.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } embassy-net-esp-hosted = { version = "0.2.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } -- cgit From 9811f1c999521a80cccf82cfe1a5192f9112b5af Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Tue, 15 Jul 2025 11:10:56 +0200 Subject: chore: prepare embassy-rp for release --- tests/rp/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 2be37f525..567c2a7b1 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -15,7 +15,7 @@ teleprobe-meta = "1.1" embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", ] } -embassy-rp = { version = "0.4.0", path = "../../embassy-rp", features = [ "defmt", "unstable-pac", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } +embassy-rp = { version = "0.5.0", path = "../../embassy-rp", features = [ "defmt", "unstable-pac", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } embassy-net-wiznet = { version = "0.2.0", path = "../../embassy-net-wiznet", features = ["defmt"] } -- cgit From 386c586afab378584a8622f32bdeb14a6ae60645 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Wed, 16 Jul 2025 14:52:21 +0200 Subject: chore: Release embassy-embedded-hal version 0.3.1 --- tests/mspm0/Cargo.toml | 2 +- tests/rp/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/mspm0/Cargo.toml b/tests/mspm0/Cargo.toml index 5d34ece7e..2d5b8cd52 100644 --- a/tests/mspm0/Cargo.toml +++ b/tests/mspm0/Cargo.toml @@ -15,7 +15,7 @@ embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = [ "d embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = [ "arch-cortex-m", "executor-thread", "defmt" ] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = [ "defmt" ] } embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = [ "rt", "defmt", "unstable-pac", "time-driver-any" ] } -embassy-embedded-hal = { version = "0.3.0", path = "../../embassy-embedded-hal/"} +embassy-embedded-hal = { version = "0.3.1", path = "../../embassy-embedded-hal/"} defmt = "1.0.1" defmt-rtt = "1.0.0" diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 567c2a7b1..86eded861 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -19,7 +19,7 @@ embassy-rp = { version = "0.5.0", path = "../../embassy-rp", features = [ "defmt embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } embassy-net-wiznet = { version = "0.2.0", path = "../../embassy-net-wiznet", features = ["defmt"] } -embassy-embedded-hal = { version = "0.3.0", path = "../../embassy-embedded-hal/"} +embassy-embedded-hal = { version = "0.3.1", path = "../../embassy-embedded-hal/"} cyw43 = { path = "../../cyw43", features = ["defmt", "firmware-logs"] } cyw43-pio = { path = "../../cyw43-pio", features = ["defmt"] } perf-client = { path = "../perf-client" } -- cgit From 8c087e3641e2bf1f863c73a388b2f483051e6b29 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Wed, 16 Jul 2025 15:47:37 +0200 Subject: chore: release embassy-nrf 0.5.0 and embassy-rp 0.6.0 --- tests/nrf/Cargo.toml | 2 +- tests/rp/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index b46498a7a..b167c589e 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -11,7 +11,7 @@ embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt", ] } embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } -embassy-nrf = { version = "0.4.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } +embassy-nrf = { version = "0.5.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } embassy-net-esp-hosted = { version = "0.2.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 86eded861..298955fe3 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -15,7 +15,7 @@ teleprobe-meta = "1.1" embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", ] } -embassy-rp = { version = "0.5.0", path = "../../embassy-rp", features = [ "defmt", "unstable-pac", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } +embassy-rp = { version = "0.6.0", path = "../../embassy-rp", features = [ "defmt", "unstable-pac", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } embassy-net-wiznet = { version = "0.2.0", path = "../../embassy-net-wiznet", features = ["defmt"] } -- cgit From a1867f0d742f597a25384e4a33209beeec7ec676 Mon Sep 17 00:00:00 2001 From: i509VCB Date: Sun, 6 Jul 2025 17:35:19 -0500 Subject: mspm0: add buffered uart driver And tests for G3507. --- tests/mspm0/Cargo.toml | 3 + tests/mspm0/src/bin/uart_buffered.rs | 115 +++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 tests/mspm0/src/bin/uart_buffered.rs (limited to 'tests') diff --git a/tests/mspm0/Cargo.toml b/tests/mspm0/Cargo.toml index 2d5b8cd52..5ba3e586b 100644 --- a/tests/mspm0/Cargo.toml +++ b/tests/mspm0/Cargo.toml @@ -13,6 +13,7 @@ teleprobe-meta = "1.1" embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = [ "defmt" ] } embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = [ "arch-cortex-m", "executor-thread", "defmt" ] } +embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = [ "defmt" ] } embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = [ "rt", "defmt", "unstable-pac", "time-driver-any" ] } embassy-embedded-hal = { version = "0.3.1", path = "../../embassy-embedded-hal/"} @@ -24,6 +25,8 @@ cortex-m = { version = "0.7.6", features = [ "inline-asm", "critical-section-sin cortex-m-rt = "0.7.0" embedded-hal = { package = "embedded-hal", version = "1.0" } embedded-hal-async = { version = "1.0" } +embedded-io = { version = "0.6.1", features = ["defmt-03"] } +embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } panic-probe = { version = "1.0.0", features = ["print-defmt"] } static_cell = "2" portable-atomic = { version = "1.5", features = ["critical-section"] } diff --git a/tests/mspm0/src/bin/uart_buffered.rs b/tests/mspm0/src/bin/uart_buffered.rs new file mode 100644 index 000000000..135ac1287 --- /dev/null +++ b/tests/mspm0/src/bin/uart_buffered.rs @@ -0,0 +1,115 @@ +#![no_std] +#![no_main] + +#[cfg(feature = "mspm0g3507")] +teleprobe_meta::target!(b"lp-mspm0g3507"); + +use defmt::{assert_eq, unwrap, *}; +use embassy_executor::Spawner; +use embassy_mspm0::uart::{BufferedInterruptHandler, BufferedUart, Config}; +use embassy_mspm0::{bind_interrupts, peripherals}; +use {defmt_rtt as _, panic_probe as _}; + +bind_interrupts!(struct Irqs { + UART1 => BufferedInterruptHandler; +}); + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p = embassy_mspm0::init(Default::default()); + info!("Hello World!"); + + // TODO: Allow creating a looped-back UART (so pins are not needed). + // Do not select default UART since the virtual COM port is attached to UART0. + #[cfg(any(feature = "mspm0g3507"))] + let (mut tx, mut rx, mut uart) = (p.PA8, p.PA9, p.UART1); + + { + use embedded_io_async::{Read, Write}; + + let mut config = Config::default(); + config.loop_back_enable = true; + config.fifo_enable = false; + + let tx_buf = &mut [0u8; 16]; + let rx_buf = &mut [0u8; 16]; + let mut uart = unwrap!(BufferedUart::new( + uart.reborrow(), + tx.reborrow(), + rx.reborrow(), + Irqs, + tx_buf, + rx_buf, + config + )); + + let mut buf = [0; 16]; + for (j, b) in buf.iter_mut().enumerate() { + *b = j as u8; + } + + unwrap!(uart.write_all(&buf).await); + unwrap!(uart.flush().await); + + unwrap!(uart.read_exact(&mut buf).await); + for (j, b) in buf.iter().enumerate() { + assert_eq!(*b, j as u8); + } + + // Buffer is unclogged, should be able to write again. + unwrap!(uart.write_all(&buf).await); + unwrap!(uart.flush().await); + + unwrap!(uart.read_exact(&mut buf).await); + for (j, b) in buf.iter().enumerate() { + assert_eq!(*b, j as u8); + } + } + + info!("Blocking buffered"); + { + use embedded_io::{Read, Write}; + + let mut config = Config::default(); + config.loop_back_enable = true; + config.fifo_enable = false; + + let tx_buf = &mut [0u8; 16]; + let rx_buf = &mut [0u8; 16]; + let mut uart = unwrap!(BufferedUart::new( + uart.reborrow(), + tx.reborrow(), + rx.reborrow(), + Irqs, + tx_buf, + rx_buf, + config + )); + + let mut buf = [0; 16]; + + for (j, b) in buf.iter_mut().enumerate() { + *b = j as u8; + } + + unwrap!(uart.write_all(&buf)); + unwrap!(uart.blocking_flush()); + unwrap!(uart.read_exact(&mut buf)); + + for (j, b) in buf.iter().enumerate() { + assert_eq!(*b, j as u8); + } + + // Buffer is unclogged, should be able to write again. + unwrap!(uart.write_all(&buf)); + unwrap!(uart.blocking_flush()); + unwrap!(uart.read_exact(&mut buf)); + + for (j, b) in buf.iter().enumerate() { + assert_eq!(*b, j as u8, "at {}", j); + } + } + + info!("Test OK"); + cortex_m::asm::bkpt(); +} -- cgit From e64c23076d2c003efe60419eab6b86630d7886b4 Mon Sep 17 00:00:00 2001 From: Chris Storah Date: Wed, 23 Jul 2025 12:38:58 +1000 Subject: Updated version of stm32-data and added c071 and c051 into ci.sh --- tests/stm32/Cargo.toml | 1 + tests/stm32/build.rs | 1 + tests/stm32/src/common.rs | 10 +++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 8d10f6593..7c32c0ce1 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -7,6 +7,7 @@ autobins = false [features] stm32c031c6 = ["embassy-stm32/stm32c031c6", "cm0", "not-gpdma"] +stm32c071rb = ["embassy-stm32/stm32c071rb", "cm0", "not-gpdma"] stm32f103c8 = ["embassy-stm32/stm32f103c8", "spi-v1", "not-gpdma"] stm32f207zg = ["embassy-stm32/stm32f207zg", "spi-v1", "chrono", "not-gpdma", "eth", "rng"] stm32f303ze = ["embassy-stm32/stm32f303ze", "chrono", "not-gpdma"] diff --git a/tests/stm32/build.rs b/tests/stm32/build.rs index 722671bf1..556d77a20 100644 --- a/tests/stm32/build.rs +++ b/tests/stm32/build.rs @@ -12,6 +12,7 @@ fn main() -> Result<(), Box> { // too little RAM to run from RAM. feature = "stm32f103c8", // 20 kb feature = "stm32c031c6", // 6 kb + feature = "stm32c071rb", // 24 kb feature = "stm32l073rz", // 20 kb feature = "stm32h503rb", // 32 kb // no VTOR, so interrupts can't work when running from RAM diff --git a/tests/stm32/src/common.rs b/tests/stm32/src/common.rs index 829f2cff0..a4d8048ce 100644 --- a/tests/stm32/src/common.rs +++ b/tests/stm32/src/common.rs @@ -34,6 +34,8 @@ teleprobe_meta::target!(b"nucleo-stm32u5a5zj"); teleprobe_meta::target!(b"nucleo-stm32h563zi"); #[cfg(feature = "stm32c031c6")] teleprobe_meta::target!(b"nucleo-stm32c031c6"); +#[cfg(feature = "stm32c071rb")] +teleprobe_meta::target!(b"nucleo-stm32c071rb"); #[cfg(feature = "stm32l073rz")] teleprobe_meta::target!(b"nucleo-stm32l073rz"); #[cfg(feature = "stm32l152re")] @@ -186,6 +188,12 @@ define_peris!( SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA1_CH1, SPI_RX_DMA = DMA1_CH2, @irq UART = {USART1 => embassy_stm32::usart::InterruptHandler;}, ); +#[cfg(feature = "stm32c071rb")] +define_peris!( + UART = USART1, UART_TX = PB6, UART_RX = PB7, UART_TX_DMA = DMA1_CH1, UART_RX_DMA = DMA1_CH2, + SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA1_CH1, SPI_RX_DMA = DMA1_CH2, + @irq UART = {USART1 => embassy_stm32::usart::InterruptHandler;}, +); #[cfg(feature = "stm32l496zg")] define_peris!( UART = USART3, UART_TX = PD8, UART_RX = PD9, UART_TX_DMA = DMA1_CH2, UART_RX_DMA = DMA1_CH3, @@ -271,7 +279,7 @@ pub fn config() -> Config { #[allow(unused_mut)] let mut config = Config::default(); - #[cfg(feature = "stm32c031c6")] + #[cfg(any(feature = "stm32c031c6", feature = "stm32c071rb"))] { config.rcc.hsi = Some(Hsi { sys_div: HsiSysDiv::DIV1, // 48Mhz -- cgit From c37fb51cfe25511b2222e92e37b80933079ed3fc Mon Sep 17 00:00:00 2001 From: Rick Rogers Date: Fri, 25 Jul 2025 12:24:54 -0400 Subject: address ci test failure --- tests/stm32/src/common.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/stm32/src/common.rs b/tests/stm32/src/common.rs index a4d8048ce..cb63b3374 100644 --- a/tests/stm32/src/common.rs +++ b/tests/stm32/src/common.rs @@ -681,6 +681,8 @@ pub fn config() -> Config { divp: Some(PllDiv::DIV2), // 600Mhz divq: Some(PllDiv::DIV25), // 48Mhz divr: None, + divs: None, + divt: None, }); config.rcc.sys = Sysclk::PLL1_P; // 600 Mhz config.rcc.ahb_pre = AHBPrescaler::DIV2; // 300 Mhz -- cgit From 3f1ddaf60e8fe2ce330ab7d5fefdf4814348df9e Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Thu, 31 Jul 2025 10:32:01 +0200 Subject: chore: prepare embassy-executor 0.8 release --- tests/mspm0/Cargo.toml | 2 +- tests/nrf/Cargo.toml | 2 +- tests/riscv32/Cargo.toml | 2 +- tests/rp/Cargo.toml | 2 +- tests/stm32/Cargo.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/mspm0/Cargo.toml b/tests/mspm0/Cargo.toml index 5ba3e586b..5b570ebec 100644 --- a/tests/mspm0/Cargo.toml +++ b/tests/mspm0/Cargo.toml @@ -12,7 +12,7 @@ mspm0g3519 = [ "embassy-mspm0/mspm0g3519pz" ] teleprobe-meta = "1.1" embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = [ "defmt" ] } -embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = [ "arch-cortex-m", "executor-thread", "defmt" ] } +embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = [ "arch-cortex-m", "executor-thread", "defmt" ] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = [ "defmt" ] } embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = [ "rt", "defmt", "unstable-pac", "time-driver-any" ] } diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index b167c589e..3e1113ccf 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -9,7 +9,7 @@ teleprobe-meta = "1" embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt", ] } -embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } +embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.5.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } diff --git a/tests/riscv32/Cargo.toml b/tests/riscv32/Cargo.toml index c5f6a1194..6bce9a0e3 100644 --- a/tests/riscv32/Cargo.toml +++ b/tests/riscv32/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0" [dependencies] critical-section = { version = "1.1.1", features = ["restore-state-bool"] } embassy-sync = { version = "0.7.0", path = "../../embassy-sync" } -embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-riscv32", "executor-thread"] } +embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-riscv32", "executor-thread"] } embassy-time = { version = "0.4.0", path = "../../embassy-time" } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 298955fe3..ca1fa53da 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -13,7 +13,7 @@ rp235xb = ["embassy-rp/rp235xb"] teleprobe-meta = "1.1" embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } +embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", ] } embassy-rp = { version = "0.6.0", path = "../../embassy-rp", features = [ "defmt", "unstable-pac", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 7c32c0ce1..58ee10d77 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -64,7 +64,7 @@ cm0 = ["portable-atomic/unsafe-assume-single-core"] teleprobe-meta = "1" embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } +embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "tick-hz-131_072", "defmt-timestamp-uptime"] } embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "memory-x", "time-driver-any"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -- cgit From 78a333d008490a7720555abea0b1f78a693d6f76 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sun, 3 Aug 2025 00:44:51 +0200 Subject: Release embassy-embedded-hal v0.4 --- tests/mspm0/Cargo.toml | 2 +- tests/rp/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/mspm0/Cargo.toml b/tests/mspm0/Cargo.toml index 5b570ebec..6742537e5 100644 --- a/tests/mspm0/Cargo.toml +++ b/tests/mspm0/Cargo.toml @@ -16,7 +16,7 @@ embassy-executor = { version = "0.8.0", path = "../../embassy-executor", feature embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = [ "defmt" ] } embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = [ "rt", "defmt", "unstable-pac", "time-driver-any" ] } -embassy-embedded-hal = { version = "0.3.1", path = "../../embassy-embedded-hal/"} +embassy-embedded-hal = { version = "0.4.0", path = "../../embassy-embedded-hal/"} defmt = "1.0.1" defmt-rtt = "1.0.0" diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index ca1fa53da..1f2bbdb22 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -19,7 +19,7 @@ embassy-rp = { version = "0.6.0", path = "../../embassy-rp", features = [ "defmt embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } embassy-net-wiznet = { version = "0.2.0", path = "../../embassy-net-wiznet", features = ["defmt"] } -embassy-embedded-hal = { version = "0.3.1", path = "../../embassy-embedded-hal/"} +embassy-embedded-hal = { version = "0.4.0", path = "../../embassy-embedded-hal/"} cyw43 = { path = "../../cyw43", features = ["defmt", "firmware-logs"] } cyw43-pio = { path = "../../cyw43-pio", features = ["defmt"] } perf-client = { path = "../perf-client" } -- cgit From 9ca44b519ac707f8a95fba55d72d4bf09ccb44c0 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Mon, 4 Aug 2025 14:07:30 +0200 Subject: chore: bump nrf and rp hal versions --- tests/nrf/Cargo.toml | 2 +- tests/rp/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index 3e1113ccf..bc7ab9891 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -11,7 +11,7 @@ embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt", ] } embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } -embassy-nrf = { version = "0.5.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } +embassy-nrf = { version = "0.6.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } embassy-net-esp-hosted = { version = "0.2.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 1f2bbdb22..711b6f733 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -15,7 +15,7 @@ teleprobe-meta = "1.1" embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", ] } -embassy-rp = { version = "0.6.0", path = "../../embassy-rp", features = [ "defmt", "unstable-pac", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } +embassy-rp = { version = "0.7.0", path = "../../embassy-rp", features = [ "defmt", "unstable-pac", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } embassy-net-wiznet = { version = "0.2.0", path = "../../embassy-net-wiznet", features = ["defmt"] } -- cgit From c4c5167e3d18eafee7726a526093bed2b3d2d119 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Tue, 12 Aug 2025 18:16:50 +0200 Subject: chore: update metapac and prepare embassy-stm32 0.3.0 --- tests/stm32/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 58ee10d77..33dce2c36 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -66,7 +66,7 @@ teleprobe-meta = "1" embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "tick-hz-131_072", "defmt-timestamp-uptime"] } -embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "memory-x", "time-driver-any"] } +embassy-stm32 = { version = "0.3.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "memory-x", "time-driver-any"] } embassy-futures = { version = "0.1.0", 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.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } -- cgit From c7b9060a7443cd004d366586c418a3d95bf3447a Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Tue, 12 Aug 2025 20:23:20 +0200 Subject: fix: prepare embassy-sync 0.7.1 release * Add newtype for moved type to preserve API compat --- tests/mspm0/Cargo.toml | 2 +- tests/nrf/Cargo.toml | 2 +- tests/riscv32/Cargo.toml | 2 +- tests/rp/Cargo.toml | 2 +- tests/stm32/Cargo.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/mspm0/Cargo.toml b/tests/mspm0/Cargo.toml index 6742537e5..e4033b8b7 100644 --- a/tests/mspm0/Cargo.toml +++ b/tests/mspm0/Cargo.toml @@ -11,7 +11,7 @@ mspm0g3519 = [ "embassy-mspm0/mspm0g3519pz" ] [dependencies] teleprobe-meta = "1.1" -embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = [ "defmt" ] } +embassy-sync = { version = "0.7.1", path = "../../embassy-sync", features = [ "defmt" ] } embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = [ "arch-cortex-m", "executor-thread", "defmt" ] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = [ "defmt" ] } diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index bc7ab9891..ef7dc96ec 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" teleprobe-meta = "1" embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt", ] } +embassy-sync = { version = "0.7.1", path = "../../embassy-sync", features = ["defmt", ] } embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.6.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } diff --git a/tests/riscv32/Cargo.toml b/tests/riscv32/Cargo.toml index 6bce9a0e3..283ea5033 100644 --- a/tests/riscv32/Cargo.toml +++ b/tests/riscv32/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] critical-section = { version = "1.1.1", features = ["restore-state-bool"] } -embassy-sync = { version = "0.7.0", path = "../../embassy-sync" } +embassy-sync = { version = "0.7.1", path = "../../embassy-sync" } embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-riscv32", "executor-thread"] } embassy-time = { version = "0.4.0", path = "../../embassy-time" } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 711b6f733..eef6c47ae 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -12,7 +12,7 @@ rp235xb = ["embassy-rp/rp235xb"] [dependencies] teleprobe-meta = "1.1" -embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.7.1", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", ] } embassy-rp = { version = "0.7.0", path = "../../embassy-rp", features = [ "defmt", "unstable-pac", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 33dce2c36..96b49f027 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -63,7 +63,7 @@ cm0 = ["portable-atomic/unsafe-assume-single-core"] [dependencies] teleprobe-meta = "1" -embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.7.1", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "tick-hz-131_072", "defmt-timestamp-uptime"] } embassy-stm32 = { version = "0.3.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "memory-x", "time-driver-any"] } -- cgit From 4c556dcbf23c0024766e78d5839ce3f717bbc0e9 Mon Sep 17 00:00:00 2001 From: Fabian Wolter Date: Thu, 14 Aug 2025 19:41:00 +0200 Subject: stm32 tests: move can_common out of the bin folder --- tests/stm32/src/bin/can.rs | 1 + tests/stm32/src/bin/can_common.rs | 109 -------------------------------------- tests/stm32/src/bin/fdcan.rs | 1 + tests/stm32/src/can_common.rs | 109 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 109 deletions(-) delete mode 100644 tests/stm32/src/bin/can_common.rs create mode 100644 tests/stm32/src/can_common.rs (limited to 'tests') diff --git a/tests/stm32/src/bin/can.rs b/tests/stm32/src/bin/can.rs index 778d88a7b..348cd049d 100644 --- a/tests/stm32/src/bin/can.rs +++ b/tests/stm32/src/bin/can.rs @@ -15,6 +15,7 @@ use embassy_stm32::peripherals::CAN1; use embassy_time::Duration; use {defmt_rtt as _, panic_probe as _}; +#[path = "../can_common.rs"] mod can_common; use can_common::*; diff --git a/tests/stm32/src/bin/can_common.rs b/tests/stm32/src/bin/can_common.rs deleted file mode 100644 index 4e1740ad5..000000000 --- a/tests/stm32/src/bin/can_common.rs +++ /dev/null @@ -1,109 +0,0 @@ -use defmt::{assert, *}; -use embassy_stm32::can; -use embassy_time::{Duration, Instant}; - -#[derive(Clone, Copy, Debug)] -pub struct TestOptions { - pub max_latency: Duration, - pub max_buffered: u8, -} - -pub async fn run_can_tests<'d>(can: &mut can::Can<'d>, options: &TestOptions) { - //pub async fn run_can_tests<'d, T: can::Instance>(can: &mut can::Can<'d, T>, options: &TestOptions) { - let mut i: u8 = 0; - loop { - //let tx_frame = can::frame::Frame::new_standard(0x123, &[i, 0x12 as u8, 0x34 as u8, 0x56 as u8, 0x78 as u8, 0x9A as u8, 0xBC as u8 ]).unwrap(); - let tx_frame = can::frame::Frame::new_standard(0x123, &[i; 1]).unwrap(); - - //info!("Transmitting frame..."); - let tx_ts = Instant::now(); - can.write(&tx_frame).await; - - let (frame, timestamp) = can.read().await.unwrap().parts(); - //info!("Frame received!"); - - // Check data. - assert!(i == frame.data()[0], "{} == {}", i, frame.data()[0]); - - //info!("loopback time {}", timestamp); - //info!("loopback frame {=u8}", frame.data()[0]); - let latency = timestamp.saturating_duration_since(tx_ts); - info!("loopback latency {} us", latency.as_micros()); - - // Theoretical minimum latency is 55us, actual is usually ~80us - const MIN_LATENCY: Duration = Duration::from_micros(50); - // Was failing at 150 but we are not getting a real time stamp. I'm not - // sure if there are other delays - assert!( - MIN_LATENCY <= latency && latency <= options.max_latency, - "{} <= {} <= {}", - MIN_LATENCY, - latency, - options.max_latency - ); - - i += 1; - if i > 5 { - break; - } - } - - // Below here, check that we can receive from both FIFO0 and FIFO1 - // Above we configured FIFO1 for extended ID packets. There are only 3 slots - // in each FIFO so make sure we write enough to fill them both up before reading. - for i in 0..options.max_buffered { - // Try filling up the RX FIFO0 buffers - //let tx_frame = if 0 != (i & 0x01) { - let tx_frame = if i < options.max_buffered / 2 { - info!("Transmitting standard frame {}", i); - can::frame::Frame::new_standard(0x123, &[i; 1]).unwrap() - } else { - info!("Transmitting extended frame {}", i); - can::frame::Frame::new_extended(0x1232344, &[i; 1]).unwrap() - }; - can.write(&tx_frame).await; - } - - // Try and receive all 6 packets - for _i in 0..options.max_buffered { - let (frame, _ts) = can.read().await.unwrap().parts(); - match frame.id() { - embedded_can::Id::Extended(_id) => { - info!("Extended received! {}", frame.data()[0]); - //info!("Extended received! {:x} {} {}", id.as_raw(), frame.data()[0], i); - } - embedded_can::Id::Standard(_id) => { - info!("Standard received! {}", frame.data()[0]); - //info!("Standard received! {:x} {} {}", id.as_raw(), frame.data()[0], i); - } - } - } -} - -pub async fn run_split_can_tests<'d>(tx: &mut can::CanTx<'d>, rx: &mut can::CanRx<'d>, options: &TestOptions) { - for i in 0..options.max_buffered { - // Try filling up the RX FIFO0 buffers - //let tx_frame = if 0 != (i & 0x01) { - let tx_frame = if i < options.max_buffered / 2 { - info!("Transmitting standard frame {}", i); - can::frame::Frame::new_standard(0x123, &[i; 1]).unwrap() - } else { - info!("Transmitting extended frame {}", i); - can::frame::Frame::new_extended(0x1232344, &[i; 1]).unwrap() - }; - tx.write(&tx_frame).await; - } - - // Try and receive all 6 packets - for _i in 0..options.max_buffered { - let (frame, _ts) = rx.read().await.unwrap().parts(); - match frame.id() { - embedded_can::Id::Extended(_id) => { - info!("Extended received! {}", frame.data()[0]); - } - embedded_can::Id::Standard(_id) => { - info!("Standard received! {}", frame.data()[0]); - } - } - } -} diff --git a/tests/stm32/src/bin/fdcan.rs b/tests/stm32/src/bin/fdcan.rs index 83d7eca85..c2a1a7bb8 100644 --- a/tests/stm32/src/bin/fdcan.rs +++ b/tests/stm32/src/bin/fdcan.rs @@ -12,6 +12,7 @@ use embassy_stm32::{bind_interrupts, can, Config}; use embassy_time::Duration; use {defmt_rtt as _, panic_probe as _}; +#[path = "../can_common.rs"] mod can_common; use can_common::*; diff --git a/tests/stm32/src/can_common.rs b/tests/stm32/src/can_common.rs new file mode 100644 index 000000000..4e1740ad5 --- /dev/null +++ b/tests/stm32/src/can_common.rs @@ -0,0 +1,109 @@ +use defmt::{assert, *}; +use embassy_stm32::can; +use embassy_time::{Duration, Instant}; + +#[derive(Clone, Copy, Debug)] +pub struct TestOptions { + pub max_latency: Duration, + pub max_buffered: u8, +} + +pub async fn run_can_tests<'d>(can: &mut can::Can<'d>, options: &TestOptions) { + //pub async fn run_can_tests<'d, T: can::Instance>(can: &mut can::Can<'d, T>, options: &TestOptions) { + let mut i: u8 = 0; + loop { + //let tx_frame = can::frame::Frame::new_standard(0x123, &[i, 0x12 as u8, 0x34 as u8, 0x56 as u8, 0x78 as u8, 0x9A as u8, 0xBC as u8 ]).unwrap(); + let tx_frame = can::frame::Frame::new_standard(0x123, &[i; 1]).unwrap(); + + //info!("Transmitting frame..."); + let tx_ts = Instant::now(); + can.write(&tx_frame).await; + + let (frame, timestamp) = can.read().await.unwrap().parts(); + //info!("Frame received!"); + + // Check data. + assert!(i == frame.data()[0], "{} == {}", i, frame.data()[0]); + + //info!("loopback time {}", timestamp); + //info!("loopback frame {=u8}", frame.data()[0]); + let latency = timestamp.saturating_duration_since(tx_ts); + info!("loopback latency {} us", latency.as_micros()); + + // Theoretical minimum latency is 55us, actual is usually ~80us + const MIN_LATENCY: Duration = Duration::from_micros(50); + // Was failing at 150 but we are not getting a real time stamp. I'm not + // sure if there are other delays + assert!( + MIN_LATENCY <= latency && latency <= options.max_latency, + "{} <= {} <= {}", + MIN_LATENCY, + latency, + options.max_latency + ); + + i += 1; + if i > 5 { + break; + } + } + + // Below here, check that we can receive from both FIFO0 and FIFO1 + // Above we configured FIFO1 for extended ID packets. There are only 3 slots + // in each FIFO so make sure we write enough to fill them both up before reading. + for i in 0..options.max_buffered { + // Try filling up the RX FIFO0 buffers + //let tx_frame = if 0 != (i & 0x01) { + let tx_frame = if i < options.max_buffered / 2 { + info!("Transmitting standard frame {}", i); + can::frame::Frame::new_standard(0x123, &[i; 1]).unwrap() + } else { + info!("Transmitting extended frame {}", i); + can::frame::Frame::new_extended(0x1232344, &[i; 1]).unwrap() + }; + can.write(&tx_frame).await; + } + + // Try and receive all 6 packets + for _i in 0..options.max_buffered { + let (frame, _ts) = can.read().await.unwrap().parts(); + match frame.id() { + embedded_can::Id::Extended(_id) => { + info!("Extended received! {}", frame.data()[0]); + //info!("Extended received! {:x} {} {}", id.as_raw(), frame.data()[0], i); + } + embedded_can::Id::Standard(_id) => { + info!("Standard received! {}", frame.data()[0]); + //info!("Standard received! {:x} {} {}", id.as_raw(), frame.data()[0], i); + } + } + } +} + +pub async fn run_split_can_tests<'d>(tx: &mut can::CanTx<'d>, rx: &mut can::CanRx<'d>, options: &TestOptions) { + for i in 0..options.max_buffered { + // Try filling up the RX FIFO0 buffers + //let tx_frame = if 0 != (i & 0x01) { + let tx_frame = if i < options.max_buffered / 2 { + info!("Transmitting standard frame {}", i); + can::frame::Frame::new_standard(0x123, &[i; 1]).unwrap() + } else { + info!("Transmitting extended frame {}", i); + can::frame::Frame::new_extended(0x1232344, &[i; 1]).unwrap() + }; + tx.write(&tx_frame).await; + } + + // Try and receive all 6 packets + for _i in 0..options.max_buffered { + let (frame, _ts) = rx.read().await.unwrap().parts(); + match frame.id() { + embedded_can::Id::Extended(_id) => { + info!("Extended received! {}", frame.data()[0]); + } + embedded_can::Id::Standard(_id) => { + info!("Standard received! {}", frame.data()[0]); + } + } + } +} -- cgit From 410a18b536e73c005285b458eaeb8b6c3a71c1af Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Tue, 12 Aug 2025 17:09:52 +0800 Subject: stm32/hash: Clear HMAC mode bit when hashing Running a hash after a hmac would hang, the CR.MODE bit isn't cleared by INIT. Test it by running the test twice. --- tests/stm32/src/bin/hash.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/stm32/src/bin/hash.rs b/tests/stm32/src/bin/hash.rs index 52b84a499..2499f42ed 100644 --- a/tests/stm32/src/bin/hash.rs +++ b/tests/stm32/src/bin/hash.rs @@ -7,6 +7,7 @@ mod common; use common::*; use embassy_executor::Spawner; use embassy_stm32::hash::*; +use embassy_stm32::mode::Blocking; use embassy_stm32::{bind_interrupts, hash, peripherals}; use hmac::{Hmac, Mac}; use sha2::{Digest, Sha224, Sha256}; @@ -32,11 +33,7 @@ bind_interrupts!(struct Irqs { HASH => hash::InterruptHandler; }); -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p: embassy_stm32::Peripherals = init(); - let mut hw_hasher = Hash::new_blocking(p.HASH, Irqs); - +fn test_interrupt(hw_hasher: &mut Hash<'_, peripherals::HASH, Blocking>) { let test_1: &[u8] = b"as;dfhaslfhas;oifvnasd;nifvnhasd;nifvhndlkfghsd;nvfnahssdfgsdafgsasdfasdfasdfasdfasdfghjklmnbvcalskdjghalskdjgfbaslkdjfgbalskdjgbalskdjbdfhsdfhsfghsfghfgh"; let test_2: &[u8] = b"fdhalksdjfhlasdjkfhalskdjfhgal;skdjfgalskdhfjgalskdjfglafgadfgdfgdafgaadsfgfgdfgadrgsyfthxfgjfhklhjkfgukhulkvhlvhukgfhfsrghzdhxyfufynufyuszeradrtydyytserr"; let test_3: &[u8] = b"a.ewtkluGWEBR.KAJRBTA,RMNRBG,FDMGB.kger.tkasjrbt.akrjtba.krjtba.ktmyna,nmbvtyliasd;gdrtba,sfvs.kgjzshd.gkbsr.tksejb.SDkfBSE.gkfgb>ESkfbSE>gkJSBESE>kbSE>fk"; @@ -95,6 +92,16 @@ async fn main(_spawner: Spawner) { info!("Hardware HMAC: {:?}", hw_hmac); info!("Software HMAC: {:?}", sw_hmac[..]); defmt::assert!(hw_hmac == sw_hmac[..]); +} + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let p: embassy_stm32::Peripherals = init(); + let mut hw_hasher = Hash::new_blocking(p.HASH, Irqs); + + test_interrupt(&mut hw_hasher); + // Run it a second time to check hash-after-hmac + test_interrupt(&mut hw_hasher); info!("Test OK"); cortex_m::asm::bkpt(); -- cgit From d939d901e245c30f924e30a7605e378be0be5cca Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Tue, 12 Aug 2025 17:13:21 +0800 Subject: stm32: Add hash test for sha512, varying lengths sha512 is only supported by hash_v3 and hash_v4, so add a feature for those chips. --- tests/stm32/Cargo.toml | 5 +++-- tests/stm32/src/bin/hash.rs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 96b49f027..c011a6d7d 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -16,7 +16,7 @@ stm32f446re = ["embassy-stm32/stm32f446re", "spi-v1", "chrono", "stop", "can", " stm32f767zi = ["embassy-stm32/stm32f767zi", "chrono", "not-gpdma", "eth", "rng", "single-bank"] stm32g071rb = ["embassy-stm32/stm32g071rb", "cm0", "not-gpdma", "dac", "ucpd"] stm32g491re = ["embassy-stm32/stm32g491re", "chrono", "stop", "not-gpdma", "rng", "fdcan", "cordic"] -stm32h563zi = ["embassy-stm32/stm32h563zi", "spi-v345", "chrono", "eth", "rng", "fdcan", "hash", "cordic", "stop"] +stm32h563zi = ["embassy-stm32/stm32h563zi", "spi-v345", "chrono", "eth", "rng", "fdcan", "hash-v34", "cordic", "stop"] stm32h753zi = ["embassy-stm32/stm32h753zi", "spi-v345", "chrono", "not-gpdma", "eth", "rng", "fdcan", "hash", "cryp"] stm32h755zi = ["embassy-stm32/stm32h755zi-cm7", "spi-v345", "chrono", "not-gpdma", "eth", "dac", "rng", "fdcan", "hash", "cryp"] stm32h7a3zi = ["embassy-stm32/stm32h7a3zi", "spi-v345", "not-gpdma", "rng", "fdcan"] @@ -33,13 +33,14 @@ stm32wba52cg = ["embassy-stm32/stm32wba52cg", "spi-v345", "chrono", "rng", "hash stm32wl55jc = ["embassy-stm32/stm32wl55jc-cm4", "not-gpdma", "rng", "chrono"] stm32f091rc = ["embassy-stm32/stm32f091rc", "cm0", "not-gpdma", "chrono"] stm32h503rb = ["embassy-stm32/stm32h503rb", "spi-v345", "rng", "stop"] -stm32h7s3l8 = ["embassy-stm32/stm32h7s3l8", "spi-v345", "rng", "cordic", "hash"] # TODO: fdcan crashes, cryp dma hangs. +stm32h7s3l8 = ["embassy-stm32/stm32h7s3l8", "spi-v345", "rng", "cordic", "hash-v34"] # TODO: fdcan crashes, cryp dma hangs. stm32u083rc = ["embassy-stm32/stm32u083rc", "cm0", "rng", "chrono"] spi-v1 = [] spi-v345 = [] cryp = [] hash = [] +hash-v34 = ["hash"] eth = [] rng = [] sdmmc = [] diff --git a/tests/stm32/src/bin/hash.rs b/tests/stm32/src/bin/hash.rs index 2499f42ed..bb08d0cf1 100644 --- a/tests/stm32/src/bin/hash.rs +++ b/tests/stm32/src/bin/hash.rs @@ -94,6 +94,34 @@ fn test_interrupt(hw_hasher: &mut Hash<'_, peripherals::HASH, Blocking>) { defmt::assert!(hw_hmac == sw_hmac[..]); } +// This uses sha512, so only supported on hash_v3 and up +#[cfg(feature = "hash-v34")] +fn test_sizes(hw_hasher: &mut Hash<'_, peripherals::HASH, Blocking>) { + let in1 = b"4BPuGudaDK"; + let in2 = b"cfFIGf0XSNhFBQ5LaIqzjnRKDRkoWweJI06HLUcicIUGjpuDNfOTQNSrRxDoveDPlazeZtt06SIYO5CvHvsJ98XSfO9yJEMHoDpDAmNQtwZOPlKmdiagRXsJ7w7IjdKpQH6I2t"; + + for i in 1..10 { + // sha512 block size is 128, so test around there + for j in [1, 1, 2, 3, 4, 5, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133] { + info!("test_sizes i {} j {}", i, j); + let mut sw = sha2::Sha512::new(); + let mut ctx = hw_hasher.start(Algorithm::SHA512, DataType::Width8, None); + + sw.update(&in1[..i]); + sw.update(&in2[..j]); + hw_hasher.update_blocking(&mut ctx, &in1[..i]); + hw_hasher.update_blocking(&mut ctx, &in2[..j]); + + let sw_digest = sw.finalize(); + let mut hw_digest = [0u8; 64]; + hw_hasher.finish_blocking(ctx, &mut hw_digest); + info!("Hardware: {:?}", hw_digest); + info!("Software: {:?}", sw_digest[..]); + defmt::assert!(hw_digest == *sw_digest); + } + } +} + #[embassy_executor::main] async fn main(_spawner: Spawner) { let p: embassy_stm32::Peripherals = init(); @@ -103,6 +131,9 @@ async fn main(_spawner: Spawner) { // Run it a second time to check hash-after-hmac test_interrupt(&mut hw_hasher); + #[cfg(feature = "hash-v34")] + test_sizes(&mut hw_hasher); + info!("Test OK"); cortex_m::asm::bkpt(); } -- cgit From 3a6ea3a31c90179fb3cbd30c18e3a310e2ee647c Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 15 Aug 2025 19:01:56 +0200 Subject: Load all crates in the graph, honor the "publish" flag to prevent publishing examples/tests. --- tests/mspm0/Cargo.toml | 6 ++++++ tests/nrf/Cargo.toml | 11 +++++++++++ tests/perf-client/Cargo.toml | 1 + tests/perf-server/Cargo.toml | 1 + tests/riscv32/Cargo.toml | 6 ++++++ tests/rp/Cargo.toml | 7 +++++++ tests/stm32/Cargo.toml | 34 ++++++++++++++++++++++++++++++++++ tests/utils/Cargo.toml | 1 + tests/utils/src/bin/saturate_serial.rs | 7 ++++--- 9 files changed, 71 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/mspm0/Cargo.toml b/tests/mspm0/Cargo.toml index e4033b8b7..5cf1b0ed1 100644 --- a/tests/mspm0/Cargo.toml +++ b/tests/mspm0/Cargo.toml @@ -3,6 +3,7 @@ edition = "2021" name = "embassy-mspm0-tests" version = "0.1.0" license = "MIT OR Apache-2.0" +publish = false [features] mspm0g3507 = [ "embassy-mspm0/mspm0g3507pm" ] @@ -60,3 +61,8 @@ debug = false debug-assertions = false opt-level = 0 overflow-checks = false + +[package.metadata.embassy] +build = [ + { target = "thumbv6m-none-eabi", features = ["mspm0g3507"], artifact-dir = "out/tests/mspm0g3507" } +] diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index ef7dc96ec..b94b54f4e 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -3,6 +3,7 @@ edition = "2021" name = "embassy-nrf-examples" version = "0.1.0" license = "MIT OR Apache-2.0" +publish = false [dependencies] teleprobe-meta = "1" @@ -112,3 +113,13 @@ path = "src/bin/wifi_esp_hosted_perf.rs" required-features = [ "nrf52840",] # END TESTS + +[package.metadata.embassy] +build = [ + { target = "thumbv6m-none-eabi", features = ["nrf51422"], artifact-dir = "out/tests/nrf51422-dk" }, + { target = "thumbv7em-none-eabi", features = ["nrf52832"], artifact-dir = "out/tests/nrf52832-dk" }, + { target = "thumbv7em-none-eabi", features = ["nrf52833"], artifact-dir = "out/tests/nrf52833-dk" }, + { target = "thumbv7em-none-eabi", features = ["nrf52840"], artifact-dir = "out/tests/nrf52840-dk" }, + { target = "thumbv8m.main-none-eabihf", features = ["nrf5340"], artifact-dir = "out/tests/nrf5340-dk" }, + { target = "thumbv8m.main-none-eabihf", features = ["nrf9160"], artifact-dir = "out/tests/nrf9160-dk" } +] diff --git a/tests/perf-client/Cargo.toml b/tests/perf-client/Cargo.toml index e31d6361b..ea0663b6f 100644 --- a/tests/perf-client/Cargo.toml +++ b/tests/perf-client/Cargo.toml @@ -2,6 +2,7 @@ name = "perf-client" version = "0.1.0" edition = "2021" +publish = false [dependencies] embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4"] } diff --git a/tests/perf-server/Cargo.toml b/tests/perf-server/Cargo.toml index 532039050..22614a33a 100644 --- a/tests/perf-server/Cargo.toml +++ b/tests/perf-server/Cargo.toml @@ -2,6 +2,7 @@ name = "perf-server" version = "0.1.0" edition = "2021" +publish = false [dependencies] log = "0.4.17" diff --git a/tests/riscv32/Cargo.toml b/tests/riscv32/Cargo.toml index 283ea5033..781fec62f 100644 --- a/tests/riscv32/Cargo.toml +++ b/tests/riscv32/Cargo.toml @@ -3,6 +3,7 @@ edition = "2021" name = "embassy-riscv-tests" version = "0.1.0" license = "MIT OR Apache-2.0" +publish = false [dependencies] critical-section = { version = "1.1.1", features = ["restore-state-bool"] } @@ -44,3 +45,8 @@ debug = false debug-assertions = false opt-level = 0 overflow-checks = false + +[package.metadata.embassy] +build = [ + { target = "riscv32imac-unknown-none-elf" } +] diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index eef6c47ae..088195a75 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -3,6 +3,7 @@ edition = "2021" name = "embassy-rp-tests" version = "0.1.0" license = "MIT OR Apache-2.0" +publish = false [features] rp2040 = ["embassy-rp/rp2040"] @@ -92,3 +93,9 @@ debug = false debug-assertions = false opt-level = 0 overflow-checks = false + +[package.metadata.embassy] +build = [ + { target = "thumbv6m-none-eabi", features = ["rp2040"], artifact-dir = "out/tests/rpi-pico" }, + { target = "thumbv8m.main-none-eabihf", features = ["rp235xb"], artifact-dir = "out/tests/pimoroni-pico-plus-2" } +] diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index c011a6d7d..37d5161f8 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -4,6 +4,7 @@ name = "embassy-stm32-tests" version = "0.1.0" license = "MIT OR Apache-2.0" autobins = false +publish = false [features] stm32c031c6 = ["embassy-stm32/stm32c031c6", "cm0", "not-gpdma"] @@ -243,3 +244,36 @@ debug = false debug-assertions = false opt-level = 0 overflow-checks = false + +[package.metadata.embassy] +build = [ + { target = "thumbv7m-none-eabi", features = ["stm32f103c8"], artifact-dir = "out/tests/stm32f103c8" }, + { target = "thumbv7em-none-eabi", features = ["stm32f429zi"], artifact-dir = "out/tests/stm32f429zi" }, + { target = "thumbv7em-none-eabi", features = ["stm32f446re"], artifact-dir = "out/tests/stm32f446re" }, + { target = "thumbv7em-none-eabi", features = ["stm32g491re"], artifact-dir = "out/tests/stm32g491re" }, + { target = "thumbv6m-none-eabi", features = ["stm32g071rb"], artifact-dir = "out/tests/stm32g071rb" }, + { target = "thumbv6m-none-eabi", features = ["stm32c031c6"], artifact-dir = "out/tests/stm32c031c6" }, + { target = "thumbv6m-none-eabi", features = ["stm32c071rb"], artifact-dir = "out/tests/stm32c071rb" }, + { target = "thumbv7em-none-eabi", features = ["stm32h755zi"], artifact-dir = "out/tests/stm32h755zi" }, + { target = "thumbv7em-none-eabi", features = ["stm32h753zi"], artifact-dir = "out/tests/stm32h753zi" }, + { target = "thumbv7em-none-eabi", features = ["stm32h7a3zi"], artifact-dir = "out/tests/stm32h7a3zi" }, + { target = "thumbv7em-none-eabi", features = ["stm32wb55rg"], artifact-dir = "out/tests/stm32wb55rg" }, + { target = "thumbv8m.main-none-eabihf", features = ["stm32h563zi"], artifact-dir = "out/tests/stm32h563zi" }, + { target = "thumbv8m.main-none-eabihf", features = ["stm32u585ai"], artifact-dir = "out/tests/stm32u585ai" }, + { target = "thumbv8m.main-none-eabihf", features = ["stm32u5a5zj"], artifact-dir = "out/tests/stm32u5a5zj" }, + { target = "thumbv8m.main-none-eabihf", features = ["stm32wba52cg"], artifact-dir = "out/tests/stm32wba52cg" }, + { target = "thumbv6m-none-eabi", features = ["stm32l073rz"], artifact-dir = "out/tests/stm32l073rz" }, + { target = "thumbv7m-none-eabi", features = ["stm32l152re"], artifact-dir = "out/tests/stm32l152re" }, + { target = "thumbv7em-none-eabi", features = ["stm32l4a6zg"], artifact-dir = "out/tests/stm32l4a6zg" }, + { target = "thumbv7em-none-eabi", features = ["stm32l4r5zi"], artifact-dir = "out/tests/stm32l4r5zi" }, + { target = "thumbv8m.main-none-eabihf", features = ["stm32l552ze"], artifact-dir = "out/tests/stm32l552ze" }, + { target = "thumbv7em-none-eabi", features = ["stm32f767zi"], artifact-dir = "out/tests/stm32f767zi" }, + { target = "thumbv7m-none-eabi", features = ["stm32f207zg"], artifact-dir = "out/tests/stm32f207zg" }, + { target = "thumbv7em-none-eabi", features = ["stm32f303ze"], artifact-dir = "out/tests/stm32f303ze" }, + { target = "thumbv7em-none-eabi", features = ["stm32l496zg"], artifact-dir = "out/tests/stm32l496zg" }, + { target = "thumbv7em-none-eabi", features = ["stm32wl55jc"], artifact-dir = "out/tests/stm32wl55jc" }, + { target = "thumbv7em-none-eabi", features = ["stm32h7s3l8"], artifact-dir = "out/tests/stm32h7s3l8" }, + { target = "thumbv6m-none-eabi", features = ["stm32f091rc"], artifact-dir = "out/tests/stm32f091rc" }, + { target = "thumbv8m.main-none-eabihf", features = ["stm32h503rb"], artifact-dir = "out/tests/stm32h503rb" }, + { target = "thumbv6m-none-eabi", features = ["stm32u083rc"], artifact-dir = "out/tests/stm32u083rc" } +] diff --git a/tests/utils/Cargo.toml b/tests/utils/Cargo.toml index bda55ad32..f76feaa20 100644 --- a/tests/utils/Cargo.toml +++ b/tests/utils/Cargo.toml @@ -2,6 +2,7 @@ name = "test-utils" version = "0.1.0" edition = "2021" +publish = false [dependencies] rand = "0.9" diff --git a/tests/utils/src/bin/saturate_serial.rs b/tests/utils/src/bin/saturate_serial.rs index 18ca12fb7..85676b106 100644 --- a/tests/utils/src/bin/saturate_serial.rs +++ b/tests/utils/src/bin/saturate_serial.rs @@ -2,7 +2,7 @@ use std::path::Path; use std::time::Duration; use std::{env, io, process, thread}; -use rand::random; +use rand::{rng, Rng}; use serial::SerialPort; pub fn main() { @@ -34,14 +34,15 @@ fn saturate(port: &mut T, idles: bool) -> io::Result<()> { })?; let mut written = 0; + let mut rng = rng(); loop { - let len = random::() % 0x1000; + let len = rng.random_range(1..=0x1000); let buf: Vec = (written..written + len).map(|x| x as u8).collect(); port.write_all(&buf)?; if idles { - let micros = (random::() % 1000) as u64; + let micros = rng.random_range(1..=1000) as u64; println!("Sleeping {}us", micros); port.flush().unwrap(); thread::sleep(Duration::from_micros(micros)); -- cgit From 83f2557eacd657070a84a9baf2da6e3aff03b2b7 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Tue, 26 Aug 2025 16:04:00 +0200 Subject: chore: prepare embassy crate releases --- tests/mspm0/Cargo.toml | 10 +++++----- tests/nrf/Cargo.toml | 16 ++++++++-------- tests/perf-client/Cargo.toml | 6 +++--- tests/riscv32/Cargo.toml | 8 ++++---- tests/rp/Cargo.toml | 16 ++++++++-------- tests/stm32/Cargo.toml | 12 ++++++------ 6 files changed, 34 insertions(+), 34 deletions(-) (limited to 'tests') diff --git a/tests/mspm0/Cargo.toml b/tests/mspm0/Cargo.toml index 5cf1b0ed1..07fe779a0 100644 --- a/tests/mspm0/Cargo.toml +++ b/tests/mspm0/Cargo.toml @@ -12,12 +12,12 @@ mspm0g3519 = [ "embassy-mspm0/mspm0g3519pz" ] [dependencies] teleprobe-meta = "1.1" -embassy-sync = { version = "0.7.1", path = "../../embassy-sync", features = [ "defmt" ] } -embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = [ "arch-cortex-m", "executor-thread", "defmt" ] } -embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -embassy-time = { version = "0.4.0", path = "../../embassy-time", features = [ "defmt" ] } +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-futures = { version = "0.1.2", path = "../../embassy-futures" } +embassy-time = { version = "0.5.0", path = "../../embassy-time", features = [ "defmt" ] } embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = [ "rt", "defmt", "unstable-pac", "time-driver-any" ] } -embassy-embedded-hal = { version = "0.4.0", path = "../../embassy-embedded-hal/"} +embassy-embedded-hal = { version = "0.4.1", path = "../../embassy-embedded-hal/"} defmt = "1.0.1" defmt-rtt = "1.0.0" diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index b94b54f4e..efc297ccf 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -8,15 +8,15 @@ publish = false [dependencies] teleprobe-meta = "1" -embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -embassy-sync = { version = "0.7.1", path = "../../embassy-sync", features = ["defmt", ] } -embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } -embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } -embassy-nrf = { version = "0.6.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } +embassy-futures = { version = "0.1.2", path = "../../embassy-futures" } +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", "defmt-timestamp-uptime"] } +embassy-nrf = { version = "0.7.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } -embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } -embassy-net-esp-hosted = { version = "0.2.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } -embassy-net-enc28j60 = { version = "0.2.0", path = "../../embassy-net-enc28j60", features = ["defmt"] } +embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } +embassy-net-esp-hosted = { version = "0.2.1", path = "../../embassy-net-esp-hosted", features = ["defmt"] } +embassy-net-enc28j60 = { version = "0.2.1", path = "../../embassy-net-enc28j60", features = ["defmt"] } embedded-hal-async = { version = "1.0" } embedded-hal-bus = { version = "0.1", features = ["async"] } static_cell = "2" diff --git a/tests/perf-client/Cargo.toml b/tests/perf-client/Cargo.toml index ea0663b6f..581b60d6f 100644 --- a/tests/perf-client/Cargo.toml +++ b/tests/perf-client/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" publish = false [dependencies] -embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4"] } -embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", ] } -embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } +embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4"] } +embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", ] } +embassy-futures = { version = "0.1.2", path = "../../embassy-futures" } defmt = "1.0.1" diff --git a/tests/riscv32/Cargo.toml b/tests/riscv32/Cargo.toml index 781fec62f..c441e8ed3 100644 --- a/tests/riscv32/Cargo.toml +++ b/tests/riscv32/Cargo.toml @@ -7,10 +7,10 @@ publish = false [dependencies] critical-section = { version = "1.1.1", features = ["restore-state-bool"] } -embassy-sync = { version = "0.7.1", path = "../../embassy-sync" } -embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-riscv32", "executor-thread"] } -embassy-time = { version = "0.4.0", path = "../../embassy-time" } -embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } +embassy-sync = { version = "0.7.2", path = "../../embassy-sync" } +embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-riscv32", "executor-thread"] } +embassy-time = { version = "0.5.0", path = "../../embassy-time" } +embassy-futures = { version = "0.1.2", path = "../../embassy-futures" } riscv-rt = "0.12.2" riscv = { version = "0.11.1", features = ["critical-section-single-hart"] } diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 088195a75..5afb0d110 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -13,14 +13,14 @@ rp235xb = ["embassy-rp/rp235xb"] [dependencies] teleprobe-meta = "1.1" -embassy-sync = { version = "0.7.1", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } -embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", ] } -embassy-rp = { version = "0.7.0", path = "../../embassy-rp", features = [ "defmt", "unstable-pac", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } -embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } -embassy-net-wiznet = { version = "0.2.0", path = "../../embassy-net-wiznet", features = ["defmt"] } -embassy-embedded-hal = { version = "0.4.0", path = "../../embassy-embedded-hal/"} +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", ] } +embassy-rp = { version = "0.8.0", path = "../../embassy-rp", features = [ "defmt", "unstable-pac", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } +embassy-futures = { version = "0.1.2", path = "../../embassy-futures" } +embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } +embassy-net-wiznet = { version = "0.2.1", path = "../../embassy-net-wiznet", features = ["defmt"] } +embassy-embedded-hal = { version = "0.4.1", path = "../../embassy-embedded-hal/"} cyw43 = { path = "../../cyw43", features = ["defmt", "firmware-logs"] } cyw43-pio = { path = "../../cyw43-pio", features = ["defmt"] } perf-client = { path = "../perf-client" } diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 37d5161f8..aeca67659 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -65,13 +65,13 @@ cm0 = ["portable-atomic/unsafe-assume-single-core"] [dependencies] teleprobe-meta = "1" -embassy-sync = { version = "0.7.1", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.8.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } -embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "tick-hz-131_072", "defmt-timestamp-uptime"] } -embassy-stm32 = { version = "0.3.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "memory-x", "time-driver-any"] } -embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } +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-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.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } +embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } perf-client = { path = "../perf-client" } defmt = "1.0.1" -- cgit From 3e8d8fec15286eb25b8bba7d103c8fc279544551 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Wed, 27 Aug 2025 08:44:05 +0200 Subject: fix: update more minor versions --- tests/mspm0/Cargo.toml | 2 +- tests/rp/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/mspm0/Cargo.toml b/tests/mspm0/Cargo.toml index 07fe779a0..227d898d5 100644 --- a/tests/mspm0/Cargo.toml +++ b/tests/mspm0/Cargo.toml @@ -17,7 +17,7 @@ embassy-executor = { version = "0.9.0", path = "../../embassy-executor", feature embassy-futures = { version = "0.1.2", path = "../../embassy-futures" } embassy-time = { version = "0.5.0", path = "../../embassy-time", features = [ "defmt" ] } embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = [ "rt", "defmt", "unstable-pac", "time-driver-any" ] } -embassy-embedded-hal = { version = "0.4.1", path = "../../embassy-embedded-hal/"} +embassy-embedded-hal = { version = "0.5.0", path = "../../embassy-embedded-hal/"} defmt = "1.0.1" defmt-rtt = "1.0.0" diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 5afb0d110..809346bed 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -20,7 +20,7 @@ embassy-rp = { version = "0.8.0", path = "../../embassy-rp", features = [ "defmt embassy-futures = { version = "0.1.2", path = "../../embassy-futures" } embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } embassy-net-wiznet = { version = "0.2.1", path = "../../embassy-net-wiznet", features = ["defmt"] } -embassy-embedded-hal = { version = "0.4.1", path = "../../embassy-embedded-hal/"} +embassy-embedded-hal = { version = "0.5.0", path = "../../embassy-embedded-hal/"} cyw43 = { path = "../../cyw43", features = ["defmt", "firmware-logs"] } cyw43-pio = { path = "../../cyw43-pio", features = ["defmt"] } perf-client = { path = "../perf-client" } -- cgit From 8aec341f28a00012e1771d5c35d2647e11830755 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 9 Jul 2025 01:49:31 +0200 Subject: executor: return error when creating the spawntoken, not when spawning. --- tests/nrf/src/bin/ethernet_enc28j60_perf.rs | 2 +- tests/nrf/src/bin/wifi_esp_hosted_perf.rs | 4 ++-- tests/rp/src/bin/cyw43-perf.rs | 4 ++-- tests/rp/src/bin/ethernet_w5100s_perf.rs | 4 ++-- tests/rp/src/bin/gpio_multicore.rs | 4 ++-- tests/rp/src/bin/i2c.rs | 2 +- tests/rp/src/bin/multicore.rs | 4 ++-- tests/rp/src/bin/spinlock_mutex_multicore.rs | 4 ++-- tests/stm32/src/bin/eth.rs | 2 +- tests/stm32/src/bin/stop.rs | 6 +++--- tests/stm32/src/bin/usart_rx_ringbuffered.rs | 4 ++-- tests/stm32/src/bin/wpan_ble.rs | 2 +- tests/stm32/src/bin/wpan_mac.rs | 2 +- 13 files changed, 22 insertions(+), 22 deletions(-) (limited to 'tests') diff --git a/tests/nrf/src/bin/ethernet_enc28j60_perf.rs b/tests/nrf/src/bin/ethernet_enc28j60_perf.rs index ed58627f1..5f3fa1fd3 100644 --- a/tests/nrf/src/bin/ethernet_enc28j60_perf.rs +++ b/tests/nrf/src/bin/ethernet_enc28j60_perf.rs @@ -68,7 +68,7 @@ async fn main(spawner: Spawner) { static RESOURCES: StaticCell> = StaticCell::new(); let (stack, runner) = embassy_net::new(device, config, RESOURCES.init(StackResources::new()), seed); - unwrap!(spawner.spawn(net_task(runner))); + spawner.spawn(unwrap!(net_task(runner))); perf_client::run( stack, diff --git a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs index 34fb8103b..34c33a4ad 100644 --- a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs +++ b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs @@ -74,7 +74,7 @@ async fn main(spawner: Spawner) { ) .await; - unwrap!(spawner.spawn(wifi_task(runner))); + spawner.spawn(unwrap!(wifi_task(runner))); unwrap!(control.init().await); unwrap!(control.connect(WIFI_NETWORK, WIFI_PASSWORD).await); @@ -94,7 +94,7 @@ async fn main(spawner: Spawner) { seed, ); - unwrap!(spawner.spawn(net_task(runner))); + spawner.spawn(unwrap!(net_task(runner))); perf_client::run( stack, diff --git a/tests/rp/src/bin/cyw43-perf.rs b/tests/rp/src/bin/cyw43-perf.rs index dba1058a8..555134ffd 100644 --- a/tests/rp/src/bin/cyw43-perf.rs +++ b/tests/rp/src/bin/cyw43-perf.rs @@ -70,7 +70,7 @@ async fn main(spawner: Spawner) { static STATE: StaticCell = StaticCell::new(); let state = STATE.init(cyw43::State::new()); let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; - unwrap!(spawner.spawn(wifi_task(runner))); + spawner.spawn(unwrap!(wifi_task(runner))); control.init(clm).await; control @@ -89,7 +89,7 @@ async fn main(spawner: Spawner) { seed, ); - unwrap!(spawner.spawn(net_task(runner))); + spawner.spawn(unwrap!(net_task(runner))); loop { match control diff --git a/tests/rp/src/bin/ethernet_w5100s_perf.rs b/tests/rp/src/bin/ethernet_w5100s_perf.rs index 89e0ad32e..3f2bc728d 100644 --- a/tests/rp/src/bin/ethernet_w5100s_perf.rs +++ b/tests/rp/src/bin/ethernet_w5100s_perf.rs @@ -60,7 +60,7 @@ async fn main(spawner: Spawner) { ) .await .unwrap(); - unwrap!(spawner.spawn(ethernet_task(runner))); + spawner.spawn(unwrap!(ethernet_task(runner))); // Generate random seed let seed = rng.next_u64(); @@ -75,7 +75,7 @@ async fn main(spawner: Spawner) { ); // Launch network task - unwrap!(spawner.spawn(net_task(runner))); + spawner.spawn(unwrap!(net_task(runner))); perf_client::run( stack, diff --git a/tests/rp/src/bin/gpio_multicore.rs b/tests/rp/src/bin/gpio_multicore.rs index 857f36975..f48dd207b 100644 --- a/tests/rp/src/bin/gpio_multicore.rs +++ b/tests/rp/src/bin/gpio_multicore.rs @@ -30,11 +30,11 @@ fn main() -> ! { unsafe { &mut *core::ptr::addr_of_mut!(CORE1_STACK) }, move || { let executor1 = EXECUTOR1.init(Executor::new()); - executor1.run(|spawner| unwrap!(spawner.spawn(core1_task(p.PIN_1)))); + executor1.run(|spawner| spawner.spawn(unwrap!(core1_task(p.PIN_1)))); }, ); let executor0 = EXECUTOR0.init(Executor::new()); - executor0.run(|spawner| unwrap!(spawner.spawn(core0_task(p.PIN_0)))); + executor0.run(|spawner| spawner.spawn(unwrap!(core0_task(p.PIN_0)))); } #[embassy_executor::task] diff --git a/tests/rp/src/bin/i2c.rs b/tests/rp/src/bin/i2c.rs index 2c835bd5a..21761b98b 100644 --- a/tests/rp/src/bin/i2c.rs +++ b/tests/rp/src/bin/i2c.rs @@ -208,7 +208,7 @@ async fn controller_task(con: &mut i2c::I2c<'static, I2C0, i2c::Async>) { config.addr = DEV_ADDR as u16; let device = i2c_slave::I2cSlave::new(p.I2C1, d_sda, d_scl, Irqs, config); - spawner.must_spawn(device_task(device)); + spawner.spawn(device_task(device).unwrap()); let c_sda = p.PIN_21; let c_scl = p.PIN_20; diff --git a/tests/rp/src/bin/multicore.rs b/tests/rp/src/bin/multicore.rs index 902169c40..11b03cfea 100644 --- a/tests/rp/src/bin/multicore.rs +++ b/tests/rp/src/bin/multicore.rs @@ -27,11 +27,11 @@ fn main() -> ! { unsafe { &mut *core::ptr::addr_of_mut!(CORE1_STACK) }, move || { let executor1 = EXECUTOR1.init(Executor::new()); - executor1.run(|spawner| unwrap!(spawner.spawn(core1_task()))); + executor1.run(|spawner| spawner.spawn(unwrap!(core1_task()))); }, ); let executor0 = EXECUTOR0.init(Executor::new()); - executor0.run(|spawner| unwrap!(spawner.spawn(core0_task()))); + executor0.run(|spawner| spawner.spawn(unwrap!(core0_task()))); } #[embassy_executor::task] diff --git a/tests/rp/src/bin/spinlock_mutex_multicore.rs b/tests/rp/src/bin/spinlock_mutex_multicore.rs index ebcf1ca32..c56d43ade 100644 --- a/tests/rp/src/bin/spinlock_mutex_multicore.rs +++ b/tests/rp/src/bin/spinlock_mutex_multicore.rs @@ -27,11 +27,11 @@ fn main() -> ! { unsafe { &mut *core::ptr::addr_of_mut!(CORE1_STACK) }, move || { let executor1 = EXECUTOR1.init(Executor::new()); - executor1.run(|spawner| unwrap!(spawner.spawn(core1_task()))); + executor1.run(|spawner| spawner.spawn(unwrap!(core1_task()))); }, ); let executor0 = EXECUTOR0.init(Executor::new()); - executor0.run(|spawner| unwrap!(spawner.spawn(core0_task()))); + executor0.run(|spawner| spawner.spawn(unwrap!(core0_task()))); } #[embassy_executor::task] diff --git a/tests/stm32/src/bin/eth.rs b/tests/stm32/src/bin/eth.rs index bcb362b42..a65682a02 100644 --- a/tests/stm32/src/bin/eth.rs +++ b/tests/stm32/src/bin/eth.rs @@ -101,7 +101,7 @@ async fn main(spawner: Spawner) { let (stack, runner) = embassy_net::new(device, config, RESOURCES.init(StackResources::new()), seed); // Launch network task - unwrap!(spawner.spawn(net_task(runner))); + spawner.spawn(unwrap!(net_task(runner))); perf_client::run( stack, diff --git a/tests/stm32/src/bin/stop.rs b/tests/stm32/src/bin/stop.rs index 772bc527c..8119c1f39 100644 --- a/tests/stm32/src/bin/stop.rs +++ b/tests/stm32/src/bin/stop.rs @@ -19,7 +19,7 @@ use static_cell::StaticCell; #[entry] fn main() -> ! { Executor::take().run(|spawner| { - unwrap!(spawner.spawn(async_main(spawner))); + spawner.spawn(unwrap!(async_main(spawner))); }); } @@ -75,6 +75,6 @@ async fn async_main(spawner: Spawner) { stop_with_rtc(rtc); - spawner.spawn(task_1()).unwrap(); - spawner.spawn(task_2()).unwrap(); + spawner.spawn(task_1().unwrap()); + spawner.spawn(task_2().unwrap()); } diff --git a/tests/stm32/src/bin/usart_rx_ringbuffered.rs b/tests/stm32/src/bin/usart_rx_ringbuffered.rs index 83c0887ac..15a0b0d60 100644 --- a/tests/stm32/src/bin/usart_rx_ringbuffered.rs +++ b/tests/stm32/src/bin/usart_rx_ringbuffered.rs @@ -46,8 +46,8 @@ async fn main(spawner: Spawner) { let rx = rx.into_ring_buffered(unsafe { &mut *core::ptr::addr_of_mut!(DMA_BUF) }); info!("Spawning tasks"); - spawner.spawn(transmit_task(tx)).unwrap(); - spawner.spawn(receive_task(rx)).unwrap(); + spawner.spawn(transmit_task(tx).unwrap()); + spawner.spawn(receive_task(rx).unwrap()); } #[embassy_executor::task] diff --git a/tests/stm32/src/bin/wpan_ble.rs b/tests/stm32/src/bin/wpan_ble.rs index fde1dfa9b..8957bfc04 100644 --- a/tests/stm32/src/bin/wpan_ble.rs +++ b/tests/stm32/src/bin/wpan_ble.rs @@ -47,7 +47,7 @@ async fn main(spawner: Spawner) { let config = Config::default(); let mut mbox = TlMbox::init(p.IPCC, Irqs, config); - spawner.spawn(run_mm_queue(mbox.mm_subsystem)).unwrap(); + spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap()); let sys_event = mbox.sys_subsystem.read().await; info!("sys event: {}", sys_event.payload()); diff --git a/tests/stm32/src/bin/wpan_mac.rs b/tests/stm32/src/bin/wpan_mac.rs index b65ace40f..79e13d524 100644 --- a/tests/stm32/src/bin/wpan_mac.rs +++ b/tests/stm32/src/bin/wpan_mac.rs @@ -40,7 +40,7 @@ async fn main(spawner: Spawner) { let config = Config::default(); let mbox = TlMbox::init(p.IPCC, Irqs, config); - spawner.spawn(run_mm_queue(mbox.mm_subsystem)).unwrap(); + spawner.spawn(run_mm_queue(mbox.mm_subsystem).unwrap()); let sys_event = mbox.sys_subsystem.read().await; info!("sys event: {}", sys_event.payload()); -- cgit From a6562c4f033432e40970aafe82f33c5138adf84e Mon Sep 17 00:00:00 2001 From: Fabian Wolter Date: Mon, 21 Jul 2025 07:57:49 +0200 Subject: Add STM32F1 AFIO remap --- tests/stm32/Cargo.toml | 12 +- tests/stm32/src/bin/afio.rs | 1156 +++++++++++++++++++++++++++++++++++++++++++ tests/stm32/src/common.rs | 2 +- 3 files changed, 1168 insertions(+), 2 deletions(-) create mode 100644 tests/stm32/src/bin/afio.rs (limited to 'tests') diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index aeca67659..891ec93fd 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -9,7 +9,9 @@ publish = false [features] stm32c031c6 = ["embassy-stm32/stm32c031c6", "cm0", "not-gpdma"] stm32c071rb = ["embassy-stm32/stm32c071rb", "cm0", "not-gpdma"] -stm32f103c8 = ["embassy-stm32/stm32f103c8", "spi-v1", "not-gpdma"] +stm32f100rd = ["embassy-stm32/stm32f100rd", "spi-v1", "not-gpdma", "afio", "afio-value-line"] +stm32f103c8 = ["embassy-stm32/stm32f103c8", "spi-v1", "not-gpdma", "afio"] +stm32f107vc = ["embassy-stm32/stm32f107vc", "spi-v1", "not-gpdma", "afio", "afio-connectivity-line"] stm32f207zg = ["embassy-stm32/stm32f207zg", "spi-v1", "chrono", "not-gpdma", "eth", "rng"] stm32f303ze = ["embassy-stm32/stm32f303ze", "chrono", "not-gpdma"] stm32f429zi = ["embassy-stm32/stm32f429zi", "spi-v1", "chrono", "eth", "stop", "can", "not-gpdma", "dac", "rng"] @@ -59,6 +61,9 @@ cordic = ["dep:num-traits"] dual-bank = ["embassy-stm32/dual-bank"] single-bank = ["embassy-stm32/single-bank"] eeprom = [] +afio = [] +afio-connectivity-line = [] +afio-value-line = [] cm0 = ["portable-atomic/unsafe-assume-single-core"] @@ -98,6 +103,11 @@ num-traits = { version="0.2", default-features = false,features = ["libm"], opti # BEGIN TESTS # Generated by gen_test.py. DO NOT EDIT. +[[bin]] +name = "afio" +path = "src/bin/afio.rs" +required-features = [ "afio",] + [[bin]] name = "can" path = "src/bin/can.rs" diff --git a/tests/stm32/src/bin/afio.rs b/tests/stm32/src/bin/afio.rs new file mode 100644 index 000000000..c684b7b3e --- /dev/null +++ b/tests/stm32/src/bin/afio.rs @@ -0,0 +1,1156 @@ +// required-features: afio +#![no_std] +#![no_main] +#[path = "../common.rs"] +mod common; + +use common::*; +use embassy_executor::Spawner; +use embassy_stm32::gpio::{OutputType, Pull}; +use embassy_stm32::pac::AFIO; +use embassy_stm32::time::khz; +use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; +use embassy_stm32::timer::input_capture::{CapturePin, InputCapture}; +use embassy_stm32::timer::pwm_input::PwmInput; +use embassy_stm32::timer::qei::{Qei, QeiPin}; +use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; +use embassy_stm32::usart::{Uart, UartRx, UartTx}; +use embassy_stm32::{bind_interrupts, Peripherals}; + +#[cfg(not(feature = "afio-connectivity-line"))] +bind_interrupts!(struct Irqs { + USART3 => embassy_stm32::usart::InterruptHandler; + TIM1_CC => embassy_stm32::timer::CaptureCompareInterruptHandler; +}); + +#[cfg(feature = "afio-connectivity-line")] +bind_interrupts!(struct Irqs { + CAN1_RX0 => embassy_stm32::can::Rx0InterruptHandler; + CAN1_RX1 => embassy_stm32::can::Rx1InterruptHandler; + CAN1_SCE => embassy_stm32::can::SceInterruptHandler; + CAN1_TX => embassy_stm32::can::TxInterruptHandler; + + CAN2_RX0 => embassy_stm32::can::Rx0InterruptHandler; + CAN2_RX1 => embassy_stm32::can::Rx1InterruptHandler; + CAN2_SCE => embassy_stm32::can::SceInterruptHandler; + CAN2_TX => embassy_stm32::can::TxInterruptHandler; + + ETH => embassy_stm32::eth::InterruptHandler; + USART3 => embassy_stm32::usart::InterruptHandler; + TIM1_CC => embassy_stm32::timer::CaptureCompareInterruptHandler; +}); + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let mut p = init(); + info!("Hello World!"); + + // USART3 + { + // no remap RX/TX/RTS/CTS + afio_registers_set_remap(); + Uart::new_blocking_with_rtscts( + p.USART3.reborrow(), + p.PB11.reborrow(), + p.PB10.reborrow(), + p.PB14.reborrow(), + p.PB13.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 0); + } + { + // no remap RX/TX + afio_registers_set_remap(); + Uart::new_blocking( + p.USART3.reborrow(), + p.PB11.reborrow(), + p.PB10.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 0); + } + { + // no remap TX + afio_registers_set_remap(); + Uart::new_blocking_half_duplex( + p.USART3.reborrow(), + p.PB10.reborrow(), + Default::default(), + embassy_stm32::usart::HalfDuplexReadback::NoReadback, + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 0); + } + { + // no remap TX async + afio_registers_set_remap(); + UartTx::new( + p.USART3.reborrow(), + p.PB10.reborrow(), + p.DMA1_CH2.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 0); + } + { + // no remap TX/CTS async + afio_registers_set_remap(); + UartTx::new_with_cts( + p.USART3.reborrow(), + p.PB10.reborrow(), + p.PB13.reborrow(), + p.DMA1_CH2.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 0); + } + { + // no remap RX async + afio_registers_set_remap(); + UartRx::new( + p.USART3.reborrow(), + Irqs, + p.PB11.reborrow(), + p.DMA1_CH3.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 0); + } + { + // no remap RX async + afio_registers_set_remap(); + UartRx::new_with_rts( + p.USART3.reborrow(), + Irqs, + p.PB11.reborrow(), + p.PB14.reborrow(), + p.DMA1_CH3.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 0); + } + { + // no remap RX/TX async + afio_registers_set_remap(); + Uart::new( + p.USART3.reborrow(), + p.PB11.reborrow(), + p.PB10.reborrow(), + Irqs, + p.DMA1_CH2.reborrow(), + p.DMA1_CH3.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 0); + } + { + // no remap RX/TX/RTS/CTS async + afio_registers_set_remap(); + Uart::new_with_rtscts( + p.USART3.reborrow(), + p.PB11.reborrow(), + p.PB10.reborrow(), + Irqs, + p.PB14.reborrow(), + p.PB13.reborrow(), + p.DMA1_CH2.reborrow(), + p.DMA1_CH3.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 0); + } + + // TIM1 + { + // no remap + afio_registers_set_remap(); + SimplePwm::new( + p.TIM1.reborrow(), + Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PA9.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PA10.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PA11.reborrow(), OutputType::PushPull)), + khz(10), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().tim1_remap(), 0); + } + { + // no remap + afio_registers_set_remap(); + SimplePwm::new( + p.TIM1.reborrow(), + Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), + None, + None, + None, + khz(10), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().tim1_remap(), 0); + } + { + // partial remap + reset_afio_registers(); + ComplementaryPwm::new( + p.TIM1.reborrow(), + Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), + None, + None, + None, + None, + None, + None, + None, + khz(10), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().tim1_remap(), 1); + } + { + // partial remap + reset_afio_registers(); + ComplementaryPwm::new( + p.TIM1.reborrow(), + Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), + Some(ComplementaryPwmPin::new(p.PA7.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PA9.reborrow(), OutputType::PushPull)), + Some(ComplementaryPwmPin::new(p.PB0.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PA10.reborrow(), OutputType::PushPull)), + None, // pin does not exist on medium-density devices + Some(PwmPin::new(p.PA11.reborrow(), OutputType::PushPull)), + None, // signal does not exist + khz(10), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().tim1_remap(), 1); + } + { + // partial remap + reset_afio_registers(); + InputCapture::new( + p.TIM1.reborrow(), + Some(CapturePin::new(p.PA8.reborrow(), Pull::Down)), + None, + None, + None, + Irqs, + khz(10), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().tim1_remap(), 1); + } + { + // partial remap + reset_afio_registers(); + PwmInput::new_ch1(p.TIM1.reborrow(), p.PA8.reborrow(), Pull::Down, khz(10)); + defmt::assert_eq!(AFIO.mapr().read().tim1_remap(), 1); + } + { + // partial remap + reset_afio_registers(); + Qei::new( + p.TIM1.reborrow(), + QeiPin::new(p.PA8.reborrow()), + QeiPin::new(p.PA9.reborrow()), + ); + defmt::assert_eq!(AFIO.mapr().read().tim1_remap(), 1); + } + + // TIM2 + { + // no remap + afio_registers_set_remap(); + SimplePwm::new( + p.TIM2.reborrow(), + Some(PwmPin::new(p.PA0.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PA1.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PA2.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PA3.reborrow(), OutputType::PushPull)), + khz(10), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().tim2_remap(), 0); + } + { + // partial remap 1 + reset_afio_registers(); + SimplePwm::new( + p.TIM2.reborrow(), + Some(PwmPin::new(p.PA15.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PB3.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PA2.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PA3.reborrow(), OutputType::PushPull)), + khz(10), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().tim2_remap(), 1); + } + { + // partial remap 2 + reset_afio_registers(); + SimplePwm::new( + p.TIM2.reborrow(), + Some(PwmPin::new(p.PA0.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PA1.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PB10.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PB11.reborrow(), OutputType::PushPull)), + khz(10), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().tim2_remap(), 2); + } + { + // full remap + reset_afio_registers(); + SimplePwm::new( + p.TIM2.reborrow(), + Some(PwmPin::new(p.PA15.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PB3.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PB10.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PB11.reborrow(), OutputType::PushPull)), + khz(10), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().tim2_remap(), 3); + } + + connectivity_line::run(&mut p); + value_line::run(&mut p); + + info!("Test OK"); + cortex_m::asm::bkpt(); +} + +#[cfg(feature = "afio-connectivity-line")] +mod connectivity_line { + use embassy_stm32::can::Can; + use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; + use embassy_stm32::i2s::I2S; + use embassy_stm32::spi::Spi; + + use super::*; + + pub fn run(p: &mut Peripherals) { + // USART3 + { + // partial remap RX/TX/RTS/CTS + reset_afio_registers(); + Uart::new_blocking_with_rtscts( + p.USART3.reborrow(), + p.PC11.reborrow(), + p.PC10.reborrow(), + p.PB14.reborrow(), + p.PB13.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 1); + } + { + // partial remap RX/TX + reset_afio_registers(); + Uart::new_blocking( + p.USART3.reborrow(), + p.PC11.reborrow(), + p.PC10.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 1); + } + { + // partial remap TX + reset_afio_registers(); + Uart::new_blocking_half_duplex( + p.USART3.reborrow(), + p.PC10.reborrow(), + Default::default(), + embassy_stm32::usart::HalfDuplexReadback::NoReadback, + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 1); + } + { + // partial remap TX async + reset_afio_registers(); + UartTx::new( + p.USART3.reborrow(), + p.PC10.reborrow(), + p.DMA1_CH2.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 1); + } + { + // partial remap TX/CTS async + reset_afio_registers(); + UartTx::new_with_cts( + p.USART3.reborrow(), + p.PC10.reborrow(), + p.PB13.reborrow(), + p.DMA1_CH2.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 1); + } + { + // partial remap RX async + reset_afio_registers(); + UartRx::new( + p.USART3.reborrow(), + Irqs, + p.PC11.reborrow(), + p.DMA1_CH3.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 1); + } + { + // partial remap RX async + reset_afio_registers(); + UartRx::new_with_rts( + p.USART3.reborrow(), + Irqs, + p.PC11.reborrow(), + p.PB14.reborrow(), + p.DMA1_CH3.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 1); + } + { + // partial remap RX/TX async + reset_afio_registers(); + Uart::new( + p.USART3.reborrow(), + p.PC11.reborrow(), + p.PC10.reborrow(), + Irqs, + p.DMA1_CH2.reborrow(), + p.DMA1_CH3.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 1); + } + { + // partial remap RX/TX/RTS/CTS async + reset_afio_registers(); + Uart::new_with_rtscts( + p.USART3.reborrow(), + p.PC11.reborrow(), + p.PC10.reborrow(), + Irqs, + p.PB14.reborrow(), + p.PB13.reborrow(), + p.DMA1_CH2.reborrow(), + p.DMA1_CH3.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 1); + } + { + // full remap RX/TX/RTS/CTS + reset_afio_registers(); + Uart::new_blocking_with_rtscts( + p.USART3.reborrow(), + p.PD9.reborrow(), + p.PD8.reborrow(), + p.PD12.reborrow(), + p.PD11.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 3); + } + { + // full remap RX/TX + reset_afio_registers(); + Uart::new_blocking( + p.USART3.reborrow(), + p.PD9.reborrow(), + p.PD8.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 3); + } + { + // full remap TX + reset_afio_registers(); + Uart::new_blocking_half_duplex( + p.USART3.reborrow(), + p.PD8.reborrow(), + Default::default(), + embassy_stm32::usart::HalfDuplexReadback::NoReadback, + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 3); + } + { + // full remap TX async + reset_afio_registers(); + UartTx::new( + p.USART3.reborrow(), + p.PD8.reborrow(), + p.DMA1_CH2.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 3); + } + { + // full remap TX/CTS async + reset_afio_registers(); + UartTx::new_with_cts( + p.USART3.reborrow(), + p.PD8.reborrow(), + p.PD11.reborrow(), + p.DMA1_CH2.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 3); + } + { + // full remap RX async + reset_afio_registers(); + UartRx::new( + p.USART3.reborrow(), + Irqs, + p.PD9.reborrow(), + p.DMA1_CH3.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 3); + } + { + // full remap RX async + reset_afio_registers(); + UartRx::new_with_rts( + p.USART3.reborrow(), + Irqs, + p.PD9.reborrow(), + p.PD12.reborrow(), + p.DMA1_CH3.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 3); + } + { + // full remap RX/TX async + reset_afio_registers(); + Uart::new( + p.USART3.reborrow(), + p.PD9.reborrow(), + p.PD8.reborrow(), + Irqs, + p.DMA1_CH2.reborrow(), + p.DMA1_CH3.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 3); + } + { + // full remap RX/TX/RTS/CTS async + reset_afio_registers(); + Uart::new_with_rtscts( + p.USART3.reborrow(), + p.PD9.reborrow(), + p.PD8.reborrow(), + Irqs, + p.PD12.reborrow(), + p.PD11.reborrow(), + p.DMA1_CH2.reborrow(), + p.DMA1_CH3.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart3_remap(), 3); + } + + // SPI3 + { + // no remap SCK/MISO/MOSI + afio_registers_set_remap(); + Spi::new_blocking( + p.SPI3.reborrow(), + p.PB3.reborrow(), + p.PB5.reborrow(), + p.PB4.reborrow(), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().spi3_remap(), false); + } + { + // no remap SCK/MOSI + afio_registers_set_remap(); + Spi::new_blocking_txonly( + p.SPI3.reborrow(), + p.PB3.reborrow(), + p.PB5.reborrow(), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().spi3_remap(), false); + } + { + // no remap MOSI + afio_registers_set_remap(); + Spi::new_blocking_txonly_nosck(p.SPI3.reborrow(), p.PB5.reborrow(), Default::default()); + defmt::assert_eq!(AFIO.mapr().read().spi3_remap(), false); + } + { + // no remap SCK/MISO + afio_registers_set_remap(); + Spi::new_blocking_rxonly( + p.SPI3.reborrow(), + p.PB3.reborrow(), + p.PB4.reborrow(), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().spi3_remap(), false); + } + { + // remap SCK/MISO/MOSI + reset_afio_registers(); + Spi::new_blocking( + p.SPI3.reborrow(), + p.PC10.reborrow(), + p.PC12.reborrow(), + p.PC11.reborrow(), + Default::default(), + ); + + defmt::assert_eq!(AFIO.mapr().read().spi3_remap(), true); + } + { + // remap SCK/MOSI + reset_afio_registers(); + Spi::new_blocking_txonly( + p.SPI3.reborrow(), + p.PC10.reborrow(), + p.PC12.reborrow(), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().spi3_remap(), true); + } + { + // remap MOSI + reset_afio_registers(); + Spi::new_blocking_txonly_nosck(p.SPI3.reborrow(), p.PB5.reborrow(), Default::default()); + defmt::assert_eq!(AFIO.mapr().read().spi3_remap(), true); + } + { + // remap SCK/MISO + reset_afio_registers(); + Spi::new_blocking_rxonly( + p.SPI3.reborrow(), + p.PC10.reborrow(), + p.PC11.reborrow(), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().spi3_remap(), true); + } + + // I2S3 + { + // no remap SD/WS/CK/MCK + afio_registers_set_remap(); + I2S::new_txonly( + p.SPI3.reborrow(), + p.PB5.reborrow(), + p.PA15.reborrow(), + p.PB3.reborrow(), + p.PC7.reborrow(), + p.DMA2_CH2.reborrow(), + &mut [0u16; 0], + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().spi3_remap(), false); + } + { + // no remap SD/WS/CK + afio_registers_set_remap(); + I2S::new_txonly_nomck( + p.SPI3.reborrow(), + p.PB5.reborrow(), + p.PA15.reborrow(), + p.PB3.reborrow(), + p.DMA2_CH2.reborrow(), + &mut [0u16; 0], + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().spi3_remap(), false); + } + { + // no remap SD/WS/CK/MCK + afio_registers_set_remap(); + I2S::new_rxonly( + p.SPI3.reborrow(), + p.PB4.reborrow(), + p.PA15.reborrow(), + p.PB3.reborrow(), + p.PC7.reborrow(), + p.DMA2_CH1.reborrow(), + &mut [0u16; 0], + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().spi3_remap(), true); + } + { + // remap SD/WS/CK/MCK + reset_afio_registers(); + I2S::new_txonly( + p.SPI3.reborrow(), + p.PC12.reborrow(), + p.PA4.reborrow(), + p.PC10.reborrow(), + p.PC7.reborrow(), + p.DMA2_CH2.reborrow(), + &mut [0u16; 0], + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().spi3_remap(), true); + } + { + // remap SD/WS/CK + reset_afio_registers(); + I2S::new_txonly_nomck( + p.SPI3.reborrow(), + p.PC12.reborrow(), + p.PA4.reborrow(), + p.PC10.reborrow(), + p.DMA2_CH2.reborrow(), + &mut [0u16; 0], + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().spi3_remap(), true); + } + { + // remap SD/WS/CK/MCK + reset_afio_registers(); + I2S::new_rxonly( + p.SPI3.reborrow(), + p.PC11.reborrow(), + p.PA4.reborrow(), + p.PC10.reborrow(), + p.PC7.reborrow(), + p.DMA2_CH1.reborrow(), + &mut [0u16; 0], + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().spi3_remap(), true); + } + + // CAN2 + { + // no remap + afio_registers_set_remap(); + Can::new(p.CAN2.reborrow(), p.PB12.reborrow(), p.PB13.reborrow(), Irqs); + defmt::assert_eq!(AFIO.mapr().read().can2_remap(), false); + } + { + // remap + reset_afio_registers(); + Can::new(p.CAN2.reborrow(), p.PB5.reborrow(), p.PB6.reborrow(), Irqs); + defmt::assert_eq!(AFIO.mapr().read().can2_remap(), true); + } + + // Ethernet + { + // no remap RMII + afio_registers_set_remap(); + Ethernet::new( + &mut PacketQueue::<1, 1>::new(), + p.ETH.reborrow(), + Irqs, + p.PA1.reborrow(), + p.PA2.reborrow(), + p.PC1.reborrow(), + p.PA7.reborrow(), + p.PC4.reborrow(), + p.PC5.reborrow(), + p.PB12.reborrow(), + p.PB13.reborrow(), + p.PB11.reborrow(), + GenericPhy::new_auto(), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().eth_remap(), false); + } + { + // no remap MII + afio_registers_set_remap(); + Ethernet::new_mii( + &mut PacketQueue::<1, 1>::new(), + p.ETH.reborrow(), + Irqs, + p.PA1.reborrow(), + p.PC3.reborrow(), + p.PA2.reborrow(), + p.PC1.reborrow(), + p.PA7.reborrow(), + p.PC4.reborrow(), + p.PC5.reborrow(), + p.PB0.reborrow(), + p.PB1.reborrow(), + p.PB12.reborrow(), + p.PB13.reborrow(), + p.PC2.reborrow(), + p.PB8.reborrow(), + p.PB11.reborrow(), + GenericPhy::new_auto(), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().eth_remap(), false); + } + { + // remap RMII + reset_afio_registers(); + Ethernet::new( + &mut PacketQueue::<1, 1>::new(), + p.ETH.reborrow(), + Irqs, + p.PA1.reborrow(), + p.PA2.reborrow(), + p.PC1.reborrow(), + p.PD8.reborrow(), + p.PD9.reborrow(), + p.PD10.reborrow(), + p.PB12.reborrow(), + p.PB13.reborrow(), + p.PB11.reborrow(), + GenericPhy::new_auto(), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().eth_remap(), true); + } + { + // remap MII + reset_afio_registers(); + Ethernet::new_mii( + &mut PacketQueue::<1, 1>::new(), + p.ETH.reborrow(), + Irqs, + p.PA1.reborrow(), + p.PC3.reborrow(), + p.PA2.reborrow(), + p.PC1.reborrow(), + p.PD8.reborrow(), + p.PD9.reborrow(), + p.PD10.reborrow(), + p.PD11.reborrow(), + p.PD12.reborrow(), + p.PB12.reborrow(), + p.PB13.reborrow(), + p.PC2.reborrow(), + p.PB8.reborrow(), + p.PB11.reborrow(), + GenericPhy::new_auto(), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().eth_remap(), true); + } + + // CAN1 + { + // no remap + afio_registers_set_remap(); + Can::new(p.CAN1.reborrow(), p.PA11.reborrow(), p.PA12.reborrow(), Irqs); + defmt::assert_eq!(AFIO.mapr().read().can1_remap(), 0); + } + { + // partial remap + reset_afio_registers(); + Can::new(p.CAN1.reborrow(), p.PB8.reborrow(), p.PB9.reborrow(), Irqs); + defmt::assert_eq!(AFIO.mapr().read().can1_remap(), 2); + } + { + // full remap + reset_afio_registers(); + Can::new(p.CAN1.reborrow(), p.PD0.reborrow(), p.PD1.reborrow(), Irqs); + defmt::assert_eq!(AFIO.mapr().read().can1_remap(), 3); + } + + // USART2 + { + // no remap RX/TX/RTS/CTS + afio_registers_set_remap(); + Uart::new_blocking_with_rtscts( + p.USART2.reborrow(), + p.PA3.reborrow(), + p.PA2.reborrow(), + p.PA1.reborrow(), + p.PA0.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart2_remap(), false); + } + { + // no remap RX/TX + afio_registers_set_remap(); + Uart::new_blocking( + p.USART2.reborrow(), + p.PA3.reborrow(), + p.PA2.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart2_remap(), false); + } + { + // no remap TX + afio_registers_set_remap(); + Uart::new_blocking_half_duplex( + p.USART2.reborrow(), + p.PA2.reborrow(), + Default::default(), + embassy_stm32::usart::HalfDuplexReadback::NoReadback, + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart2_remap(), false); + } + { + // full remap RX/TX/RTS/CTS + reset_afio_registers(); + Uart::new_blocking_with_rtscts( + p.USART2.reborrow(), + p.PD6.reborrow(), + p.PD5.reborrow(), + p.PD4.reborrow(), + p.PD3.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart2_remap(), false); + } + { + // full remap RX/TX + reset_afio_registers(); + Uart::new_blocking( + p.USART2.reborrow(), + p.PD6.reborrow(), + p.PD5.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart2_remap(), false); + } + { + // full remap TX + reset_afio_registers(); + Uart::new_blocking_half_duplex( + p.USART2.reborrow(), + p.PD5.reborrow(), + Default::default(), + embassy_stm32::usart::HalfDuplexReadback::NoReadback, + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart2_remap(), true); + } + + // USART1 + { + // no remap RX/TX/RTS/CTS + afio_registers_set_remap(); + Uart::new_blocking_with_rtscts( + p.USART1.reborrow(), + p.PA10.reborrow(), + p.PA9.reborrow(), + p.PA12.reborrow(), + p.PA11.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart1_remap(), false); + } + { + // no remap RX/TX + afio_registers_set_remap(); + Uart::new_blocking( + p.USART1.reborrow(), + p.PA10.reborrow(), + p.PA9.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart1_remap(), false); + } + { + // no remap TX + afio_registers_set_remap(); + Uart::new_blocking_half_duplex( + p.USART1.reborrow(), + p.PA9.reborrow(), + Default::default(), + embassy_stm32::usart::HalfDuplexReadback::NoReadback, + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart1_remap(), false); + } + { + // remap RX/TX/RTS/CTS + reset_afio_registers(); + Uart::new_blocking_with_rtscts( + p.USART1.reborrow(), + p.PB7.reborrow(), + p.PB6.reborrow(), + p.PA12.reborrow(), + p.PA11.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart1_remap(), true); + } + { + // remap RX/TX + reset_afio_registers(); + Uart::new_blocking( + p.USART1.reborrow(), + p.PB7.reborrow(), + p.PB6.reborrow(), + Default::default(), + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart1_remap(), true); + } + { + // remap TX + reset_afio_registers(); + Uart::new_blocking_half_duplex( + p.USART1.reborrow(), + p.PB6.reborrow(), + Default::default(), + embassy_stm32::usart::HalfDuplexReadback::NoReadback, + ) + .unwrap(); + defmt::assert_eq!(AFIO.mapr().read().usart1_remap(), true); + } + + // TIM1 + { + // full remap + reset_afio_registers(); + SimplePwm::new( + p.TIM1.reborrow(), + Some(PwmPin::new(p.PE9.reborrow(), OutputType::PushPull)), + Some(PwmPin::new(p.PE11.reborrow(), OutputType::PushPull)), + None, + None, + khz(10), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr().read().tim1_remap(), 3); + } + } +} + +#[cfg(feature = "afio-value-line")] +mod value_line { + use super::*; + + pub fn run(p: &mut Peripherals) { + // TIM13 + { + // no remap + reset_afio_registers(); + SimplePwm::new( + p.TIM13.reborrow(), + Some(PwmPin::new(p.PC8.reborrow(), OutputType::PushPull)), + None, + None, + None, + khz(10), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr2().read().tim13_remap(), false); + } + { + // remap + reset_afio_registers(); + SimplePwm::new( + p.TIM13.reborrow(), + Some(PwmPin::new(p.PB0.reborrow(), OutputType::PushPull)), + None, + None, + None, + khz(10), + Default::default(), + ); + defmt::assert_eq!(AFIO.mapr2().read().tim13_remap(), true); + } + } +} + +#[cfg(not(feature = "afio-connectivity-line"))] +mod connectivity_line { + use super::*; + + pub fn run(_: &mut Peripherals) {} +} + +#[cfg(not(feature = "afio-value-line"))] +mod value_line { + use super::*; + + pub fn run(_: &mut Peripherals) {} +} + +fn reset_afio_registers() { + set_afio_registers(false, 0); +} + +fn afio_registers_set_remap() { + set_afio_registers(true, 1); +} + +fn set_afio_registers(bool_val: bool, num_val: u8) { + AFIO.mapr().modify(|w| { + w.set_swj_cfg(embassy_stm32::pac::afio::vals::SwjCfg::NO_OP); + w.set_can1_remap(num_val); + w.set_can2_remap(bool_val); + w.set_eth_remap(bool_val); + w.set_i2c1_remap(bool_val); + w.set_spi1_remap(bool_val); + w.set_spi3_remap(bool_val); + w.set_tim1_remap(num_val); + w.set_tim2_remap(num_val); + w.set_tim3_remap(num_val); + w.set_tim4_remap(bool_val); + w.set_usart1_remap(bool_val); + w.set_usart2_remap(bool_val); + w.set_usart3_remap(num_val); + }); + + AFIO.mapr2().modify(|w| { + w.set_cec_remap(bool_val); + w.set_tim9_remap(bool_val); + w.set_tim10_remap(bool_val); + w.set_tim11_remap(bool_val); + w.set_tim12_remap(bool_val); + w.set_tim13_remap(bool_val); + w.set_tim14_remap(bool_val); + w.set_tim15_remap(bool_val); + w.set_tim16_remap(bool_val); + w.set_tim17_remap(bool_val); + }); +} diff --git a/tests/stm32/src/common.rs b/tests/stm32/src/common.rs index cb63b3374..f800769ab 100644 --- a/tests/stm32/src/common.rs +++ b/tests/stm32/src/common.rs @@ -103,7 +103,7 @@ define_peris!( SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA1_CH3, SPI_RX_DMA = DMA1_CH2, @irq UART = {USART1 => embassy_stm32::usart::InterruptHandler;}, ); -#[cfg(feature = "stm32f103c8")] +#[cfg(any(feature = "stm32f100rd", feature = "stm32f103c8", feature = "stm32f107vc"))] define_peris!( UART = USART1, UART_TX = PA9, UART_RX = PA10, UART_TX_DMA = DMA1_CH4, UART_RX_DMA = DMA1_CH5, SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA1_CH3, SPI_RX_DMA = DMA1_CH2, -- cgit From 7419b398bf7cc5c1ff164c504f4a4027cd6bcd3b Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 5 Sep 2025 23:00:31 +0200 Subject: stm32/afio: use type inference for timer remaps as well. --- tests/stm32/src/bin/afio.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/stm32/src/bin/afio.rs b/tests/stm32/src/bin/afio.rs index c684b7b3e..cc44dc59c 100644 --- a/tests/stm32/src/bin/afio.rs +++ b/tests/stm32/src/bin/afio.rs @@ -6,7 +6,7 @@ mod common; use common::*; use embassy_executor::Spawner; -use embassy_stm32::gpio::{OutputType, Pull}; +use embassy_stm32::gpio::{AfioRemap, OutputType, Pull}; use embassy_stm32::pac::AFIO; use embassy_stm32::time::khz; use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; @@ -173,7 +173,7 @@ async fn main(_spawner: Spawner) { { // no remap afio_registers_set_remap(); - SimplePwm::new( + SimplePwm::new::>( p.TIM1.reborrow(), Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), Some(PwmPin::new(p.PA9.reborrow(), OutputType::PushPull)), @@ -187,7 +187,7 @@ async fn main(_spawner: Spawner) { { // no remap afio_registers_set_remap(); - SimplePwm::new( + SimplePwm::new::>( p.TIM1.reborrow(), Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), None, @@ -201,7 +201,7 @@ async fn main(_spawner: Spawner) { { // partial remap reset_afio_registers(); - ComplementaryPwm::new( + ComplementaryPwm::new::>( p.TIM1.reborrow(), Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), None, @@ -219,7 +219,7 @@ async fn main(_spawner: Spawner) { { // partial remap reset_afio_registers(); - ComplementaryPwm::new( + ComplementaryPwm::new::>( p.TIM1.reborrow(), Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), Some(ComplementaryPwmPin::new(p.PA7.reborrow(), OutputType::PushPull)), @@ -237,7 +237,7 @@ async fn main(_spawner: Spawner) { { // partial remap reset_afio_registers(); - InputCapture::new( + InputCapture::new::>( p.TIM1.reborrow(), Some(CapturePin::new(p.PA8.reborrow(), Pull::Down)), None, @@ -252,13 +252,13 @@ async fn main(_spawner: Spawner) { { // partial remap reset_afio_registers(); - PwmInput::new_ch1(p.TIM1.reborrow(), p.PA8.reborrow(), Pull::Down, khz(10)); + PwmInput::new_ch1::>(p.TIM1.reborrow(), p.PA8.reborrow(), Pull::Down, khz(10)); defmt::assert_eq!(AFIO.mapr().read().tim1_remap(), 1); } { // partial remap reset_afio_registers(); - Qei::new( + Qei::new::>( p.TIM1.reborrow(), QeiPin::new(p.PA8.reborrow()), QeiPin::new(p.PA9.reborrow()), @@ -270,7 +270,7 @@ async fn main(_spawner: Spawner) { { // no remap afio_registers_set_remap(); - SimplePwm::new( + SimplePwm::new::>( p.TIM2.reborrow(), Some(PwmPin::new(p.PA0.reborrow(), OutputType::PushPull)), Some(PwmPin::new(p.PA1.reborrow(), OutputType::PushPull)), @@ -284,7 +284,7 @@ async fn main(_spawner: Spawner) { { // partial remap 1 reset_afio_registers(); - SimplePwm::new( + SimplePwm::new::>( p.TIM2.reborrow(), Some(PwmPin::new(p.PA15.reborrow(), OutputType::PushPull)), Some(PwmPin::new(p.PB3.reborrow(), OutputType::PushPull)), @@ -298,7 +298,7 @@ async fn main(_spawner: Spawner) { { // partial remap 2 reset_afio_registers(); - SimplePwm::new( + SimplePwm::new::>( p.TIM2.reborrow(), Some(PwmPin::new(p.PA0.reborrow(), OutputType::PushPull)), Some(PwmPin::new(p.PA1.reborrow(), OutputType::PushPull)), @@ -312,7 +312,7 @@ async fn main(_spawner: Spawner) { { // full remap reset_afio_registers(); - SimplePwm::new( + SimplePwm::new::>( p.TIM2.reborrow(), Some(PwmPin::new(p.PA15.reborrow(), OutputType::PushPull)), Some(PwmPin::new(p.PB3.reborrow(), OutputType::PushPull)), -- cgit