wake up pin working for the wake up

This commit is contained in:
Priec
2025-12-14 14:33:01 +01:00
parent f4ca3071f0
commit 20dfdbc335
5 changed files with 21 additions and 22 deletions

View File

@@ -14,7 +14,7 @@ use defmt::info;
pub async fn execute_low_power(
cmd: LowPowerCmd,
iwdg: &mut Option<Peri<'static, peripherals::IWDG>>
) -> ! {
) {
Timer::after(Duration::from_millis(10)).await;
match cmd {
@@ -45,14 +45,16 @@ pub async fn execute_low_power(
}
LowPowerCmd::StopMode(StopModeConfig { mode, entry }) => {
info!("Entering {:?} with {:?}", mode, entry);
if let Some(wdg) = iwdg.take() {
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),
StopMode::Stop3 => {
if let Some(wdg) = iwdg.take() {
init_watchdog_reset(wdg).await;
}
enter_stop3(entry);
}
}
}
}

View File

@@ -22,7 +22,7 @@ impl From<StopEntry> for u8 {
}
}
pub fn enter_stop0() -> ! {
pub fn enter_stop0() {
unsafe extern "C" {
fn rust_LL_PWR_SetPowerMode(mode: u32);
}
@@ -35,12 +35,11 @@ pub fn enter_stop0() -> ! {
let mut core = Peripherals::steal();
core.SCB.set_sleepdeep();
asm::wfi();
core.SCB.clear_sleepdeep();
}
cortex_m::asm::udf();
}
pub fn enter_stop1(entry: StopEntry) -> ! {
pub fn enter_stop1(entry: StopEntry) {
unsafe extern "C" {
fn HAL_PWREx_EnterSTOP1Mode(entry: u8);
}
@@ -48,11 +47,9 @@ pub fn enter_stop1(entry: StopEntry) -> ! {
unsafe {
HAL_PWREx_EnterSTOP1Mode(entry.into());
}
cortex_m::asm::udf()
}
pub fn enter_stop2(entry: StopEntry) -> ! {
pub fn enter_stop2(entry: StopEntry) {
unsafe extern "C" {
fn HAL_PWREx_EnterSTOP2Mode(entry: u8);
}
@@ -60,11 +57,9 @@ pub fn enter_stop2(entry: StopEntry) -> ! {
unsafe {
HAL_PWREx_EnterSTOP2Mode(entry.into());
}
cortex_m::asm::udf()
}
pub fn enter_stop3(entry: StopEntry) -> ! {
pub fn enter_stop3(entry: StopEntry) {
unsafe extern "C" {
fn HAL_PWREx_EnterSTOP3Mode(entry: u8);
}
@@ -72,6 +67,4 @@ pub fn enter_stop3(entry: StopEntry) -> ! {
unsafe {
HAL_PWREx_EnterSTOP3Mode(entry.into());
}
cortex_m::asm::udf()
}