initial commit

This commit is contained in:
Jorge Aparicio
2020-08-21 12:02:11 +02:00
commit df96204a61
13 changed files with 479 additions and 0 deletions
+41
View File
@@ -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();
}
}