-
Notifications
You must be signed in to change notification settings - Fork 217
embassy-time-driver using RTC interrupts #825
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
base: master
Are you sure you want to change the base?
Conversation
d853b9d
to
85a1edf
Compare
b046fc1
to
651dd87
Compare
hal/src/rtc/embassy/mod.rs
Outdated
if RtcMode0::check_interrupt_flag::<Compare0>(&rtc) { | ||
// Due to synchronization delay, the RTC may be slightly behind | ||
// Assume the current time is the time the interrupt is set for | ||
let now = RtcMode0::get_compare(&rtc, 0) as u64; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sjroe solved this by setting the prescaler to four, thus ensuring the resolution was coarse enough to not cause issues. I like my solution better, but am open to suggestions
6247d9a
to
9182bd0
Compare
update interrupt handling code close up modes Remove unneeded examples don't need semihosting remove rtt-target roll back config.toml
9182bd0
to
f2af62e
Compare
@@ -0,0 +1,163 @@ | |||
//! Turn on and off with an LED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could potentially be moved to another PR. I wrote this while debugging my interrupt code, and thought it might be a useful example for others in the future.
8126267
to
2ccaefe
Compare
2ccaefe
to
a78cb55
Compare
1a81ae9
to
3d7a961
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @stillinbeta! I intend to review this shortly. In the meantime, could you revert these two changes? Thanks!
runner = "hf2 elf" | ||
# runner = 'probe-rs run --chip ATSAMD51J20A' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please revert this?
# version = "0.21.0" | ||
path = "../../hal" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, we'd like to keep pyportal a Tier 2 boarrd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure exactly how to manage this, then. Should I have the PR to add embassy-time
support be a stand-alone PR, then send another PR once there's a HAL release with the examples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that would be the way to go! The second PR could already be opened, it's just a matter of timing of when we can merge it.
let at = match u32::try_from(at) { | ||
Ok(at) => at, | ||
_ if at == u64::MAX => u32::MAX, | ||
Err(_) => return false, | ||
}; | ||
|
||
RtcMode0::set_compare(rtc, 0, at); | ||
true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am experiencing race condition in this implementation where it is possible for the RTC counter to advance past at
while COMP0 is being set
the [embassy timer queue implementation for stm32 microcontrollers] tries to prevent this from happening by avoiding setting alarms for timestamps in the very near future:
…some minor changes made for the embassy time driver (see PR atsamd-rs#825).
…some minor changes made for the embassy time driver (see PR atsamd-rs#825).
As I'm interested in this getting merged, I had a good look at at and tested it. Here are some comments/questions:
Note: This PR makes a few changes to the RTC modes abstraction. I also made some changes and additions with my RTC fixes in PR #845. In that PR I've already merged the changes from this one, so that version should take precedence in the event of any conflicts. Edit: For my own purposes, I'm maintaining this branch in my fork that I am keeping up to date with |
…some minor changes made for the embassy time driver (see PR atsamd-rs#825).
…some minor changes made for the embassy time driver (see PR atsamd-rs#825).
Summary
These changes implement the embassy-time-driver interface, used by Embassy for scheduling and a prerequisite for the Embassy runtime.
These changes are confined to the
embassy-time
feature.I have only tested these changes on the
pyportal
board (see examples provided).Checklist
#[allow]
certain lints where reasonable, but ideally justify those with a short comment.If Adding a new Board
crates.json
If Adding a new cargo
feature
to the HALcrates.json
Note
The crate changelogs should no longer be manually updated! Changelogs are now automatically generated. Instead: