mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-18 05:45:19 +01:00
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
This commit is contained in:
parent
9f5820da1d
commit
612a47ef4d
19 changed files with 560 additions and 141 deletions
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
use crate::{Monotonic, TimeoutError, TimerQueue};
|
||||
use atomic_polyfill::{compiler_fence, AtomicU64, Ordering};
|
||||
pub use fugit::{self, ExtU64};
|
||||
pub use fugit::{self, ExtU64, ExtU64Ceil};
|
||||
use stm32_metapac as pac;
|
||||
|
||||
mod _generated {
|
||||
|
|
@ -218,31 +218,17 @@ macro_rules! make_timer {
|
|||
}
|
||||
}
|
||||
|
||||
rtic_time::embedded_hal_delay_impl_fugit64!($mono_name);
|
||||
|
||||
#[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;
|
||||
}
|
||||
}
|
||||
|
||||
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 {}
|
||||
}
|
||||
}
|
||||
rtic_time::embedded_hal_async_delay_impl_fugit64!($mono_name);
|
||||
|
||||
impl Monotonic for $mono_name {
|
||||
type Instant = fugit::TimerInstantU64<TIMER_HZ>;
|
||||
type Duration = fugit::TimerDurationU64<TIMER_HZ>;
|
||||
|
||||
const ZERO: Self::Instant = Self::Instant::from_ticks(0);
|
||||
const TICK_PERIOD: Self::Duration = Self::Duration::from_ticks(1);
|
||||
|
||||
fn now() -> Self::Instant {
|
||||
// Credits to the `time-driver` of `embassy-stm32`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue