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

Add implementation for embedded_hal::blocking::delay::Delay trait #86

Open
Piroro-hs opened this issue Nov 25, 2020 · 2 comments
Open

Comments

@Piroro-hs
Copy link

Piroro-hs commented Nov 25, 2020

How about adding Clock::delay(&self) -> impl Delay function (maybe behind feature gate)?
It could be useful as currently many hal crates only provides SysTick based delay.

I will make a PR if you like.

@PTaylor-us
Copy link
Member

I'm not seeing a Delay trait in embedded-hal. It does have DelayUs and DelayMs. These could possibly be implemented, but I think the proper implementation would be for Timer. I'm thinking something like this:

impl<'a, Clock: crate::Clock, Dur: Duration> embedded_hal::blocking::delay::DelayMs<Clock::T>
    for Timer<'a, OneShot, Armed, Clock, Dur>
{
    fn delay_ms(&mut self, ms: <Clock as crate::Clock>::T) {
        unimplemented!()
    }
}

It's been a while since I've worked on this code, but I think we could wrap a timer in the Clock trait.

@Piroro-hs
Copy link
Author

Yes, DelayMs and DelayUs.

I thought that Timer is for constant duration...

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

No branches or pull requests

2 participants