aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf-examples/src/example_common.rs
blob: d16964d4fc2a0709bcce2172a0bb70e8c0d5e8ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#![macro_use]

use defmt_rtt as _; // global logger
use nrf52840_hal as _;
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
    }
}