irq

Attribute Macro irq 

Source
#[irq]
Expand description

Creates an unsafe interrupt handler.

It’s unsafe because you are not supposed to call it - it should only be called from assembly routines registered in the interrupt vector table.

When placed on a function like:

#[irq]
fn foo(addr: usize) -> ! {
    panic!("On no")
}

You get something like:

#[doc(hidden)]
#[export_name = "_irq_handler"]
pub unsafe extern "C" fn __cortex_ar_rt_irq_handler(addr: usize) -> ! {
    foo(addr)
}

fn foo(addr: usize) -> ! {
    panic!("On no")
}

This is preferred over #[exception(Irq) because most people probably won’t consider interrupts to be a form of exception.