stm32f103-template/src/lib.rs

27 lines
666 B
Rust

#![no_std]
use defmt_rtt as _; // global logger
use panic_probe as _;
use stm32f1xx_hal as _;
use core::sync::atomic::{AtomicU32, Ordering};
pub mod application;
// same panicking *behavior* as `panic-probe` but doesn't print a panic message
// this prevents the panic message being printed *twice* when `defmt::panic` is invoked
#[defmt::panic_handler]
fn panic() -> ! {
cortex_m::asm::udf()
}
static COUNT: AtomicU32 = AtomicU32::new(0);
defmt::timestamp!("{=u32}", COUNT.fetch_add(1, Ordering::Relaxed));
/// Terminates the application and makes `probe-run` exit with exit-code = 0
pub fn exit() -> ! {
loop {
cortex_m::asm::bkpt();
}
}