#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Exception {
ThreadMode,
Nmi,
HardFault,
MemoryManagementFault,
BusFault,
UsageFault,
SVCall,
PendSV,
Systick,
Interrupt(u8),
#[doc(hidden)]
Reserved,
}
impl Exception {
pub fn current() -> Exception {
match ::peripheral::scb().icsr.read() as u8 {
0 => Exception::ThreadMode,
2 => Exception::Nmi,
3 => Exception::HardFault,
4 => Exception::MemoryManagementFault,
5 => Exception::BusFault,
6 => Exception::UsageFault,
11 => Exception::SVCall,
14 => Exception::PendSV,
15 => Exception::Systick,
n if n >= 16 => Exception::Interrupt(n - 16),
_ => Exception::Reserved,
}
}
}