aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliebman <[email protected]>2025-10-22 07:16:43 -0700
committerliebman <[email protected]>2025-11-03 12:49:49 -0800
commit36aa3e10aaf27bb1bd1109a203b378dc93b90b02 (patch)
tree9148a85c8e26ff46c5e8dd937b40f1b7ec501fa5
parente4eac457b3b86fd89c215c386216f7cf0873ba38 (diff)
low_power: i2c wakeup
-rw-r--r--embassy-stm32/src/i2c/v2.rs5
-rw-r--r--embassy-stm32/src/low_power.rs9
2 files changed, 11 insertions, 3 deletions
diff --git a/embassy-stm32/src/i2c/v2.rs b/embassy-stm32/src/i2c/v2.rs
index 01b6b8800..a2184630f 100644
--- a/embassy-stm32/src/i2c/v2.rs
+++ b/embassy-stm32/src/i2c/v2.rs
@@ -70,6 +70,11 @@ fn debug_print_interrupts(isr: stm32_metapac::i2c::regs::Isr) {
70} 70}
71 71
72pub(crate) unsafe fn on_interrupt<T: Instance>() { 72pub(crate) unsafe fn on_interrupt<T: Instance>() {
73 // restore the clocks to their last configured state as
74 // much is lost in STOP modes
75 #[cfg(all(feature = "low-power", stm32wlex))]
76 crate::low_power::on_wakeup_irq();
77
73 let regs = T::info().regs; 78 let regs = T::info().regs;
74 let isr = regs.isr().read(); 79 let isr = regs.isr().read();
75 80
diff --git a/embassy-stm32/src/low_power.rs b/embassy-stm32/src/low_power.rs
index 4ebded8a5..4cdaf6a00 100644
--- a/embassy-stm32/src/low_power.rs
+++ b/embassy-stm32/src/low_power.rs
@@ -180,16 +180,19 @@ impl Executor {
180 } 180 }
181 181
182 unsafe fn on_wakeup_irq(&mut self) { 182 unsafe fn on_wakeup_irq(&mut self) {
183 // when we wake from STOP2, we need to re-initialize the rcc and the time driver
184 // to restore the clocks to their last configured state
185 #[cfg(stm32wlex)]
186 crate::rcc::apply_resume_config();
183 #[cfg(stm32wlex)] 187 #[cfg(stm32wlex)]
184 if crate::pac::PWR.extscr().read().c1stop2f() { 188 if crate::pac::PWR.extscr().read().c1stop2f() {
185 // when we wake from STOP2, we need to re-initialize the rcc and the time driver
186 // to restore the clocks to their last configured state
187 crate::rcc::apply_resume_config();
188 critical_section::with(|cs| crate::time_driver::init_timer(cs)); 189 critical_section::with(|cs| crate::time_driver::init_timer(cs));
189 // reset the refcounts for STOP2 and STOP1 (initializing the time driver will increment one of them for the timer) 190 // reset the refcounts for STOP2 and STOP1 (initializing the time driver will increment one of them for the timer)
191 // and given that we just woke from STOP2, we can reset them
190 crate::rcc::REFCOUNT_STOP2 = 0; 192 crate::rcc::REFCOUNT_STOP2 = 0;
191 crate::rcc::REFCOUNT_STOP1 = 0; 193 crate::rcc::REFCOUNT_STOP1 = 0;
192 } 194 }
195
193 self.time_driver.resume_time(); 196 self.time_driver.resume_time();
194 trace!("low power: resume"); 197 trace!("low power: resume");
195 } 198 }