-
Notifications
You must be signed in to change notification settings - Fork 218
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
SYSTIMER peripheral #76
Conversation
To add some reasoning behind the current API:
|
I like it, too. Really looking forward to have const generics for enums. There is a nightly feature but don't think it's really worth to force nighly and also that feature is very experimental (warning: the feature I'm a bit more concerned about the unwrapping needed on |
Maybe it might be better for SysTimer to own the alarms (outright, not in an option) and let the compiler move the fields out. Much like the Example: pub struct SystemTimer {
inner: SYSTIMER,
pub alrm0: Alarm<Target, 0>,
pub alrm1: Alarm<Target, 1>,
pub alrm2: Alarm<Target, 2>,
}
// in main
let s = SystemTimer::new(p.SYSTIMER);
let alarm0 = s.alarm0; // move out of SystemTimer struct
s.alarm0.enable_interrupt() // compiler error, use of moved value, alarm is now in alarm0 |
Yes, I thought of something like this |
eb13597
to
7374c5b
Compare
Should now be ready for review. I had a branch with esp32c3 delay implemented with an alarm here: https://github.com/esp-rs/esp-hal/tree/feature/delay-alarm, but it introduced a generic parameter on Delay and instead chose just to implement with the new |
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.
Looks great to me
The ESP32-S2 and ESP32-S3 have this peripheral as well. |
Ah, good point! I'll add support for those (hopefully its the same 😅). |
S2 compiles, but it looks like SYSTIMER is missing from the S3 PAC, I filed esp-rs/esp-pacs#20. |
The |
- Remove runtime Option, turn into compile error - Make Systimer::now() not take self
7374c5b
to
986753f
Compare
So the C3 & S3 version is identical and works great (yay!). However, the S2 has some changes, see the CI. I see a few options:
What do we think? |
Thanks for making those changes! I would say "fixing" the SVD would probably be my preferred approach, however if you just don't want to deal with the S2 right now that's fine too. |
So I needed a few cfg's but it's not too bad. Yet one more difference is that the S2 system timer does not run at fixed 16MHZ, but is variable. I've fixed it to 40mhz (can't go any lower) for now. |
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 think this is looking pretty good, thanks for all your work!
Opening in draft form early to bikeshed the API.
Limitations of this implementation:
This is a key part of embassy integration, so I thought I'd upstream this early :).
TODO
Makedelay::Delay
take an alarm instead of the whole SYSTIMER