aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJakob <[email protected]>2025-11-07 15:54:35 +0100
committerGitHub <[email protected]>2025-11-07 15:54:35 +0100
commit1fd44118a7ba5329b256e3d45c04f606722eb3e9 (patch)
tree25ecc54d755affca2a9e9abdddd4227a087ef7eb /tests
parentf4746467438b9d385f03b85823e0eb6ce9f49ee9 (diff)
parentb68253e1aa38a9251b10219df4da3519cecf33e7 (diff)
Merge branch 'main' into into_ring_buffered_adc_for_g4
Diffstat (limited to 'tests')
-rw-r--r--tests/stm32/Cargo.toml3
-rw-r--r--tests/stm32/src/bin/rtc.rs23
-rw-r--r--tests/stm32/src/bin/spi.rs7
-rw-r--r--tests/stm32/src/bin/spi_dma.rs7
-rw-r--r--tests/stm32/src/bin/stop.rs13
-rw-r--r--tests/stm32/src/common.rs2
6 files changed, 39 insertions, 16 deletions
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml
index 1161e827b..b92b47be2 100644
--- a/tests/stm32/Cargo.toml
+++ b/tests/stm32/Cargo.toml
@@ -73,7 +73,7 @@ teleprobe-meta = "1"
73embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } 73embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] }
74embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } 74embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] }
75embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "tick-hz-131_072", "defmt-timestamp-uptime"] } 75embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "tick-hz-131_072", "defmt-timestamp-uptime"] }
76embassy-stm32 = { version = "0.4.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "memory-x", "time-driver-any"] } 76embassy-stm32 = { version = "0.4.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "memory-x", "time-driver-any", "_allow-disable-rtc"] }
77embassy-futures = { version = "0.1.2", path = "../../embassy-futures" } 77embassy-futures = { version = "0.1.2", path = "../../embassy-futures" }
78embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", optional = true, features = ["defmt", "stm32wb55rg", "ble"] } 78embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", optional = true, features = ["defmt", "stm32wb55rg", "ble"] }
79embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } 79embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] }
@@ -94,6 +94,7 @@ rand_core = { version = "0.9.1", default-features = false }
94rand_chacha = { version = "0.9.0", default-features = false } 94rand_chacha = { version = "0.9.0", default-features = false }
95static_cell = "2" 95static_cell = "2"
96portable-atomic = { version = "1.5", features = [] } 96portable-atomic = { version = "1.5", features = [] }
97critical-section = "1.1"
97 98
98chrono = { version = "^0.4", default-features = false, optional = true} 99chrono = { version = "^0.4", default-features = false, optional = true}
99sha2 = { version = "0.10.8", default-features = false } 100sha2 = { version = "0.10.8", default-features = false }
diff --git a/tests/stm32/src/bin/rtc.rs b/tests/stm32/src/bin/rtc.rs
index 5fe98d807..eb27af4ca 100644
--- a/tests/stm32/src/bin/rtc.rs
+++ b/tests/stm32/src/bin/rtc.rs
@@ -10,13 +10,19 @@ use common::*;
10use defmt::assert; 10use defmt::assert;
11use embassy_executor::Spawner; 11use embassy_executor::Spawner;
12use embassy_stm32::rcc::LsConfig; 12use embassy_stm32::rcc::LsConfig;
13#[cfg(feature = "stop")]
14use embassy_stm32::rtc::Rtc;
15#[cfg(not(feature = "stop"))]
13use embassy_stm32::rtc::{Rtc, RtcConfig}; 16use embassy_stm32::rtc::{Rtc, RtcConfig};
14use embassy_time::Timer; 17use embassy_time::Timer;
15
16#[embassy_executor::main] 18#[embassy_executor::main]
17async fn main(_spawner: Spawner) { 19async fn main(_spawner: Spawner) {
18 let mut config = config(); 20 let mut config = config();
19 config.rcc.ls = LsConfig::default_lse(); 21 config.rcc.ls = LsConfig::default_lse();
22 #[cfg(feature = "stop")]
23 {
24 config.rtc._disable_rtc = false;
25 }
20 26
21 let p = init_with_config(config); 27 let p = init_with_config(config);
22 info!("Hello World!"); 28 info!("Hello World!");
@@ -26,14 +32,25 @@ async fn main(_spawner: Spawner) {
26 .and_hms_opt(10, 30, 15) 32 .and_hms_opt(10, 30, 15)
27 .unwrap(); 33 .unwrap();
28 34
29 let mut rtc = Rtc::new(p.RTC, RtcConfig::default()); 35 #[cfg(not(feature = "stop"))]
36 let (mut rtc, time_provider) = Rtc::new(p.RTC, RtcConfig::default());
37
38 #[cfg(feature = "stop")]
39 let (rtc, time_provider) = Rtc::new(p.RTC);
30 40
41 #[cfg(not(feature = "stop"))]
31 rtc.set_datetime(now.into()).expect("datetime not set"); 42 rtc.set_datetime(now.into()).expect("datetime not set");
32 43
44 #[cfg(feature = "stop")]
45 critical_section::with(|cs| {
46 rtc.borrow_mut(cs).set_datetime(now.into()).expect("datetime not set");
47 });
48
33 info!("Waiting 5 seconds"); 49 info!("Waiting 5 seconds");
34 Timer::after_millis(5000).await; 50 Timer::after_millis(5000).await;
35 51
36 let then: NaiveDateTime = rtc.now().unwrap().into(); 52 let then: NaiveDateTime = time_provider.now().unwrap().into();
53
37 let seconds = (then - now).num_seconds(); 54 let seconds = (then - now).num_seconds();
38 55
39 info!("measured = {}", seconds); 56 info!("measured = {}", seconds);
diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs
index e8310866a..cedff772c 100644
--- a/tests/stm32/src/bin/spi.rs
+++ b/tests/stm32/src/bin/spi.rs
@@ -8,6 +8,7 @@ use defmt::assert_eq;
8use embassy_executor::Spawner; 8use embassy_executor::Spawner;
9use embassy_stm32::gpio::{Level, Output, Speed}; 9use embassy_stm32::gpio::{Level, Output, Speed};
10use embassy_stm32::mode::Blocking; 10use embassy_stm32::mode::Blocking;
11use embassy_stm32::spi::mode::Master;
11use embassy_stm32::spi::{self, Spi, Word}; 12use embassy_stm32::spi::{self, Spi, Word};
12use embassy_stm32::time::Hertz; 13use embassy_stm32::time::Hertz;
13 14
@@ -65,7 +66,7 @@ async fn main(_spawner: Spawner) {
65 cortex_m::asm::bkpt(); 66 cortex_m::asm::bkpt();
66} 67}
67 68
68fn test_txrx<W: Word + From<u8> + defmt::Format + Eq>(spi: &mut Spi<'_, Blocking>) 69fn test_txrx<W: Word + From<u8> + defmt::Format + Eq>(spi: &mut Spi<'_, Blocking, Master>)
69where 70where
70 W: core::ops::Not<Output = W>, 71 W: core::ops::Not<Output = W>,
71{ 72{
@@ -109,7 +110,7 @@ where
109 spi.blocking_write::<u8>(&[]).unwrap(); 110 spi.blocking_write::<u8>(&[]).unwrap();
110} 111}
111 112
112fn test_rx<W: Word + From<u8> + defmt::Format + Eq>(spi: &mut Spi<'_, Blocking>, mosi_out: &mut Output<'_>) 113fn test_rx<W: Word + From<u8> + defmt::Format + Eq>(spi: &mut Spi<'_, Blocking, Master>, mosi_out: &mut Output<'_>)
113where 114where
114 W: core::ops::Not<Output = W>, 115 W: core::ops::Not<Output = W>,
115{ 116{
@@ -125,7 +126,7 @@ where
125 spi.blocking_read::<u8>(&mut []).unwrap(); 126 spi.blocking_read::<u8>(&mut []).unwrap();
126} 127}
127 128
128fn test_tx<W: Word + From<u8> + defmt::Format + Eq>(spi: &mut Spi<'_, Blocking>) 129fn test_tx<W: Word + From<u8> + defmt::Format + Eq>(spi: &mut Spi<'_, Blocking, Master>)
129where 130where
130 W: core::ops::Not<Output = W>, 131 W: core::ops::Not<Output = W>,
131{ 132{
diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs
index b4fdb8faa..c8cd92401 100644
--- a/tests/stm32/src/bin/spi_dma.rs
+++ b/tests/stm32/src/bin/spi_dma.rs
@@ -8,6 +8,7 @@ use defmt::assert_eq;
8use embassy_executor::Spawner; 8use embassy_executor::Spawner;
9use embassy_stm32::gpio::{Level, Output, Speed}; 9use embassy_stm32::gpio::{Level, Output, Speed};
10use embassy_stm32::mode::Async; 10use embassy_stm32::mode::Async;
11use embassy_stm32::spi::mode::Master;
11use embassy_stm32::spi::{self, Spi, Word}; 12use embassy_stm32::spi::{self, Spi, Word};
12use embassy_stm32::time::Hertz; 13use embassy_stm32::time::Hertz;
13 14
@@ -78,7 +79,7 @@ async fn main(_spawner: Spawner) {
78 cortex_m::asm::bkpt(); 79 cortex_m::asm::bkpt();
79} 80}
80 81
81async fn test_txrx<W: Word + From<u8> + defmt::Format + Eq>(spi: &mut Spi<'_, Async>) 82async fn test_txrx<W: Word + From<u8> + defmt::Format + Eq>(spi: &mut Spi<'_, Async, Master>)
82where 83where
83 W: core::ops::Not<Output = W>, 84 W: core::ops::Not<Output = W>,
84{ 85{
@@ -142,7 +143,7 @@ where
142 spi.write(&buf).await.unwrap(); 143 spi.write(&buf).await.unwrap();
143} 144}
144 145
145async fn test_rx<W: Word + From<u8> + defmt::Format + Eq>(spi: &mut Spi<'_, Async>, mosi_out: &mut Output<'_>) 146async fn test_rx<W: Word + From<u8> + defmt::Format + Eq>(spi: &mut Spi<'_, Async, Master>, mosi_out: &mut Output<'_>)
146where 147where
147 W: core::ops::Not<Output = W>, 148 W: core::ops::Not<Output = W>,
148{ 149{
@@ -168,7 +169,7 @@ where
168 spi.blocking_read::<u8>(&mut []).unwrap(); 169 spi.blocking_read::<u8>(&mut []).unwrap();
169} 170}
170 171
171async fn test_tx<W: Word + From<u8> + defmt::Format + Eq>(spi: &mut Spi<'_, Async>) 172async fn test_tx<W: Word + From<u8> + defmt::Format + Eq>(spi: &mut Spi<'_, Async, Master>)
172where 173where
173 W: core::ops::Not<Output = W>, 174 W: core::ops::Not<Output = W>,
174{ 175{
diff --git a/tests/stm32/src/bin/stop.rs b/tests/stm32/src/bin/stop.rs
index 73580f0f2..1fe65d867 100644
--- a/tests/stm32/src/bin/stop.rs
+++ b/tests/stm32/src/bin/stop.rs
@@ -10,9 +10,9 @@ use common::*;
10use cortex_m_rt::entry; 10use cortex_m_rt::entry;
11use embassy_executor::Spawner; 11use embassy_executor::Spawner;
12use embassy_stm32::Config; 12use embassy_stm32::Config;
13use embassy_stm32::low_power::{Executor, StopMode, stop_ready, stop_with_rtc}; 13use embassy_stm32::low_power::{Executor, StopMode, stop_ready};
14use embassy_stm32::rcc::LsConfig; 14use embassy_stm32::rcc::LsConfig;
15use embassy_stm32::rtc::{Rtc, RtcConfig}; 15use embassy_stm32::rtc::Rtc;
16use embassy_time::Timer; 16use embassy_time::Timer;
17 17
18#[entry] 18#[entry]
@@ -49,6 +49,7 @@ async fn async_main(spawner: Spawner) {
49 49
50 let mut config = Config::default(); 50 let mut config = Config::default();
51 config.rcc.ls = LsConfig::default_lse(); 51 config.rcc.ls = LsConfig::default_lse();
52 config.rtc._disable_rtc = false;
52 53
53 // System Clock seems cannot be greater than 16 MHz 54 // System Clock seems cannot be greater than 16 MHz
54 #[cfg(any(feature = "stm32h563zi", feature = "stm32h503rb"))] 55 #[cfg(any(feature = "stm32h563zi", feature = "stm32h503rb"))]
@@ -65,11 +66,11 @@ async fn async_main(spawner: Spawner) {
65 .and_hms_opt(10, 30, 15) 66 .and_hms_opt(10, 30, 15)
66 .unwrap(); 67 .unwrap();
67 68
68 let mut rtc = Rtc::new(p.RTC, RtcConfig::default()); 69 let (rtc, _time_provider) = Rtc::new(p.RTC);
69 70
70 rtc.set_datetime(now.into()).expect("datetime not set"); 71 critical_section::with(|cs| {
71 72 rtc.borrow_mut(cs).set_datetime(now.into()).expect("datetime not set");
72 stop_with_rtc(rtc); 73 });
73 74
74 spawner.spawn(task_1().unwrap()); 75 spawner.spawn(task_1().unwrap());
75 spawner.spawn(task_2().unwrap()); 76 spawner.spawn(task_2().unwrap());
diff --git a/tests/stm32/src/common.rs b/tests/stm32/src/common.rs
index 2bd934d6f..096cce947 100644
--- a/tests/stm32/src/common.rs
+++ b/tests/stm32/src/common.rs
@@ -468,6 +468,8 @@ pub fn config() -> Config {
468 config.rcc.apb3_pre = APBPrescaler::DIV1; 468 config.rcc.apb3_pre = APBPrescaler::DIV1;
469 config.rcc.sys = Sysclk::PLL1_P; 469 config.rcc.sys = Sysclk::PLL1_P;
470 config.rcc.voltage_scale = VoltageScale::Scale0; 470 config.rcc.voltage_scale = VoltageScale::Scale0;
471
472 config.rtc._disable_rtc = true;
471 } 473 }
472 474
473 #[cfg(feature = "stm32h503rb")] 475 #[cfg(feature = "stm32h503rb")]