-
Notifications
You must be signed in to change notification settings - Fork 221
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
Improve the SYSTIMER API #1739
Improve the SYSTIMER API #1739
Conversation
I updated the CHANGELOG in |
Code looks really good to me - just some questions/notes From the orignal issue:
But now we have Previously The i.e. something like this was previously possible: #[entry]
fn main() -> ! {
let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM);
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
let mut syst = peripherals.SYSTIMER;
let mut systimer = SystemTimer::new(&mut syst);
println!("SYSTIMER Current value = {}", SystemTimer::now());
let mut alarm0 = &mut systimer.alarm0;
let delay = Delay::new(&clocks);
for _ in 0..10 {
if alarm0.is_running() {
alarm0.stop();
}
alarm0.clear_interrupt();
alarm0.reset();
alarm0.enable_auto_reload(false);
alarm0.load_value(500u64.millis()).unwrap();
alarm0.start();
while !alarm0.is_interrupt_set() {
// Wait
}
alarm0.stop();
alarm0.clear_interrupt();
println!("hello");
}
core::mem::drop(systimer);
let mut systimer = SystemTimer::new(&mut syst);
println!("SYSTIMER Current value = {}", SystemTimer::now());
loop {}
} |
Yes, it's a bit subtle. The call to I added |
Ah ok - maybe a bit more documentation might be useful then 👍 |
Thinking about it now yeah it needs some documentation to make it more obvious. I'll update the snippet in the doc and the main example. |
I've updated the docs and the example. Side note, we should strongly consider making a separate object for enabling/clearing interrupts. It's rather inconvenient to have to place the entire driver in a global static, it'd be nice to just have a tiny interrupt flag object to make global instead, then the main driver can live on the stack. |
I'll reopen this once I work up the courage to resolve the conflicts. |
Thank you for your contribution!
We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:
Submission Checklist 📝
cargo xtask fmt-packages
command to ensure that all changed code is formatted correctly.CHANGELOG.md
in the proper section.Extra:
Pull Request Details 📖
Description
Fixes #1477 and also expose the second unit.
esp-hal-embassy
kinda gets in the way since it insists on owning all the comparators/alarms.I didn't sign up to touch
esp-hal-embassy
in this PR so I'm going to mostly leave it as is.Testing
Ran the systimer example and it works as expected.