Interrupts

    Interrupts do allow for a lot of flexibility which needs to be accounted for when attempting to use them in an advanced way. We will not cover those uses in this book, however it is a good idea to keep the following in mind:

    • Interrupts have programmable priorities which determine their handlers’ execution order
    • Interrupts can nest and preempt, i.e. execution of an interrupt handler might be interrupted by another higher-priority interrupt
    • In general the reason causing the interrupt to trigger needs to be cleared to prevent re-entering the interrupt handler endlessly
    • Set the desired priority of the interrupt handler in the interrupt controller
    • Enable the interrupt handler in the interrupt controller

    Similarly to exceptions, the crate provides an attribute to declare interrupt handlers. The available interrupts (and their position in the interrupt handler table) are usually automatically generated via svd2rust from a SVD description.

    Similar to exception handlers it is also possible to declare static mut variables inside the interrupt handlers for safe state keeping.

    1. static mut COUNT: u32 = 0;
    2. // `COUNT` has type `&mut u32` and it's safe to use