shutdown added

This commit is contained in:
Priec
2025-12-03 17:57:10 +01:00
parent 33543099c2
commit 434e2b3d21
4 changed files with 32 additions and 11 deletions

View File

@@ -9,6 +9,15 @@ use embassy_stm32::pac;
use crate::config::WATCHDOG_TIMEOUT_US;
/// Clears system reset and standby flags after wakeup.
///
/// Call early in startup to:
/// - Clear reset flags by setting `RMVF` in `RCC_CSR`.
/// - If `SBF` in `PWR_SR` is set (woke from Standby), clear it.
///
/// # Registers
/// - `RCC_CSR` — Reset and Clock Control / Status
/// - `PWR_SR` — Power Control / Status
pub fn clear_wakeup_flags() {
info!("Clearing wakeup flags...");
@@ -26,6 +35,11 @@ pub fn clear_wakeup_flags() {
}
}
/// Initializes the Independent Watchdog (IWDG) timer.
/// Wakeup source: Can wake the system from Standby mode on timeout
///
/// # Timing
/// - Timeout value is configured in `WATCHDOG_TIMEOUT_US` from config.rs
pub async fn init_watchdog(iwdg: Peri<'_, peripherals::IWDG>) {
info!("Initializing watchdog after watchdog wake...");
let mut watchdog = IndependentWatchdog::new(iwdg, WATCHDOG_TIMEOUT_US);