From 3342a183847922b7bf0b01b31ee41bdf7d1ac97a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 16 Oct 2020 15:39:19 +0200 Subject: [PATCH 1/7] Add inherent methods to MRT channels This is a step in preparation for implementing the `CountDown` trait from the alpha version of embedded-hal. These have different names (`try_` prefix) and are fallible. Since we will most likely drop support for the old version of embedded-hal at some point, I thought it best to add the infallible versions as inherent methods now, instead of having to make another change later. --- src/mrt.rs | 52 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/src/mrt.rs b/src/mrt.rs index d9d5c5b6a..ea04b952c 100644 --- a/src/mrt.rs +++ b/src/mrt.rs @@ -74,32 +74,13 @@ where Self(RegProxy::new()) } - /// Returns the current timer value - pub fn value(&self) -> u32 { - self.0.timer.read().value().bits() - } -} - -impl CountDown for Channel -where - T: Trait, -{ - /// The timer operates in clock ticks from the system clock, that means it - /// runs at 12_000_000 ticks per second if you haven't changed it. - /// - /// It can also only use values smaller than 0x7FFFFFFF. - type Time = u32; - - /// Start counting down from the given count + /// Start the timer /// /// The `reload` argument must be smaller than or equal to [`MAX_VALUE`]. /// /// [`MAX_VALUE`]: constant.MAX_VALUE.html - fn start