stop0 working

This commit is contained in:
Priec
2025-12-14 11:56:09 +01:00
parent 58561ec392
commit 49cc8dcc71
5 changed files with 44 additions and 1 deletions

View File

@@ -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 (STOP0STOP3)
#[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);