update examples and docs
This commit is contained in:
49
src/examples/_3_panic.rs
Normal file
49
src/examples/_3_panic.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
//! Changing the panic handler
|
||||
//!
|
||||
//! The easiest way to change the panic handler is to use a different [panic implementation
|
||||
//! crate][0].
|
||||
//!
|
||||
//! [0]: https://crates.io/keywords/panic-impl
|
||||
//!
|
||||
//! ---
|
||||
//!
|
||||
//! ```
|
||||
//!
|
||||
//! #![no_main]
|
||||
//! #![no_std]
|
||||
//!
|
||||
//! extern crate cortex_m;
|
||||
//! #[macro_use]
|
||||
//! extern crate cortex_m_rt as rt;
|
||||
//! // extern crate panic_abort;
|
||||
//! extern crate panic_semihosting; // reports panic messages to the host stderr using semihosting
|
||||
//!
|
||||
//! use cortex_m::asm;
|
||||
//! use rt::ExceptionFrame;
|
||||
//!
|
||||
//! main!(main);
|
||||
//!
|
||||
//! #[inline(always)]
|
||||
//! fn main() -> ! {
|
||||
//! panic!("Oops")
|
||||
//! }
|
||||
//!
|
||||
//! exception!(DefaultHandler, deh);
|
||||
//!
|
||||
//! #[inline(always)]
|
||||
//! fn deh(_nr: u8) {
|
||||
//! asm::bkpt();
|
||||
//! }
|
||||
//!
|
||||
//! exception!(HardFault, hf);
|
||||
//!
|
||||
//! #[inline(always)]
|
||||
//! fn hf(_ef: &ExceptionFrame) -> ! {
|
||||
//! asm::bkpt();
|
||||
//!
|
||||
//! loop {}
|
||||
//! }
|
||||
//!
|
||||
//! interrupts!(DefaultHandler);
|
||||
//! ```
|
||||
// Auto-generated. Do not modify.
|
||||
Reference in New Issue
Block a user