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

Use embedded-time instead of custom implementation #191

Closed
wbuck opened this issue Jan 10, 2021 · 2 comments
Closed

Use embedded-time instead of custom implementation #191

wbuck opened this issue Jan 10, 2021 · 2 comments

Comments

@wbuck
Copy link
Contributor

wbuck commented Jan 10, 2021

When writing a driver for some device (say a motor driver) and attempt to program against the trait's in the embedded-hal you can run into issues when using a peripheral that requires types defined in time.rs.

Because of this the driver now has a dependency on the stm32f3xx-hal device crate.
This of course is unwanted as it would be nice to create a generic device driver that doesn't depend on any specific device crate.

Example:

pub struct Driver<T>
where 
    T: CountDown
{ 
    timer: T,
}

impl<T> Driver<T> 
where 
    T: CountDown
{
    pub fn new( timer: T ) -> Self { Driver { timer }  }

    pub fn start( &self ) { 
         self.timer.start( /* This requires Hertz which is defined in time.rs of the stm32f3xx-hal crate */ );
    }
}

Instead of using the units/functionality defined in time.rs could the units/functionality defined in embedded-time be used instead? This would allow for a truly generic driver (assuming other device crates got on board).

This is probably more of community issue as a lot of device crates use their own custom time.rs implementation.

Below are two issues regarding this for the embedded-hal crate.
It sounded like the consensus was to have device crates get on board with using some centralized source for using time based units and functionality.

embedded-hal #221
embedded-hal #59

@wbuck
Copy link
Contributor Author

wbuck commented Jan 10, 2021

Just noticed that there was already a request for this: #185

@Sh3Rm4n
Copy link
Member

Sh3Rm4n commented Mar 12, 2021

Closed by #192

@Sh3Rm4n Sh3Rm4n closed this as completed Mar 12, 2021
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