diff options
| author | xoviat <[email protected]> | 2023-08-26 20:37:01 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2023-08-26 20:37:01 -0500 |
| commit | db71887817e665c5c226e8775ad2d5814babac6e (patch) | |
| tree | 5ca82259ad73a91002b063e89ad2bc8369726c8e /tests | |
| parent | 1e430f74133acaeb31cb689ded3da77cb7b1c0ca (diff) | |
tests/stm32: add stop and cleanpu
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/stm32/Cargo.toml | 9 | ||||
| -rw-r--r-- | tests/stm32/src/bin/stop.rs | 53 |
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] |
| 9 | stm32f103c8 = ["embassy-stm32/stm32f103c8", "not-gpdma"] # Blue Pill | 9 | stm32f103c8 = ["embassy-stm32/stm32f103c8", "not-gpdma"] # Blue Pill |
| 10 | stm32f429zi = ["embassy-stm32/stm32f429zi", "chrono", "can", "not-gpdma", "dac-adc-pin"] # Nucleo "sdmmc" | 10 | stm32f429zi = ["embassy-stm32/stm32f429zi", "chrono", "stop", "can", "not-gpdma", "dac-adc-pin"] # Nucleo "sdmmc" |
| 11 | stm32g071rb = ["embassy-stm32/stm32g071rb", "not-gpdma", "dac-adc-pin"] # Nucleo | 11 | stm32g071rb = ["embassy-stm32/stm32g071rb", "not-gpdma", "dac-adc-pin"] # Nucleo |
| 12 | stm32c031c6 = ["embassy-stm32/stm32c031c6", "not-gpdma"] # Nucleo | 12 | stm32c031c6 = ["embassy-stm32/stm32c031c6", "not-gpdma"] # Nucleo |
| 13 | stm32g491re = ["embassy-stm32/stm32g491re", "not-gpdma"] # Nucleo | 13 | stm32g491re = ["embassy-stm32/stm32g491re", "not-gpdma"] # Nucleo |
| @@ -17,6 +17,7 @@ stm32h563zi = ["embassy-stm32/stm32h563zi"] # Nucleo | |||
| 17 | stm32u585ai = ["embassy-stm32/stm32u585ai"] # IoT board | 17 | stm32u585ai = ["embassy-stm32/stm32u585ai"] # IoT board |
| 18 | 18 | ||
| 19 | sdmmc = [] | 19 | sdmmc = [] |
| 20 | stop = ["embassy-stm32/low-power"] | ||
| 20 | chrono = ["embassy-stm32/chrono", "dep:chrono"] | 21 | chrono = ["embassy-stm32/chrono", "dep:chrono"] |
| 21 | can = [] | 22 | can = [] |
| 22 | ble = ["dep:embassy-stm32-wpan", "embassy-stm32-wpan/ble"] | 23 | ble = ["dep:embassy-stm32-wpan", "embassy-stm32-wpan/ble"] |
| @@ -47,6 +48,7 @@ micromath = "2.0.0" | |||
| 47 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } | 48 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } |
| 48 | rand_core = { version = "0.6", default-features = false } | 49 | rand_core = { version = "0.6", default-features = false } |
| 49 | rand_chacha = { version = "0.3", default-features = false } | 50 | rand_chacha = { version = "0.3", default-features = false } |
| 51 | static_cell = {version = "1.1", features = ["nightly"] } | ||
| 50 | 52 | ||
| 51 | chrono = { version = "^0.4", default-features = false, optional = true} | 53 | chrono = { version = "^0.4", default-features = false, optional = true} |
| 52 | 54 | ||
| @@ -88,6 +90,11 @@ path = "src/bin/spi_dma.rs" | |||
| 88 | required-features = [] | 90 | required-features = [] |
| 89 | 91 | ||
| 90 | [[bin]] | 92 | [[bin]] |
| 93 | name = "stop" | ||
| 94 | path = "src/bin/stop.rs" | ||
| 95 | required-features = [ "stop", "chrono",] | ||
| 96 | |||
| 97 | [[bin]] | ||
| 91 | name = "timer" | 98 | name = "timer" |
| 92 | path = "src/bin/timer.rs" | 99 | path = "src/bin/timer.rs" |
| 93 | required-features = [] | 100 | required-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"] | ||
| 7 | mod common; | ||
| 8 | |||
| 9 | use chrono::NaiveDate; | ||
| 10 | use common::*; | ||
| 11 | use cortex_m_rt::entry; | ||
| 12 | use embassy_executor::Spawner; | ||
| 13 | use embassy_stm32::low_power::{stop_with_rtc, Executor}; | ||
| 14 | use embassy_stm32::rtc::{Rtc, RtcClockSource, RtcConfig}; | ||
| 15 | use embassy_time::{Duration, Timer}; | ||
| 16 | use static_cell::make_static; | ||
| 17 | |||
| 18 | #[entry] | ||
| 19 | fn main() -> ! { | ||
| 20 | let executor = Executor::take(); | ||
| 21 | executor.run(|spawner| { | ||
| 22 | unwrap!(spawner.spawn(async_main(spawner))); | ||
| 23 | }); | ||
| 24 | } | ||
| 25 | |||
| 26 | #[embassy_executor::task] | ||
| 27 | async 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 | } | ||
