Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add alarms for RTC #1985

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chrenderle
Copy link
Contributor

Didn't compile it yet.
Didn't test it on any target yet.
Only written for STM32L0 and probably breaks other targets.

TODO:

  • make it compile ready
  • test on STM32L0
  • test compilation on other targets
  • write drivers which allow setting the RTC alarm

Didn't compile fully yet.
Didn't test on any target yet.
Only written for STM32L0 and probably breaks other targets.
@xoviat
Copy link
Contributor

xoviat commented Oct 1, 2023

For the STM32L0 the interrupt routine is the same as the wkup timer so there has to be some overlap.

If that is the case, the low-power wakeup irq handler needs to be converted to bind_interrupts and moved to the rtc mod, and needs to call the on_wakeup_irq function when the alarm wakes the chip.

The code in low power and time driver is only there since for the low-power feature the low-power executor has ownership of the rtc.

The low-power feature is only intended to have ownership over part of the rtc: it's wakeup functionality and timekeeping. The alarm functionality can be split off like this:

let rtc = Rtc::new(...)
let alarm1 = rtc.alarm1.take().unwrap();

let rtc=make_static!(rtc);
stop_with_rtc(rtc);

alarm1.wait_for_alarm(day, hour, minute, second).await;

In fact, low-power should be able to work without embassy-time at all (in that case, it would not even set the wakeup alarm) and alarms should be available to work without the low-power feature (in that case, the core wouldn't stop, but sleep until the alarm).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants