aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxoviat <[email protected]>2023-08-28 15:30:29 -0500
committerxoviat <[email protected]>2023-08-28 15:30:29 -0500
commitb315c28d4eda4fe62747d7f626226862cbc92629 (patch)
tree676c70c7b12c85ca2bcbd9e2b4e05a2af0bd4f3e
parent2c80784fe6e1a165cabae83baf7c842218a35046 (diff)
stm32/rtc: remove rtc-debug and asbtract exti wakeup
-rw-r--r--embassy-stm32/Cargo.toml3
-rw-r--r--embassy-stm32/src/low_power.rs10
-rw-r--r--embassy-stm32/src/rtc/v2.rs26
-rw-r--r--embassy-stm32/src/time_driver.rs2
4 files changed, 10 insertions, 31 deletions
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml
index ca4219102..d0ada97a3 100644
--- a/embassy-stm32/Cargo.toml
+++ b/embassy-stm32/Cargo.toml
@@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
8src_base = "https://github.com/embassy-rs/embassy/blob/embassy-stm32-v$VERSION/embassy-stm32/src/" 8src_base = "https://github.com/embassy-rs/embassy/blob/embassy-stm32-v$VERSION/embassy-stm32/src/"
9src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-stm32/src/" 9src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-stm32/src/"
10 10
11features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "time", "low-power", "rtc-debug"] 11features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "time", "low-power"]
12flavors = [ 12flavors = [
13 { regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" }, 13 { regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" },
14 { regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" }, 14 { regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" },
@@ -90,7 +90,6 @@ defmt = ["dep:defmt", "bxcan/unstable-defmt", "embassy-sync/defmt", "embassy-emb
90 90
91exti = [] 91exti = []
92low-power = [ "dep:embassy-executor", "embassy-executor/arch-cortex-m" ] 92low-power = [ "dep:embassy-executor", "embassy-executor/arch-cortex-m" ]
93rtc-debug = []
94embassy-executor = [] 93embassy-executor = []
95 94
96## Automatically generate `memory.x` file using [`stm32-metapac`](https://docs.rs/stm32-metapac/) 95## Automatically generate `memory.x` file using [`stm32-metapac`](https://docs.rs/stm32-metapac/)
diff --git a/embassy-stm32/src/low_power.rs b/embassy-stm32/src/low_power.rs
index f9b5fde91..d0230ed72 100644
--- a/embassy-stm32/src/low_power.rs
+++ b/embassy-stm32/src/low_power.rs
@@ -89,9 +89,6 @@ impl Executor {
89 89
90 self.time_driver.resume_time(); 90 self.time_driver.resume_time();
91 trace!("low power: resume time"); 91 trace!("low power: resume time");
92
93 #[cfg(feature = "rtc-debug")]
94 cortex_m::asm::bkpt();
95 } 92 }
96 93
97 pub(self) fn stop_with_rtc(&mut self, rtc: &'static Rtc) { 94 pub(self) fn stop_with_rtc(&mut self, rtc: &'static Rtc) {
@@ -102,8 +99,7 @@ impl Executor {
102 crate::interrupt::typelevel::RTC_WKUP::unpend(); 99 crate::interrupt::typelevel::RTC_WKUP::unpend();
103 unsafe { crate::interrupt::typelevel::RTC_WKUP::enable() }; 100 unsafe { crate::interrupt::typelevel::RTC_WKUP::enable() };
104 101
105 EXTI.rtsr(0).modify(|w| w.set_line(22, true)); 102 rtc.enable_wakeup_line();
106 EXTI.imr(0).modify(|w| w.set_line(22, true));
107 } 103 }
108 104
109 fn configure_pwr(&mut self) { 105 fn configure_pwr(&mut self) {
@@ -121,7 +117,6 @@ impl Executor {
121 } 117 }
122 118
123 trace!("low power: enter stop..."); 119 trace!("low power: enter stop...");
124 #[cfg(not(feature = "rtc-debug"))]
125 self.scb.set_sleepdeep(); 120 self.scb.set_sleepdeep();
126 } 121 }
127 122
@@ -144,9 +139,6 @@ impl Executor {
144 /// 139 ///
145 /// This function never returns. 140 /// This function never returns.
146 pub fn run(&'static mut self, init: impl FnOnce(Spawner)) -> ! { 141 pub fn run(&'static mut self, init: impl FnOnce(Spawner)) -> ! {
147 #[cfg(feature = "rtc-debug")]
148 trace!("low power: rtc debug enabled");
149
150 init(unsafe { EXECUTOR.as_mut().unwrap() }.inner.spawner()); 142 init(unsafe { EXECUTOR.as_mut().unwrap() }.inner.spawner());
151 143
152 loop { 144 loop {
diff --git a/embassy-stm32/src/rtc/v2.rs b/embassy-stm32/src/rtc/v2.rs
index 7eb8a96c4..49f66e957 100644
--- a/embassy-stm32/src/rtc/v2.rs
+++ b/embassy-stm32/src/rtc/v2.rs
@@ -75,21 +75,6 @@ impl super::Rtc {
75 /// start the wakeup alarm and wtih a duration that is as close to but less than 75 /// start the wakeup alarm and wtih a duration that is as close to but less than
76 /// the requested duration, and record the instant the wakeup alarm was started 76 /// the requested duration, and record the instant the wakeup alarm was started
77 pub(crate) fn start_wakeup_alarm(&self, requested_duration: embassy_time::Duration) { 77 pub(crate) fn start_wakeup_alarm(&self, requested_duration: embassy_time::Duration) {
78 #[cfg(feature = "rtc-debug")]
79 if critical_section::with(|cs| {
80 if let Some(instant) = self.stop_time.borrow(cs).take() {
81 self.stop_time.borrow(cs).replace(Some(instant));
82
83 Some(())
84 } else {
85 None
86 }
87 })
88 .is_some()
89 {
90 return;
91 }
92
93 use embassy_time::{Duration, TICK_HZ}; 78 use embassy_time::{Duration, TICK_HZ};
94 79
95 use crate::rcc::get_freqs; 80 use crate::rcc::get_freqs;
@@ -134,6 +119,14 @@ impl super::Rtc {
134 } 119 }
135 120
136 #[cfg(feature = "low-power")] 121 #[cfg(feature = "low-power")]
122 pub(crate) fn enable_wakeup_line(&self) {
123 use crate::pac::EXTI;
124
125 EXTI.rtsr(0).modify(|w| w.set_line(22, true));
126 EXTI.imr(0).modify(|w| w.set_line(22, true));
127 }
128
129 #[cfg(feature = "low-power")]
137 /// stop the wakeup alarm and return the time elapsed since `start_wakeup_alarm` 130 /// stop the wakeup alarm and return the time elapsed since `start_wakeup_alarm`
138 /// was called, otherwise none 131 /// was called, otherwise none
139 pub(crate) fn stop_wakeup_alarm(&self) -> Option<embassy_time::Duration> { 132 pub(crate) fn stop_wakeup_alarm(&self) -> Option<embassy_time::Duration> {
@@ -141,9 +134,6 @@ impl super::Rtc {
141 134
142 trace!("rtc: stop wakeup alarm at {}", self.instant()); 135 trace!("rtc: stop wakeup alarm at {}", self.instant());
143 136
144 #[cfg(feature = "rtc-debug")]
145 return None;
146
147 self.write(false, |regs| { 137 self.write(false, |regs| {
148 regs.cr().modify(|w| w.set_wutie(false)); 138 regs.cr().modify(|w| w.set_wutie(false));
149 regs.cr().modify(|w| w.set_wute(false)); 139 regs.cr().modify(|w| w.set_wute(false));
diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs
index d4442c231..99d423d08 100644
--- a/embassy-stm32/src/time_driver.rs
+++ b/embassy-stm32/src/time_driver.rs
@@ -363,7 +363,6 @@ impl RtcDriver {
363 .start_wakeup_alarm(time_until_next_alarm); 363 .start_wakeup_alarm(time_until_next_alarm);
364 }); 364 });
365 365
366 #[cfg(not(feature = "rtc-debug"))]
367 T::regs_gp16().cr1().modify(|w| w.set_cen(false)); 366 T::regs_gp16().cr1().modify(|w| w.set_cen(false));
368 367
369 Ok(()) 368 Ok(())
@@ -375,7 +374,6 @@ impl RtcDriver {
375 pub(crate) fn resume_time(&self) { 374 pub(crate) fn resume_time(&self) {
376 self.stop_wakeup_alarm(); 375 self.stop_wakeup_alarm();
377 376
378 #[cfg(not(feature = "rtc-debug"))]
379 T::regs_gp16().cr1().modify(|w| w.set_cen(true)); 377 T::regs_gp16().cr1().modify(|w| w.set_cen(true));
380 } 378 }
381} 379}