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

@@ -7,19 +7,19 @@ use embassy_stm32::peripherals;
use embassy_time::{Duration, Timer};
use embassy_hal_internal::Peri;
/// GPIO pin as an EXTI wakeup source.
/// GPIO pin as an EXTI wake-up source.
#[embassy_executor::task]
pub async fn gpio_wakeup(
pin: Peri<'static, peripherals::PA0>,
ch: Peri<'static, peripherals::EXTI0>
) {
info!("Configuring EXTI wake input on PA0 (rising edge)");
info!("EXTI wake input on PA0");
let mut btn = ExtiInput::new(pin, ch, Pull::Up);
loop {
info!("Waiting for rising edge on PA0");
info!("Waiting for falling edge on PA0");
btn.wait_for_falling_edge().await;
info!("GPIO wakeup: event detected!");
info!("GPIO wake-up");
Timer::after(Duration::from_millis(50)).await;
}
}

View File

@@ -10,10 +10,8 @@ use crate::sleep::standby;
use crate::config::WATCHDOG_TIMEOUT_US;
/// Clears system reset and standby flags after wakeup.
/// Call early in startup
///
/// # Registers
/// - `RCC_CSR` — Reset and Clock Control / Status
/// - `PWR_SR` — Power Control / Status
pub fn clear_wakeup_flags() {
@@ -34,10 +32,10 @@ pub fn clear_wakeup_flags() {
}
}
/// Initializes the Independent Watchdog (IWDG) timer.
/// Init Independent Watchdog (IWDG) timer.
/// Timeout value is configured in `WATCHDOG_TIMEOUT_US` from config.rs
pub async fn init_watchdog_reset(iwdg: Peri<'static, peripherals::IWDG>) {
info!("Initializing watchdog after watchdog wake...");
info!("Init watchdog after watchdog wake...");
let mut watchdog = IndependentWatchdog::new(iwdg, WATCHDOG_TIMEOUT_US);
watchdog.unleash();
Timer::after(Duration::from_millis(10)).await;