interrupt

Attribute Macro interrupt 

Source
#[interrupt]
Expand description

Attribute to declare an Interrupt Service Routine (ISR)

The name of the ISRs must correspond to the interrupts names defined in the Peripheral Access Crate of the respective device.

static mut variables declared within an ISR are safe to access and can be used to preserve state across invocations of the handler. The compiler can’t prove this is safe so the attribute will help by making a transformation to the source code: for this reason a variable like static mut FOO: u32 will be accessible from within the ISR as let FOO: &mut u32;.

§Example

#[interrupt]
fn CORE_TIMER() {
    static mut COUNTER: u32 = 0;

    *COUNTER += 1;  // access of a static mut variable as described above

    // clear interrupt flag
    unsafe {
        (*INT::ptr()).ifs0clr.write(|w| w.ctif().bit(true));
    }
}