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

Base CountDown on Timer instead of &Timer #815

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading