working uart trigger of standby

This commit is contained in:
Priec
2025-12-03 22:23:41 +01:00
parent c7a74df023
commit 7184ce9898
2 changed files with 11 additions and 7 deletions

View File

@@ -19,7 +19,7 @@ use dma_gpio::config::{
BAUD, PIPE_HW_RX, PIPE_HW_TX, BAUD, PIPE_HW_RX, PIPE_HW_TX,
}; };
use dma_gpio::hw_uart_pc::driver::uart_task; use dma_gpio::hw_uart_pc::driver::uart_task;
use dma_gpio::wakeup::iwdg::{clear_wakeup_flags, init_watchdog}; use dma_gpio::wakeup::iwdg::{clear_wakeup_flags, init_watchdog_reset};
use dma_gpio::sleep::shutdown; use dma_gpio::sleep::shutdown;
use dma_gpio::sleep::standby; use dma_gpio::sleep::standby;
use {defmt_rtt as _, panic_probe as _}; use {defmt_rtt as _, panic_probe as _};
@@ -112,11 +112,15 @@ async fn main(spawner: Spawner) {
[4] Shutdown — lowest power, full reset on wake", [4] Shutdown — lowest power, full reset on wake",
BAUD, WATCHDOG_TIMEOUT_US / 1_000_000 BAUD, WATCHDOG_TIMEOUT_US / 1_000_000
); );
// disabling st-link debug
dbg.cr().modify(|w| {
w.set_dbg_standby(false);
w.set_dbg_stop(false);
});
// END OF DEBUG INFO // END OF DEBUG INFO
// MAIN LOOP // MAIN LOOP
Timer::after(Duration::from_millis(500)).await;
Timer::after(Duration::from_millis(10)).await; Timer::after(Duration::from_millis(10)).await;
info!("ready for uart"); info!("ready for uart");
@@ -124,17 +128,17 @@ async fn main(spawner: Spawner) {
let cmd = CMD_CH.receive().await; let cmd = CMD_CH.receive().await;
match cmd { match cmd {
LowPowerCmd::Standby8k => { LowPowerCmd::Standby8k => {
init_watchdog(p.IWDG).await; // watchdog reset at configurated time init_watchdog_reset(p.IWDG).await; // watchdog reset at configurated time
Timer::after(Duration::from_millis(10)).await; // let UART flush Timer::after(Duration::from_millis(10)).await; // let UART flush
standby::enter_standby_with_sram2_8kb(); standby::enter_standby_with_sram2_8kb();
} }
LowPowerCmd::StandbyFull => { LowPowerCmd::StandbyFull => {
init_watchdog(p.IWDG).await; init_watchdog_reset(p.IWDG).await;
Timer::after(Duration::from_millis(10)).await; Timer::after(Duration::from_millis(10)).await;
standby::enter_standby_with_sram2_full(); standby::enter_standby_with_sram2_full();
} }
LowPowerCmd::Standby => { LowPowerCmd::Standby => {
init_watchdog(p.IWDG).await; init_watchdog_reset(p.IWDG).await;
Timer::after(Duration::from_millis(10)).await; Timer::after(Duration::from_millis(10)).await;
standby::enter_standby(); standby::enter_standby();
} }

View File

@@ -42,7 +42,7 @@ pub fn clear_wakeup_flags() {
/// ///
/// # Timing /// # Timing
/// - Timeout value is configured in `WATCHDOG_TIMEOUT_US` from config.rs /// - Timeout value is configured in `WATCHDOG_TIMEOUT_US` from config.rs
pub async fn init_watchdog(iwdg: Peri<'_, peripherals::IWDG>) { pub async fn init_watchdog_reset(iwdg: Peri<'_, peripherals::IWDG>) {
info!("Initializing watchdog after watchdog wake..."); info!("Initializing watchdog after watchdog wake...");
let mut watchdog = IndependentWatchdog::new(iwdg, WATCHDOG_TIMEOUT_US); let mut watchdog = IndependentWatchdog::new(iwdg, WATCHDOG_TIMEOUT_US);
watchdog.unleash(); watchdog.unleash();