embedded-time icon indicating copy to clipboard operation
embedded-time copied to clipboard

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

Open Piroro-hs opened this issue 5 years ago • 2 comments

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.

Piroro-hs avatar Nov 25 '20 14:11 Piroro-hs

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.

PTaylor-us avatar Nov 30 '20 03:11 PTaylor-us

Yes, DelayMs and DelayUs.

I thought that Timer is for constant duration...

Piroro-hs avatar Dec 01 '20 03:12 Piroro-hs