diff options
| author | Finomnis <Finomnis@users.noreply.github.com> | 2023-12-01 08:59:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-01 07:59:22 +0000 |
| commit | 612a47ef4d09da3553145d77bf1750314bbb7b16 (patch) | |
| tree | 7f6f6beca7e0c81397994b4f835c6a7f0bbee331 /rtic-monotonics/src/nrf | |
| parent | 9f5820da1d36a8c84455b1bc0458d34eb7dd9a70 (diff) | |
Fix mono delay (#843)
* rtic-time: Compenstate for timer uncertainty
* Update changelog and incorrect cargo.lock in an example
* Fix Monotonic impls
* Fix tests
* Fix other monotonics, again
* Update changelog
* Fix example
* Fix DelayUs and DelayMs impls
* Minor coding style fix in u64 conversions
* Fix all changelogs
* Fix changelog
* Fix blocking DelayUs
* Minor monotonic rework
* Add delay precision test
* Add more tests
* Add rust-version tags to Cargo.toml
* Fix imxrt, rp2040 and systick timer
* Fix more monotonics
* Fix systick monotonic
* Some reverts
* Fix imxrt
* Fix nrf
* Fix rp2040
* Fix stm32
* Fix systick
* Fix rtic-time tests
* Bump to e-h.rc2
* Apply e-h.rc2 fixes to rtic-time
* Apply fixes from arbiter
* Fix clippy warning
* Minor beautification
* Revert previous changes
* Fix variable name
* Add blocking tests, but disable them by default
Diffstat (limited to 'rtic-monotonics/src/nrf')
| -rw-r--r-- | rtic-monotonics/src/nrf/rtc.rs | 23 | ||||
| -rw-r--r-- | rtic-monotonics/src/nrf/timer.rs | 24 |
2 files changed, 10 insertions, 37 deletions
diff --git a/rtic-monotonics/src/nrf/rtc.rs b/rtic-monotonics/src/nrf/rtc.rs index 9491307..1f4e34f 100644 --- a/rtic-monotonics/src/nrf/rtc.rs +++ b/rtic-monotonics/src/nrf/rtc.rs @@ -43,7 +43,7 @@ use nrf9160_pac::{self as pac, Interrupt, RTC0_NS as RTC0, RTC1_NS as RTC1}; use crate::{Monotonic, TimeoutError, TimerQueue}; use atomic_polyfill::{AtomicU32, Ordering}; use core::future::Future; -pub use fugit::{self, ExtU64}; +pub use fugit::{self, ExtU64, ExtU64Ceil}; #[doc(hidden)] #[macro_export] @@ -167,28 +167,15 @@ macro_rules! make_rtc { } } - #[cfg(feature = "embedded-hal-async")] - impl embedded_hal_async::delay::DelayUs for $mono_name { - #[inline] - async fn delay_us(&mut self, us: u32) { - Self::delay((us as u64).micros()).await; - } - #[inline] - async fn delay_ms(&mut self, ms: u32) { - Self::delay((ms as u64).millis()).await; - } - } + rtic_time::embedded_hal_delay_impl_fugit64!($mono_name); - impl embedded_hal::delay::DelayUs for $mono_name { - fn delay_us(&mut self, us: u32) { - let done = Self::now() + u64::from(us).micros(); - while Self::now() < done {} - } - } + #[cfg(feature = "embedded-hal-async")] + rtic_time::embedded_hal_async_delay_impl_fugit64!($mono_name); impl Monotonic for $mono_name { const ZERO: Self::Instant = Self::Instant::from_ticks(0); + const TICK_PERIOD: Self::Duration = Self::Duration::from_ticks(1); type Instant = fugit::TimerInstantU64<32_768>; type Duration = fugit::TimerDurationU64<32_768>; diff --git a/rtic-monotonics/src/nrf/timer.rs b/rtic-monotonics/src/nrf/timer.rs index 589cc6f..0488ca9 100644 --- a/rtic-monotonics/src/nrf/timer.rs +++ b/rtic-monotonics/src/nrf/timer.rs @@ -29,7 +29,7 @@ use crate::{Monotonic, TimeoutError, TimerQueue}; use atomic_polyfill::{AtomicU32, Ordering}; use core::future::Future; -pub use fugit::{self, ExtU64}; +pub use fugit::{self, ExtU64, ExtU64Ceil}; #[cfg(feature = "nrf52810")] use nrf52810_pac::{self as pac, Interrupt, TIMER0, TIMER1, TIMER2}; @@ -203,28 +203,14 @@ macro_rules! make_timer { } } - #[cfg(feature = "embedded-hal-async")] - impl embedded_hal_async::delay::DelayUs for $mono_name { - #[inline] - async fn delay_us(&mut self, us: u32) { - Self::delay((us as u64).micros()).await; - } - - #[inline] - async fn delay_ms(&mut self, ms: u32) { - Self::delay((ms as u64).millis()).await; - } - } + rtic_time::embedded_hal_delay_impl_fugit64!($mono_name); - impl embedded_hal::delay::DelayUs for $mono_name { - fn delay_us(&mut self, us: u32) { - let done = Self::now() + (us as u64).micros(); - while Self::now() < done {} - } - } + #[cfg(feature = "embedded-hal-async")] + rtic_time::embedded_hal_async_delay_impl_fugit64!($mono_name); impl Monotonic for $mono_name { const ZERO: Self::Instant = Self::Instant::from_ticks(0); + const TICK_PERIOD: Self::Duration = Self::Duration::from_ticks(1); type Instant = fugit::TimerInstantU64<1_000_000>; type Duration = fugit::TimerDurationU64<1_000_000>; |
