disconnect USB from host on exit/panic

This commit is contained in:
Jorge Aparicio 2022-01-12 16:17:20 +01:00
parent 8b15469bd3
commit e9dee61072
2 changed files with 3 additions and 0 deletions

View file

@ -323,6 +323,7 @@ fn RTC0() {
/// Exits the application when the program is executed through the `probe-run` Cargo runner
pub fn exit() -> ! {
unsafe { (0x4002_7504 as *mut u32).write_volatile(0) }
log::info!("`dk::exit() called; exiting ...`");
// force any pending memory operation to complete before the BKPT instruction that follows
atomic::compiler_fence(Ordering::SeqCst);

View file

@ -6,6 +6,8 @@ use cortex_m::asm;
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
unsafe { (0x4002_7504 as *mut u32).write_volatile(0) }
log::error!("{}", info);
// abort instruction: triggers a HardFault exception which causes probe-run to exit