From 885c7746b3fff3f10acef55505ce3b17d1b0235f Mon Sep 17 00:00:00 2001 From: sigil-03 Date: Fri, 12 Sep 2025 16:19:26 -0600 Subject: [PATCH] deep sleep with PDDS is working --- ch32v-insert-coin/src/main.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ch32v-insert-coin/src/main.rs b/ch32v-insert-coin/src/main.rs index 6d22219..2db5988 100644 --- a/ch32v-insert-coin/src/main.rs +++ b/ch32v-insert-coin/src/main.rs @@ -109,6 +109,15 @@ unsafe fn enter_standby(pin: usize) { w.set_sleeponexit(false); }); + // set PDDS=1: + // get current value of PWR_CTLR + let mut reg: u32 = 0x4000_7000; + let mut val: u32 = 0; + unsafe { val = (reg as *mut u32).read_volatile(); } + // modify PDDS + val |= 1 << 1; // PWR_CTLR[1] -> PDDS + unsafe { (reg as *mut u32).write_volatile(val); } + // // disable all exti interrupts let exti = &hal::pac::EXTI; // exti.intenr().write(| w| { @@ -144,8 +153,8 @@ unsafe fn enter_standby(pin: usize) { } unsafe fn init_gpio_irq(pin: u8, port: u8, rising: bool, falling: bool) { - critical_section::with(|_| { - #[cfg(features="enable_print")] + critical_section::with(|_| { + #[cfg(feature="enable_print")] println!("init_gpio_irq"); let exti = &hal::pac::EXTI; let afio = &hal::pac::AFIO;