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

System time based on static systick isr counter #149

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

h2obrain
Copy link
Contributor

@h2obrain h2obrain commented May 1, 2020

I added this to the hal while playing with it. Maybe it fits the upstream :)

src/systick.rs Outdated
Comment on lines 100 to 114
// there can only be one!
#[exception]
fn SysTick() {
free(|_|unsafe {
if let Some(systime) = &mut SYSTIME {
systime.systick += 1;
}
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is going to be an issue. We really shouldn't make any assumptions about the runtime here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is it possible to wrap an interrupt without making assumptions about the ruintime?
I mean something better than adding a global fn SystickISR() {..}, which has to be called from the implementation isr.

@h2obrain h2obrain marked this pull request as draft May 10, 2020 16:59
@h2obrain h2obrain force-pushed the systick branch 2 times, most recently from 9ca6671 to f34a2aa Compare May 12, 2020 01:27
@h2obrain
Copy link
Contributor Author

Maybe this could just be an example without changes to the hal?

@therealprof
Copy link
Member

Maybe this could just be an example without changes to the hal?

That is definitely possible. I was actually thinking about implementing a general "tick" counter crate a while back; something that you would initialise and then feed with monotonic counter updates which could be used for all kinds of purposes, e.g. a delay implementation.

@h2obrain h2obrain force-pushed the systick branch 2 times, most recently from 9ad31f9 to c4b7312 Compare October 10, 2020 15:01
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.

None yet

2 participants