mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2024-09-22 11:30:07 +00:00
20 lines
973 B
Rust
20 lines
973 B
Rust
#![no_std]
|
|
|
|
use panic_probe as _;
|
|
|
|
// 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() -> ! {
|
|
unsafe {
|
|
// turn off the USB D+ pull-up before pausing the device with a breakpoint
|
|
// this disconnects the nRF device from the USB host so the USB host won't attempt further
|
|
// USB communication (and see an unresponsive device). probe-run will also reset the nRF's
|
|
// USBD peripheral when it sees the device in a halted state which has the same effect as
|
|
// this line but that can take a while and the USB host may issue a power cycle of the USB
|
|
// port / hub / root in the meantime, which can bring down the probe and break probe-run
|
|
const USBD_USBPULLUP: *mut u32 = 0x4002_7504 as *mut u32;
|
|
USBD_USBPULLUP.write_volatile(0)
|
|
}
|
|
cortex_m::asm::udf()
|
|
}
|