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