stm32/rtc: remove rtc-debug and asbtract exti wakeup

This commit is contained in:
xoviat 2023-08-28 15:30:29 -05:00
parent 2c80784fe6
commit b315c28d4e
4 changed files with 10 additions and 31 deletions

View File

@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-stm32-v$VERSION/embassy-stm32/src/" src_base = "https://github.com/embassy-rs/embassy/blob/embassy-stm32-v$VERSION/embassy-stm32/src/"
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-stm32/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-stm32/src/"
features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "time", "low-power", "rtc-debug"] features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "time", "low-power"]
flavors = [ flavors = [
{ regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" }, { regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" },
{ regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" }, { regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" },
@ -90,7 +90,6 @@ defmt = ["dep:defmt", "bxcan/unstable-defmt", "embassy-sync/defmt", "embassy-emb
exti = [] exti = []
low-power = [ "dep:embassy-executor", "embassy-executor/arch-cortex-m" ] low-power = [ "dep:embassy-executor", "embassy-executor/arch-cortex-m" ]
rtc-debug = []
embassy-executor = [] embassy-executor = []
## Automatically generate `memory.x` file using [`stm32-metapac`](https://docs.rs/stm32-metapac/) ## Automatically generate `memory.x` file using [`stm32-metapac`](https://docs.rs/stm32-metapac/)

View File

@ -89,9 +89,6 @@ impl Executor {
self.time_driver.resume_time(); self.time_driver.resume_time();
trace!("low power: resume time"); trace!("low power: resume time");
#[cfg(feature = "rtc-debug")]
cortex_m::asm::bkpt();
} }
pub(self) fn stop_with_rtc(&mut self, rtc: &'static Rtc) { pub(self) fn stop_with_rtc(&mut self, rtc: &'static Rtc) {
@ -102,8 +99,7 @@ impl Executor {
crate::interrupt::typelevel::RTC_WKUP::unpend(); crate::interrupt::typelevel::RTC_WKUP::unpend();
unsafe { crate::interrupt::typelevel::RTC_WKUP::enable() }; unsafe { crate::interrupt::typelevel::RTC_WKUP::enable() };
EXTI.rtsr(0).modify(|w| w.set_line(22, true)); rtc.enable_wakeup_line();
EXTI.imr(0).modify(|w| w.set_line(22, true));
} }
fn configure_pwr(&mut self) { fn configure_pwr(&mut self) {
@ -121,7 +117,6 @@ impl Executor {
} }
trace!("low power: enter stop..."); trace!("low power: enter stop...");
#[cfg(not(feature = "rtc-debug"))]
self.scb.set_sleepdeep(); self.scb.set_sleepdeep();
} }
@ -144,9 +139,6 @@ impl Executor {
/// ///
/// This function never returns. /// This function never returns.
pub fn run(&'static mut self, init: impl FnOnce(Spawner)) -> ! { pub fn run(&'static mut self, init: impl FnOnce(Spawner)) -> ! {
#[cfg(feature = "rtc-debug")]
trace!("low power: rtc debug enabled");
init(unsafe { EXECUTOR.as_mut().unwrap() }.inner.spawner()); init(unsafe { EXECUTOR.as_mut().unwrap() }.inner.spawner());
loop { loop {

View File

@ -75,21 +75,6 @@ impl super::Rtc {
/// start the wakeup alarm and wtih a duration that is as close to but less than /// start the wakeup alarm and wtih a duration that is as close to but less than
/// the requested duration, and record the instant the wakeup alarm was started /// the requested duration, and record the instant the wakeup alarm was started
pub(crate) fn start_wakeup_alarm(&self, requested_duration: embassy_time::Duration) { pub(crate) fn start_wakeup_alarm(&self, requested_duration: embassy_time::Duration) {
#[cfg(feature = "rtc-debug")]
if critical_section::with(|cs| {
if let Some(instant) = self.stop_time.borrow(cs).take() {
self.stop_time.borrow(cs).replace(Some(instant));
Some(())
} else {
None
}
})
.is_some()
{
return;
}
use embassy_time::{Duration, TICK_HZ}; use embassy_time::{Duration, TICK_HZ};
use crate::rcc::get_freqs; use crate::rcc::get_freqs;
@ -133,6 +118,14 @@ impl super::Rtc {
critical_section::with(|cs| assert!(self.stop_time.borrow(cs).replace(Some(self.instant())).is_none())) critical_section::with(|cs| assert!(self.stop_time.borrow(cs).replace(Some(self.instant())).is_none()))
} }
#[cfg(feature = "low-power")]
pub(crate) fn enable_wakeup_line(&self) {
use crate::pac::EXTI;
EXTI.rtsr(0).modify(|w| w.set_line(22, true));
EXTI.imr(0).modify(|w| w.set_line(22, true));
}
#[cfg(feature = "low-power")] #[cfg(feature = "low-power")]
/// stop the wakeup alarm and return the time elapsed since `start_wakeup_alarm` /// stop the wakeup alarm and return the time elapsed since `start_wakeup_alarm`
/// was called, otherwise none /// was called, otherwise none
@ -141,9 +134,6 @@ impl super::Rtc {
trace!("rtc: stop wakeup alarm at {}", self.instant()); trace!("rtc: stop wakeup alarm at {}", self.instant());
#[cfg(feature = "rtc-debug")]
return None;
self.write(false, |regs| { self.write(false, |regs| {
regs.cr().modify(|w| w.set_wutie(false)); regs.cr().modify(|w| w.set_wutie(false));
regs.cr().modify(|w| w.set_wute(false)); regs.cr().modify(|w| w.set_wute(false));

View File

@ -363,7 +363,6 @@ impl RtcDriver {
.start_wakeup_alarm(time_until_next_alarm); .start_wakeup_alarm(time_until_next_alarm);
}); });
#[cfg(not(feature = "rtc-debug"))]
T::regs_gp16().cr1().modify(|w| w.set_cen(false)); T::regs_gp16().cr1().modify(|w| w.set_cen(false));
Ok(()) Ok(())
@ -375,7 +374,6 @@ impl RtcDriver {
pub(crate) fn resume_time(&self) { pub(crate) fn resume_time(&self) {
self.stop_wakeup_alarm(); self.stop_wakeup_alarm();
#[cfg(not(feature = "rtc-debug"))]
T::regs_gp16().cr1().modify(|w| w.set_cen(true)); T::regs_gp16().cr1().modify(|w| w.set_cen(true));
} }
} }