diff options
| author | Andres O. Vela <[email protected]> | 2024-05-30 22:16:56 +0200 |
|---|---|---|
| committer | Andres O. Vela <[email protected]> | 2024-05-30 22:16:56 +0200 |
| commit | 6eaa25934226ee5ff2038a34e6d32b5d69559c1d (patch) | |
| tree | b732407ca438eaae2b017c5a107c499f81539853 /embassy-time/src | |
| parent | 694ac3a51573421c90e350c6253e2f42b4ab0bb1 (diff) | |
embassy-time: add timestamp features
Diffstat (limited to 'embassy-time/src')
| -rw-r--r-- | embassy-time/src/lib.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/embassy-time/src/lib.rs b/embassy-time/src/lib.rs index 3c8575ee9..24ee51be7 100644 --- a/embassy-time/src/lib.rs +++ b/embassy-time/src/lib.rs | |||
| @@ -46,5 +46,20 @@ pub(crate) const GCD_1K: u64 = gcd(TICK_HZ, 1_000); | |||
| 46 | pub(crate) const GCD_1M: u64 = gcd(TICK_HZ, 1_000_000); | 46 | pub(crate) const GCD_1M: u64 = gcd(TICK_HZ, 1_000_000); |
| 47 | pub(crate) const GCD_1G: u64 = gcd(TICK_HZ, 1_000_000_000); | 47 | pub(crate) const GCD_1G: u64 = gcd(TICK_HZ, 1_000_000_000); |
| 48 | 48 | ||
| 49 | #[cfg(feature = "defmt-timestamp-uptime")] | 49 | #[cfg(feature = "defmt-timestamp-uptime-s")] |
| 50 | defmt::timestamp! {"{=u64}", Instant::now().as_secs() } | ||
| 51 | |||
| 52 | #[cfg(feature = "defmt-timestamp-uptime-ms")] | ||
| 53 | defmt::timestamp! {"{=u64:ms}", Instant::now().as_millis() } | ||
| 54 | |||
| 55 | #[cfg(any(feature = "defmt-timestamp-uptime", feature = "defmt-timestamp-uptime-us"))] | ||
| 50 | defmt::timestamp! {"{=u64:us}", Instant::now().as_micros() } | 56 | defmt::timestamp! {"{=u64:us}", Instant::now().as_micros() } |
| 57 | |||
| 58 | #[cfg(feature = "defmt-timestamp-uptime-ts")] | ||
| 59 | defmt::timestamp! {"{=u64:ts}", Instant::now().as_secs() } | ||
| 60 | |||
| 61 | #[cfg(feature = "defmt-timestamp-uptime-tms")] | ||
| 62 | defmt::timestamp! {"{=u64:tms}", Instant::now().as_millis() } | ||
| 63 | |||
| 64 | #[cfg(feature = "defmt-timestamp-uptime-tus")] | ||
| 65 | defmt::timestamp! {"{=u64:tus}", Instant::now().as_micros() } | ||
