aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/examples/override-exception.rs
blob: 3e0af25ef8705b14c1fcd4610f9f9ebdd99ecbe2 (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]
fn DefaultHandler(_irqn: i16) {
    asm::bkpt();
}

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

    loop {}
}