From dff03ecfc74d6af716637888338ebfa99ab7a027 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 2 Jun 2021 01:30:07 +0200 Subject: Move examples to a subdirectory --- examples/nrf/src/example_common.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 examples/nrf/src/example_common.rs (limited to 'examples/nrf/src/example_common.rs') diff --git a/examples/nrf/src/example_common.rs b/examples/nrf/src/example_common.rs new file mode 100644 index 000000000..54d633837 --- /dev/null +++ b/examples/nrf/src/example_common.rs @@ -0,0 +1,17 @@ +#![macro_use] + +use defmt_rtt as _; // global logger +use panic_probe as _; + +pub use defmt::*; + +use core::sync::atomic::{AtomicUsize, Ordering}; + +defmt::timestamp! {"{=u64}", { + static COUNT: AtomicUsize = AtomicUsize::new(0); + // NOTE(no-CAS) `timestamps` runs with interrupts disabled + let n = COUNT.load(Ordering::Relaxed); + COUNT.store(n + 1, Ordering::Relaxed); + n as u64 + } +} -- cgit