stm32: add low-power mod
This commit is contained in:
parent
7d6edd7b15
commit
6d35bcc3d9
@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
|
|||||||
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-stm32-v$VERSION/embassy-stm32/src/"
|
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-stm32-v$VERSION/embassy-stm32/src/"
|
||||||
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-stm32/src/"
|
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-stm32/src/"
|
||||||
|
|
||||||
features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "time"]
|
features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "time", "low-power"]
|
||||||
flavors = [
|
flavors = [
|
||||||
{ regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" },
|
{ regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" },
|
||||||
{ regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" },
|
{ regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" },
|
||||||
@ -88,6 +88,7 @@ rt = ["stm32-metapac/rt"]
|
|||||||
defmt = ["dep:defmt", "bxcan/unstable-defmt", "embassy-sync/defmt", "embassy-embedded-hal/defmt", "embassy-hal-internal/defmt", "embedded-io-async?/defmt-03", "embassy-usb-driver?/defmt", "embassy-net-driver/defmt", "embassy-time?/defmt"]
|
defmt = ["dep:defmt", "bxcan/unstable-defmt", "embassy-sync/defmt", "embassy-embedded-hal/defmt", "embassy-hal-internal/defmt", "embedded-io-async?/defmt-03", "embassy-usb-driver?/defmt", "embassy-net-driver/defmt", "embassy-time?/defmt"]
|
||||||
|
|
||||||
exti = []
|
exti = []
|
||||||
|
low-power = []
|
||||||
|
|
||||||
## Automatically generate `memory.x` file using [`stm32-metapac`](https://docs.rs/stm32-metapac/)
|
## Automatically generate `memory.x` file using [`stm32-metapac`](https://docs.rs/stm32-metapac/)
|
||||||
memory-x = ["stm32-metapac/memory-x"]
|
memory-x = ["stm32-metapac/memory-x"]
|
||||||
|
@ -47,6 +47,8 @@ pub mod i2c;
|
|||||||
pub mod i2s;
|
pub mod i2s;
|
||||||
#[cfg(stm32wb)]
|
#[cfg(stm32wb)]
|
||||||
pub mod ipcc;
|
pub mod ipcc;
|
||||||
|
#[cfg(feature = "low-power")]
|
||||||
|
pub mod low_power;
|
||||||
#[cfg(quadspi)]
|
#[cfg(quadspi)]
|
||||||
pub mod qspi;
|
pub mod qspi;
|
||||||
#[cfg(rng)]
|
#[cfg(rng)]
|
||||||
|
15
embassy-stm32/src/low_power.rs
Normal file
15
embassy-stm32/src/low_power.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
use crate::rtc::{Rtc, RtcInstant};
|
||||||
|
|
||||||
|
static mut RTC: Option<&'static Rtc> = None;
|
||||||
|
|
||||||
|
pub fn stop_with_rtc(rtc: &'static Rtc) {
|
||||||
|
unsafe { RTC = Some(rtc) };
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn start_wakeup_alarm(requested_duration: embassy_time::Duration) -> RtcInstant {
|
||||||
|
unsafe { RTC }.unwrap().start_wakeup_alarm(requested_duration)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn stop_wakeup_alarm() -> RtcInstant {
|
||||||
|
unsafe { RTC }.unwrap().stop_wakeup_alarm()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user