moved handler

This commit is contained in:
Priec
2025-12-15 16:46:10 +01:00
parent 88341314dd
commit 4c7d9af29a
9 changed files with 21 additions and 19 deletions

View File

@@ -1,66 +0,0 @@
// src/sleep/handler.rs
use embassy_time::{Duration, Timer};
use embassy_stm32::peripherals;
use embassy_stm32::Peri;
use crate::sleep::stop::*;
use crate::wakeup::iwdg::init_watchdog_reset;
use crate::hw_uart_pc::init::{LowPowerCmd, StopMode, StopModeConfig};
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 {
LowPowerCmd::Standby8k => {
info!("Entering Standby with 8KB SRAM2 retention");
if let Some(wdg) = iwdg.take() {
init_watchdog_reset(wdg).await;
}
super::standby::enter_standby_with_sram2_8kb();
}
LowPowerCmd::StandbyFull => {
info!("Entering Standby with full SRAM2 retention");
if let Some(wdg) = iwdg.take() {
init_watchdog_reset(wdg).await;
}
super::standby::enter_standby_with_sram2_full();
}
LowPowerCmd::Standby => {
info!("Entering minimal Standby");
if let Some(wdg) = iwdg.take() {
init_watchdog_reset(wdg).await;
}
super::standby::enter_standby();
}
LowPowerCmd::Shutdown => {
info!("Entering Shutdown mode");
super::shutdown::enter_shutdown();
}
LowPowerCmd::StopMode(StopModeConfig { mode, entry }) => {
info!("Entering {:?} with {:?}", mode, entry);
match mode {
StopMode::Stop0 => enter_stop0(),
StopMode::Stop1 => enter_stop1(entry),
StopMode::Stop2 => enter_stop2(entry),
StopMode::Stop3 => {
if let Some(wdg) = iwdg.take() {
init_watchdog_reset(wdg).await;
}
enter_stop3(entry);
}
}
}
LowPowerCmd::Sleep => {
info!("Entering Sleep mode (WFI)...");
use crate::sleep::sleep::{enter_sleep_mode, SleepEntry};
enter_sleep_mode(SleepEntry::Wfi);
info!("Woke up from Sleep mode.");
}
}
}

View File

@@ -3,7 +3,6 @@
pub mod standby;
pub mod shutdown;
pub mod stop;
pub mod handler;
pub mod sleep;
pub use stop::StopEntry;

View File

@@ -9,7 +9,7 @@ pub fn enter_standby() -> ! {
HAL_PWR_EnterSTANDBYMode();
}
cortex_m::asm::udf(); // never happen marker
cortex_m::asm::udf();
}
pub fn enter_standby_with_sram2_8kb() -> ! {

View File

@@ -3,7 +3,7 @@
use cortex_m::Peripherals;
use cortex_m::asm;
/// How to enter STOPx mode (STOP0STOP3)
/// Enter STOPx mode parameter
#[derive(Debug, Clone, Copy, PartialEq, Eq, defmt::Format)]
pub enum StopEntry {
Wfi,