2022-09-20 17:23:56 +00:00
|
|
|
#![cfg_attr(not(any(feature = "std", feature = "wasm", test)), no_std)]
|
2023-11-29 16:23:48 +00:00
|
|
|
#![allow(async_fn_in_trait)]
|
2022-08-23 11:57:45 +00:00
|
|
|
#![doc = include_str!("../README.md")]
|
2022-08-17 21:40:16 +00:00
|
|
|
#![allow(clippy::new_without_default)]
|
|
|
|
#![warn(missing_docs)]
|
|
|
|
|
2023-12-22 16:08:39 +00:00
|
|
|
//! ## Feature flags
|
|
|
|
#![doc = document_features::document_features!(feature_label = r#"<span class="stab portability"><code>{feature}</code></span>"#)]
|
|
|
|
|
2022-08-17 21:40:16 +00:00
|
|
|
// This mod MUST go first, so that the others see its macros.
|
|
|
|
pub(crate) mod fmt;
|
2021-08-25 22:20:52 +00:00
|
|
|
|
2021-07-12 01:10:01 +00:00
|
|
|
mod delay;
|
2020-10-19 19:15:24 +00:00
|
|
|
mod duration;
|
|
|
|
mod instant;
|
2021-07-12 01:10:01 +00:00
|
|
|
mod timer;
|
2020-10-19 19:15:24 +00:00
|
|
|
|
2023-10-29 18:49:52 +00:00
|
|
|
#[cfg(feature = "mock-driver")]
|
|
|
|
mod driver_mock;
|
|
|
|
|
|
|
|
#[cfg(feature = "mock-driver")]
|
|
|
|
pub use driver_mock::MockDriver;
|
|
|
|
|
2021-08-25 18:34:25 +00:00
|
|
|
#[cfg(feature = "std")]
|
|
|
|
mod driver_std;
|
2021-09-13 12:35:40 +00:00
|
|
|
#[cfg(feature = "wasm")]
|
|
|
|
mod driver_wasm;
|
2022-09-26 10:46:15 +00:00
|
|
|
#[cfg(feature = "generic-queue")]
|
|
|
|
mod queue_generic;
|
2021-09-13 12:35:40 +00:00
|
|
|
|
2021-07-12 01:10:01 +00:00
|
|
|
pub use delay::{block_for, Delay};
|
2020-10-19 19:15:24 +00:00
|
|
|
pub use duration::Duration;
|
2024-01-11 21:47:05 +00:00
|
|
|
pub use embassy_time_driver::TICK_HZ;
|
2020-10-19 19:15:24 +00:00
|
|
|
pub use instant::Instant;
|
2021-07-12 01:10:01 +00:00
|
|
|
pub use timer::{with_timeout, Ticker, TimeoutError, Timer};
|
2020-10-19 19:15:24 +00:00
|
|
|
|
2022-02-12 02:19:46 +00:00
|
|
|
const fn gcd(a: u64, b: u64) -> u64 {
|
|
|
|
if b == 0 {
|
|
|
|
a
|
|
|
|
} else {
|
|
|
|
gcd(b, a % b)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-01 22:58:31 +00:00
|
|
|
pub(crate) const GCD_1K: u64 = gcd(TICK_HZ, 1_000);
|
|
|
|
pub(crate) const GCD_1M: u64 = gcd(TICK_HZ, 1_000_000);
|
2023-11-29 15:37:07 +00:00
|
|
|
pub(crate) const GCD_1G: u64 = gcd(TICK_HZ, 1_000_000_000);
|
2022-08-17 21:40:16 +00:00
|
|
|
|
|
|
|
#[cfg(feature = "defmt-timestamp-uptime")]
|
|
|
|
defmt::timestamp! {"{=u64:us}", Instant::now().as_micros() }
|