move out most of text
see https://github.com/rust-embedded/book/pull/20
This commit is contained in:
@@ -79,36 +79,18 @@
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate cortex_m;
|
||||
#[macro_use]
|
||||
extern crate cortex_m_rt as rt;
|
||||
extern crate panic_semihosting;
|
||||
extern crate panic_halt;
|
||||
|
||||
use core::ptr;
|
||||
|
||||
use rt::ExceptionFrame;
|
||||
|
||||
entry!(main);
|
||||
use cortex_m_rt::entry;
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
unsafe {
|
||||
// read an address outside of the RAM region; causes a HardFault exception
|
||||
// read an address outside of the RAM region; this causes a HardFault exception
|
||||
ptr::read_volatile(0x2FFF_FFFF as *const u32);
|
||||
}
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
||||
// define the hard fault handler
|
||||
exception!(HardFault, hard_fault);
|
||||
|
||||
fn hard_fault(ef: &ExceptionFrame) -> ! {
|
||||
panic!("HardFault at {:#?}", ef);
|
||||
}
|
||||
|
||||
// define the default exception handler
|
||||
exception!(*, default_handler);
|
||||
|
||||
fn default_handler(irqn: i16) {
|
||||
panic!("Unhandled exception (IRQn = {})", irqn);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user