Skip to main content

panic_rtt_core/
lib.rs

1//! Set the panicking behavior to log to a JLINK debugger and break.
2//!
3//! Currently, this crate only supports the ARM Cortex-M architecture.
4//!
5//! # Usage
6//!
7//! ``` ignore
8//! #![no_std]
9//!
10//! use panic_rtt_core::{self, rtt_init_print, rprintln};
11//!
12//! fn main() {
13//!     // you must create a print channel if you wish to see print output in RTT
14//!     rtt_init_print!(NoBlockTrim);
15//!     let value = 5;
16//!     rprintln!("Hello world! {}", value);
17//!     panic!("message logged to jlink debugger");
18//! }
19//! ```
20#![deny(missing_docs)]
21#![deny(warnings)]
22#![no_std]
23
24
25use core::panic::PanicInfo;
26use cortex_m::{asm, interrupt};
27pub use rtt_target::{rprint, rprintln, rtt_init_print};
28
29#[inline(never)]
30#[panic_handler]
31fn panic(info: &PanicInfo) -> ! {
32    interrupt::disable();
33    rprintln!("{}", info);
34
35    loop {
36        asm::bkpt();
37    }
38}
39
40
41
42