aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorxoviat <[email protected]>2023-08-26 20:37:01 -0500
committerxoviat <[email protected]>2023-08-26 20:37:01 -0500
commitdb71887817e665c5c226e8775ad2d5814babac6e (patch)
tree5ca82259ad73a91002b063e89ad2bc8369726c8e /tests
parent1e430f74133acaeb31cb689ded3da77cb7b1c0ca (diff)
tests/stm32: add stop and cleanpu
Diffstat (limited to 'tests')
-rw-r--r--tests/stm32/Cargo.toml9
-rw-r--r--tests/stm32/src/bin/stop.rs53
2 files changed, 61 insertions, 1 deletions
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml
index 754356cb5..1f8c7373c 100644
--- a/tests/stm32/Cargo.toml
+++ b/tests/stm32/Cargo.toml
@@ -7,7 +7,7 @@ autobins = false
7 7
8[features] 8[features]
9stm32f103c8 = ["embassy-stm32/stm32f103c8", "not-gpdma"] # Blue Pill 9stm32f103c8 = ["embassy-stm32/stm32f103c8", "not-gpdma"] # Blue Pill
10stm32f429zi = ["embassy-stm32/stm32f429zi", "chrono", "can", "not-gpdma", "dac-adc-pin"] # Nucleo "sdmmc" 10stm32f429zi = ["embassy-stm32/stm32f429zi", "chrono", "stop", "can", "not-gpdma", "dac-adc-pin"] # Nucleo "sdmmc"
11stm32g071rb = ["embassy-stm32/stm32g071rb", "not-gpdma", "dac-adc-pin"] # Nucleo 11stm32g071rb = ["embassy-stm32/stm32g071rb", "not-gpdma", "dac-adc-pin"] # Nucleo
12stm32c031c6 = ["embassy-stm32/stm32c031c6", "not-gpdma"] # Nucleo 12stm32c031c6 = ["embassy-stm32/stm32c031c6", "not-gpdma"] # Nucleo
13stm32g491re = ["embassy-stm32/stm32g491re", "not-gpdma"] # Nucleo 13stm32g491re = ["embassy-stm32/stm32g491re", "not-gpdma"] # Nucleo
@@ -17,6 +17,7 @@ stm32h563zi = ["embassy-stm32/stm32h563zi"] # Nucleo
17stm32u585ai = ["embassy-stm32/stm32u585ai"] # IoT board 17stm32u585ai = ["embassy-stm32/stm32u585ai"] # IoT board
18 18
19sdmmc = [] 19sdmmc = []
20stop = ["embassy-stm32/low-power"]
20chrono = ["embassy-stm32/chrono", "dep:chrono"] 21chrono = ["embassy-stm32/chrono", "dep:chrono"]
21can = [] 22can = []
22ble = ["dep:embassy-stm32-wpan", "embassy-stm32-wpan/ble"] 23ble = ["dep:embassy-stm32-wpan", "embassy-stm32-wpan/ble"]
@@ -47,6 +48,7 @@ micromath = "2.0.0"
47panic-probe = { version = "0.3.0", features = ["print-defmt"] } 48panic-probe = { version = "0.3.0", features = ["print-defmt"] }
48rand_core = { version = "0.6", default-features = false } 49rand_core = { version = "0.6", default-features = false }
49rand_chacha = { version = "0.3", default-features = false } 50rand_chacha = { version = "0.3", default-features = false }
51static_cell = {version = "1.1", features = ["nightly"] }
50 52
51chrono = { version = "^0.4", default-features = false, optional = true} 53chrono = { version = "^0.4", default-features = false, optional = true}
52 54
@@ -88,6 +90,11 @@ path = "src/bin/spi_dma.rs"
88required-features = [] 90required-features = []
89 91
90[[bin]] 92[[bin]]
93name = "stop"
94path = "src/bin/stop.rs"
95required-features = [ "stop", "chrono",]
96
97[[bin]]
91name = "timer" 98name = "timer"
92path = "src/bin/timer.rs" 99path = "src/bin/timer.rs"
93required-features = [] 100required-features = []
diff --git a/tests/stm32/src/bin/stop.rs b/tests/stm32/src/bin/stop.rs
new file mode 100644
index 000000000..4a49bde9d
--- /dev/null
+++ b/tests/stm32/src/bin/stop.rs
@@ -0,0 +1,53 @@
1// required-features: stop,chrono
2
3#![no_std]
4#![no_main]
5#![feature(type_alias_impl_trait)]
6#[path = "../common.rs"]
7mod common;
8
9use chrono::NaiveDate;
10use common::*;
11use cortex_m_rt::entry;
12use embassy_executor::Spawner;
13use embassy_stm32::low_power::{stop_with_rtc, Executor};
14use embassy_stm32::rtc::{Rtc, RtcClockSource, RtcConfig};
15use embassy_time::{Duration, Timer};
16use static_cell::make_static;
17
18#[entry]
19fn main() -> ! {
20 let executor = Executor::take();
21 executor.run(|spawner| {
22 unwrap!(spawner.spawn(async_main(spawner)));
23 });
24}
25
26#[embassy_executor::task]
27async fn async_main(_spawner: Spawner) {
28 let mut config = config();
29
30 config.rcc.rtc = Some(RtcClockSource::LSI);
31
32 let p = embassy_stm32::init(config);
33 info!("Hello World!");
34
35 let now = NaiveDate::from_ymd_opt(2020, 5, 15)
36 .unwrap()
37 .and_hms_opt(10, 30, 15)
38 .unwrap();
39
40 let mut rtc = Rtc::new(p.RTC, RtcConfig::default());
41
42 rtc.set_datetime(now.into()).expect("datetime not set");
43
44 let rtc = make_static!(rtc);
45
46 stop_with_rtc(rtc);
47
48 info!("Waiting 5 seconds");
49 Timer::after(Duration::from_secs(5)).await;
50
51 info!("Test OK");
52 cortex_m::asm::bkpt();
53}