embassy-time-driver using RTC interrupts - #825
Conversation
d853b9d to
85a1edf
Compare
b046fc1 to
651dd87
Compare
| 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.
@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
9182bd0 to
f2af62e
Compare
1a81ae9 to
3d7a961
Compare
jbeaurivage
left a comment
There was a problem hiding this comment.
Thanks for the PR @stillinbeta! I intend to review this shortly. In the meantime, could you revert these two changes? Thanks!
| 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.
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).
update interrupt handling code close up modes Remove unneeded examples don't need semihosting remove rtt-target roll back config.toml
…/modes.rs` from the merged PR atsamd-rs#845.
3d7a961 to
e16b12f
Compare
401f994 to
bada3d2
Compare
|
@kyp44 thanks for doing the hard work of rebasing this back onto master! I've gone ahead and removed all the pyportal changes (they're in #1008 now). I'm going to see what I can do about the race condition @ritikmishra found. |
53c914b to
df1233f
Compare
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-timefeature.I have only tested these changes on the
pyportalboard (see examples provided).Checklist
#[allow]certain lints where reasonable, but ideally justify those with a short comment.If Adding a new Board
crates.jsonIf Adding a new cargo
featureto the HALcrates.jsonNote
The crate changelogs should no longer be manually updated! Changelogs are now automatically generated. Instead: