Skip to content

Commit

Permalink
Merge pull request #815 from jannic/issue-216
Browse files Browse the repository at this point in the history
Base CountDown on Timer instead of &Timer
  • Loading branch information
thejpster authored Jul 20, 2024
2 parents a09724f + e4a722d commit 5da290a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions rp2040-hal/src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ impl Timer {
}

/// Initialized a Count Down instance without starting it.
pub fn count_down(&self) -> CountDown<'_> {
pub fn count_down(&self) -> CountDown {
CountDown {
timer: self,
timer: *self,
period: MicrosDurationU64::nanos(0),
next_end: None,
}
Expand Down Expand Up @@ -213,13 +213,13 @@ impl embedded_hal::delay::DelayNs for Timer {
/// // Cancel it immediately
/// count_down.cancel();
/// ```
pub struct CountDown<'timer> {
timer: &'timer Timer,
pub struct CountDown {
timer: Timer,
period: MicrosDurationU64,
next_end: Option<u64>,
}

impl embedded_hal_0_2::timer::CountDown for CountDown<'_> {
impl embedded_hal_0_2::timer::CountDown for CountDown {
type Time = MicrosDurationU64;

fn start<T>(&mut self, count: T)
Expand Down Expand Up @@ -250,9 +250,9 @@ impl embedded_hal_0_2::timer::CountDown for CountDown<'_> {
}
}

impl embedded_hal_0_2::timer::Periodic for CountDown<'_> {}
impl embedded_hal_0_2::timer::Periodic for CountDown {}

impl embedded_hal_0_2::timer::Cancel for CountDown<'_> {
impl embedded_hal_0_2::timer::Cancel for CountDown {
type Error = &'static str;

fn cancel(&mut self) -> Result<(), Self::Error> {
Expand Down

0 comments on commit 5da290a

Please sign in to comment.