-
Notifications
You must be signed in to change notification settings - Fork 203
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
Allow a way to get >1 impl Delay
type
#670
Comments
@tgross35, yes, that seems like a reasonable feature. Feel free to make a PR. I'm not really familiar with the |
The inner workings aren't too complicated, but I am really not sure what the best way forward is that also avoids race conditions. This chunk specifically definitely seems problematic Lines 65 to 67 in 7d85efd
I don't mind doing the work, but I would appreciate some input from the proper maintainers if you know who to ping |
A shallow google search seems to indicate that most (at least all I could find) The only way I can see it work is by wrapping the That being said, I am no expert in Rust, so maybe there is another way. |
A I am curious what Adam comes up with for cortex M, as mentioned here rust-embedded/embedded-hal#435 (comment) edit: scratch my ISR example since I just realized the peripheral would have to be in a mutex anyway |
I think you could do things properly if the current Delay is used and allowed to Clone (with some interior mutability on SYST), but it would need to be |
If it's |
Qutoing from Adam's suggestion in rust-embedded/embedded-hal#435 (comment):
I would assume that changing the current Delay API is not acceptable, so perhaps something like this would work:
That way, there would only ever be one instance of Alternatively, an entirely separate set of types like Does any of this sound reasonable? |
@tgross35, another approach would be using a timer queue. When scheduling timeouts, they are added to a queue, and the timer can then generate an event when the next timeout expires. This enables the timer to be PS. there are ways to use async constructs in a sync program using simple, lightweight executors such as spin_on. |
I wonder if the right answer is to change things that require Currently, |
Sorry, I should've spent 5 minutes looking in to this before commenting... All our uses of Making an interruptible delay, that's also reasonably accurate, I think would require some way to access the state of the hardware counter, so would need to be in the HAL for a TC or TCC implementation. Doing something like a loop around a 1us delay from an arbitrary Seems like a fun little puzzle; I think for me usb-device issues and clocking v2 implementation for the thumbv6 targets are both higher priority at the moment but will have a think on this one. |
Apologies for another reply-to-self... The SYSTICK is provided by the processor core, so we might look around at other Cortex-M HALs to see what's available. It wouldn't be hard to make a struct that crudely impls I reckon it would be possible to make a |
It seems like at this time, it is only possible to get one
Delay
: atsamd_hal::delay::Delay, which consumes the systick. I brought this issue up on the embedded HAL crate, and their suggestion was that there should be a way to get more than one delay via
Clone` or otherwise. rust-embedded/embedded-hal#435I'm not sure what the best way to go about this is, but it should be possible via this HAL. Being able to get more
impl CountDown
objects would be similarly helpful.The text was updated successfully, but these errors were encountered: