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<(), !>;
}
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: