aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/examples/override-exception.rs
blob: dca31e665d0c0812d718873766ded32f675f3751 (plain) (blame)
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
//! How to override the hard fault exception handler and the default exception handler

#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]

extern crate cortex_m;
extern crate cortex_m_rt as rt;
extern crate panic_semihosting;

use cortex_m::asm;
use rt::{entry, exception, ExceptionFrame};

#[entry]
fn main() -> ! {
    loop {}
}

#[exception(DefaultHandler)]
fn default_handler(_irqn: i16) {
    asm::bkpt();
}

#[exception(HardFault)]
fn hard_fault(_ef: &ExceptionFrame) -> ! {
    asm::bkpt();

    loop {}
}