diff options
| author | VasanthakumarV <[email protected]> | 2021-12-11 21:51:14 +0530 |
|---|---|---|
| committer | VasanthakumarV <[email protected]> | 2021-12-13 14:50:13 +0530 |
| commit | a65c2bc2b43d82d5c0b5c192d68ef10f63901750 (patch) | |
| tree | 1e7c2894dec0c7d03c4c841c4fc9ed90456824c0 /examples/stm32f3/src/example_common.rs | |
| parent | 3f33d307ffc6c122abfa113e6c72a9f7acda40e5 (diff) | |
[examples] Add examples for STM32F3
Diffstat (limited to 'examples/stm32f3/src/example_common.rs')
| -rw-r--r-- | examples/stm32f3/src/example_common.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/stm32f3/src/example_common.rs b/examples/stm32f3/src/example_common.rs new file mode 100644 index 000000000..e14517033 --- /dev/null +++ b/examples/stm32f3/src/example_common.rs | |||
| @@ -0,0 +1,19 @@ | |||
| 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! { | ||
| 11 | "{=u64}", | ||
| 12 | { | ||
| 13 | static COUNT: AtomicUsize = AtomicUsize::new(0); | ||
| 14 | // NOTE(no-CAS) `timestamps` runs with interrupts disabled | ||
| 15 | let n = COUNT.load(Ordering::Relaxed); | ||
| 16 | COUNT.store(n + 1, Ordering::Relaxed); | ||
| 17 | n as u64 | ||
| 18 | } | ||
| 19 | } | ||
