embassy/examples/src/example_common.rs

19 lines
428 B
Rust
Raw Normal View History

2020-09-22 16:03:43 +00:00
#![macro_use]
use defmt_rtt as _; // global logger
use nrf52840_hal as _;
use panic_probe as _;
2020-11-27 17:42:59 +00:00
pub use defmt::*;
2020-09-22 16:03:43 +00:00
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
}