initial commit
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
#![no_std]
|
||||
|
||||
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
use defmt_rtt as _; // global logger
|
||||
|
||||
// TODO(5) adjust HAL import
|
||||
// use some_hal as _; // memory layout
|
||||
|
||||
#[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
|
||||
}
|
||||
|
||||
#[panic_handler] // panicking behavior
|
||||
fn panic(info: &core::panic::PanicInfo) -> ! {
|
||||
if let Some(loc) = info.location() {
|
||||
defmt::error!(
|
||||
"panicked at {:str}:{:u32}:{:u32}",
|
||||
loc.file(),
|
||||
loc.line(),
|
||||
loc.column()
|
||||
)
|
||||
} else {
|
||||
// no location info
|
||||
defmt::error!("panicked")
|
||||
}
|
||||
|
||||
exit()
|
||||
}
|
||||
|
||||
/// Terminates the application and makes `probe-run` exit with exit-code = 0
|
||||
pub fn exit() -> ! {
|
||||
loop {
|
||||
cortex_m::asm::bkpt();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user