1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Defining the panic handler
//!
//! The panic handler can be defined through the `panic_fmt` [language item][1].
//! Make sure that the "abort-on-panic" feature of the cortex-m-rt crate is
//! disabled to avoid redefining the language item.
//!
//! [1]: https://doc.rust-lang.org/unstable-book/language-features/lang-items.html
//!
//! ---
//!
//! ```
//! 
//! #![feature(core_intrinsics)]
//! #![feature(lang_items)]
//! #![feature(used)]
//! #![no_std]
//! 
//! extern crate cortex_m;
//! extern crate cortex_m_rt;
//! extern crate cortex_m_semihosting;
//! 
//! use core::fmt::Write;
//! use core::intrinsics;
//! 
//! use cortex_m::asm;
//! use cortex_m_semihosting::hio;
//! 
//! fn main() {
//!     panic!("Oops");
//! }
//! 
//! #[lang = "panic_fmt"]
//! #[no_mangle]
//! unsafe extern "C" fn rust_begin_unwind(
//!     args: core::fmt::Arguments,
//!     file: &'static str,
//!     line: u32,
//!     col: u32,
//! ) -> ! {
//!     if let Ok(mut stdout) = hio::hstdout() {
//!         write!(stdout, "panicked at '")
//!             .and_then(|_| {
//!                 stdout
//!                     .write_fmt(args)
//!                     .and_then(|_| writeln!(stdout, "', {}:{}", file, line))
//!             })
//!             .ok();
//!     }
//! 
//!     intrinsics::abort()
//! }
//! 
//! // As we are not using interrupts, we just register a dummy catch all handler
//! #[link_section = ".vector_table.interrupts"]
//! #[used]
//! static INTERRUPTS: [extern "C" fn(); 240] = [default_handler; 240];
//! 
//! extern "C" fn default_handler() {
//!     asm::bkpt();
//! }
//! ```
// Auto-generated. Do not modify.