embed-rs / stm32f7-discovery

Apache License 2.0
30 stars 23 forks source link

Use embedded-hal as HAL #35

Open f-bro opened 7 years ago

f-bro commented 7 years ago

We could use https://github.com/japaric/embedded-hal for our hal implementation.

The problem is that the functions of the traits only get &self and not &mut self. I think it makes more sense to use &mut self, because you "change" the timer when you call pause()... For example:

pub trait Timer {
    /// A time unit that can be converted into a human time unit (e.g. seconds)
    type Time;

    /// Returns the current timeout
    fn get_timeout(&self) -> Self::Time;

    /// Pauses the timer
    fn pause(&self);

    /// Restarts the timer count to zero
    fn restart(&self);

    /// Resumes the timer count
    fn resume(&self);

    /// Sets a new timeout
    fn set_timeout<T>(&self, timeout: T)
    where
        T: Into<Self::Time>;

    /// "Waits" until the timer times out
    fn wait(&self) -> nb::Result<(), !>;
}
f-bro commented 7 years ago

I added a PR to fix the &mut self problem: https://github.com/japaric/embedded-hal/pull/16