diff --git a/boards/rp-pico/examples/pico_rtic.rs b/boards/rp-pico/examples/pico_rtic.rs index 1218f47..3d83735 100644 --- a/boards/rp-pico/examples/pico_rtic.rs +++ b/boards/rp-pico/examples/pico_rtic.rs @@ -7,13 +7,13 @@ use panic_halt as _; mod app { use embedded_hal::digital::v2::OutputPin; - use fugit::SecsDurationU32; + use fugit::MicrosDurationU32; use rp_pico::{ hal::{self, clocks::init_clocks_and_plls, timer::Alarm, watchdog::Watchdog, Sio}, XOSC_CRYSTAL_FREQ, }; - const SCAN_TIME_US: SecsDurationU32 = SecsDurationU32::secs(1); + const SCAN_TIME_US: MicrosDurationU32 = MicrosDurationU32::secs(1); #[shared] struct Shared { diff --git a/rp2040-hal/src/timer.rs b/rp2040-hal/src/timer.rs index 70424ad..403e2a0 100644 --- a/rp2040-hal/src/timer.rs +++ b/rp2040-hal/src/timer.rs @@ -8,7 +8,7 @@ //! //! See [Chapter 4 Section 6](https://datasheets.raspberrypi.org/rp2040/rp2040_datasheet.pdf) of the datasheet for more details. -use fugit::{Duration, MicrosDurationU64, TimerInstantU64}; +use fugit::{MicrosDurationU32, MicrosDurationU64, TimerInstantU64}; use crate::atomic_register_access::{write_bitmask_clear, write_bitmask_set}; use crate::pac::{RESETS, TIMER}; @@ -200,10 +200,7 @@ pub trait Alarm { /// this will trigger interrupt whenever this time elapses. /// /// [enable_interrupt]: #method.enable_interrupt - fn schedule( - &mut self, - countdown: Duration, - ) -> Result<(), ScheduleAlarmError>; + fn schedule(&mut self, countdown: MicrosDurationU32) -> Result<(), ScheduleAlarmError>; /// Schedule the alarm to be finished at the given timestamp. If [enable_interrupt] is /// called, this will trigger interrupt whenever this timestamp is reached. @@ -307,14 +304,10 @@ macro_rules! impl_alarm { /// ` whenever this time elapses. /// /// [enable_interrupt]: #method.enable_interrupt - fn schedule( - &mut self, - countdown: Duration, - ) -> Result<(), ScheduleAlarmError> { + fn schedule(&mut self, countdown: MicrosDurationU32) -> Result<(), ScheduleAlarmError> { // safety: Only read operations are made on the timer and they should not have any UB let timer = unsafe { &*TIMER::ptr() }; - let micros = fugit::MicrosDurationU32::micros(countdown.to_micros()); - let timestamp = get_counter(timer) + micros; + let timestamp = get_counter(timer) + countdown; self.schedule_internal(timer, timestamp) }