diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-06-02 01:30:07 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-06-02 01:32:19 +0200 |
| commit | dff03ecfc74d6af716637888338ebfa99ab7a027 (patch) | |
| tree | c06bf2b0a2e6657c3427c956dbd27a4e45211aaa /examples/nrf/src/example_common.rs | |
| parent | a0c5f7137fe0c45b8db0aad2a116aea91e6a93f7 (diff) | |
Move examples to a subdirectory
Diffstat (limited to 'examples/nrf/src/example_common.rs')
| -rw-r--r-- | examples/nrf/src/example_common.rs | 17 |
1 files changed, 17 insertions, 0 deletions
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 @@ | |||
| 1 | #![macro_use] | ||
| 2 | |||
| 3 | use defmt_rtt as _; // global logger | ||
| 4 | use panic_probe as _; | ||
| 5 | |||
| 6 | pub use defmt::*; | ||
| 7 | |||
| 8 | use core::sync::atomic::{AtomicUsize, Ordering}; | ||
| 9 | |||
| 10 | defmt::timestamp! {"{=u64}", { | ||
| 11 | static COUNT: AtomicUsize = AtomicUsize::new(0); | ||
| 12 | // NOTE(no-CAS) `timestamps` runs with interrupts disabled | ||
| 13 | let n = COUNT.load(Ordering::Relaxed); | ||
| 14 | COUNT.store(n + 1, Ordering::Relaxed); | ||
| 15 | n as u64 | ||
| 16 | } | ||
| 17 | } | ||
