aboutsummaryrefslogtreecommitdiff
path: root/examples/src/example_common.rs
blob: 1a12fa69a9739add2628cc4f52b064d96c940293 (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 anyfmt::*;

use core::sync::atomic::{AtomicUsize, Ordering};

#[defmt::timestamp]
fn 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
}