stop0 working
This commit is contained in:
@@ -49,6 +49,7 @@ pub async fn execute_low_power(
|
||||
init_watchdog_reset(wdg).await;
|
||||
}
|
||||
match mode {
|
||||
StopMode::Stop0 => enter_stop0(),
|
||||
StopMode::Stop1 => enter_stop1(entry),
|
||||
StopMode::Stop2 => enter_stop2(entry),
|
||||
StopMode::Stop3 => enter_stop3(entry),
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
// src/sleep/stop.rs
|
||||
|
||||
use cortex_m::peripheral::SCB;
|
||||
use cortex_m::Peripherals;
|
||||
use cortex_m::asm;
|
||||
|
||||
/// How to enter STOPx mode (STOP0–STOP3)
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, defmt::Format)]
|
||||
pub enum StopEntry {
|
||||
@@ -18,6 +22,24 @@ impl From<StopEntry> for u8 {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enter_stop0() -> ! {
|
||||
unsafe extern "C" {
|
||||
fn rust_LL_PWR_SetPowerMode(mode: u32);
|
||||
}
|
||||
|
||||
const LL_PWR_STOP0_MODE: u32 = 0; //stm32u5xx_ll_pwr.h
|
||||
|
||||
unsafe {
|
||||
rust_LL_PWR_SetPowerMode(LL_PWR_STOP0_MODE);
|
||||
|
||||
let mut core = Peripherals::steal();
|
||||
core.SCB.set_sleepdeep();
|
||||
asm::wfi();
|
||||
}
|
||||
|
||||
cortex_m::asm::udf();
|
||||
}
|
||||
|
||||
pub fn enter_stop1(entry: StopEntry) -> ! {
|
||||
unsafe extern "C" {
|
||||
fn HAL_PWREx_EnterSTOP1Mode(entry: u8);
|
||||
|
||||
Reference in New Issue
Block a user