-
Notifications
You must be signed in to change notification settings - Fork 151
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
GetTick and DelayUntilMs/DelayUntilUs utilities for Delay? #446
Comments
Before I get into the rest of this comment, let me just start by saying this is a very sensible and useful thing to want, and it would be nice to have, but it's a bit tricky... This crate actually just provides an implementation of the embedded-hal In the Cortex-M implementation in this crate, you couldn't actually implement your proposed methods - it basically loads the required number of ticks into the SysTick timer, starts it running, then waits for it to run down to 0. There's no ongoing counter in the background, so there's no current "ticks" value. Another hard part with this is that whatever value you return for Other embedded projects like embassy can provide exactly what you're looking for by virtue of making more decisions about the platform; see the embassy time docs for example. |
Thank you so much for the response, it was very clarifying. I guess that you noticed that I'm quite new in this world of open source and embedded systems. It seems that embedded-time is quite an appealing alternative for this, and people in the wg of embedded-hal are discussing whether to adopt it or not. I guess that embedded-time will eventually be absorbed by embedded-hal (or at least the latter will implement something similar to the prior). Am I right? or did I misunderstood your message? Thanks in advance. |
Yep, that's about right! A more recent crate, fugit has also been very popular recently as an alternative design to embedded-time, which a number of HALs have started to adopt I believe. |
Great, thanks for your time! I'll close the issue. |
Hi! I think it would be nice to add a
DelayUntil
utility to delays. In this way, we can have actual periodic tasks, regardless of the time consumed by a task when executing. To do so, we would need to add the following methods to delays:get_tick(&self) -> u32
(I'm not sure which the return value should be): it returns the current internal clock tick value.delay_until_ms(&mut self, tick_from: u32, ms: u16)
: it waits the given amount of milliseconds FROM THE BASELINE.delay_until_us(&mut self, tick_from: u32, us: u32)
: it waits the given amount of microseconds FROM THE BASELINE.With that, we could do something like this:
Thus, we would not delay for one second, but 1 second SINCE WE CAPTURED THE BASELINE.
What do you think? Is there anything I'm missing that makes this a bad idea?
The text was updated successfully, but these errors were encountered: