unstable only.Expand description
§Interrupt support
§Overview
This module routes one or more peripheral interrupt sources to any one of the CPU’s peripheral interrupts.
§Configuration
Usually peripheral drivers offer a mechanism to register your interrupt
handler. e.g. the systimer offers set_interrupt_handler to register a
handler for a specific alarm. Other drivers might take an interrupt handler
as an optional parameter to their constructor.
This is the preferred way to register handlers.
There are additional ways to register interrupt handlers which are generally only meant to be used in very special situations (mostly internal to the HAL or the supporting libraries). Those are outside the scope of this documentation.
It is even possible, but not recommended, to bind an interrupt directly to a
CPU interrupt. This can offer lower latency, at the cost of more complexity
in the interrupt handler. See the direct_vectoring.rs example
We reserve a number of CPU interrupts, which cannot be used; see
RESERVED_INTERRUPTS.
§Examples
§Using the peripheral driver to register an interrupt handler
let mut sw_int = SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
critical_section::with(|cs| {
    sw_int
        .software_interrupt0
        .set_interrupt_handler(swint0_handler);
    SWINT0
        .borrow_ref_mut(cs)
        .replace(sw_int.software_interrupt0);
});
critical_section::with(|cs| {
    if let Some(swint) = SWINT0.borrow_ref(cs).as_ref() {
        swint.raise();
    }
});
static SWINT0: Mutex<RefCell<Option<SoftwareInterrupt<0>>>> = Mutex::new(RefCell::new(None));
#[handler(priority = Priority::Priority1)]
fn swint0_handler() {
    println!("SW interrupt0");
    critical_section::with(|cs| {
        if let Some(swint) = SWINT0.borrow_ref(cs).as_ref() {
            swint.reset();
        }
    });
}Modules§
- software
- Software Interrupts
Structs§
- InterruptHandler 
- An interrupt handler
- InterruptStatus 
- Representation of peripheral-interrupt status bits.
- InterruptStatus Iterator 
- Iterator over set interrupt status bits
- IsrCallback
- Represents an ISR callback function
- TrapFrame 
- Registers saved in trap handler
Enums§
- CpuInterrupt
- Enumeration of available CPU interrupts.
It is possible to create a handler for each of the interrupts. (e.g.
interrupt3)
- Error
- Interrupt Error
- InterruptKind 
- Interrupt kind
- Priority
- Interrupt priority levels.
Constants§
- DEFAULT_INTERRUPT_ HANDLER 
- Default (unhandled) interrupt handler
Statics§
- RESERVED_INTERRUPTS 
- The interrupts reserved by the HAL
Traits§
- InterruptConfigurable 
- Trait implemented by drivers which allow the user to set an InterruptHandler
Functions§
- bind_interrupt ⚠
- Binds the given interrupt to the given handler.
- bound_handler 
- Returns the currently bound interrupt handler.
- clear
- Clear a CPU interrupt
- current_runlevel 
- Get the current run level (the level below which interrupts are masked).
- disable
- Disable the given peripheral interrupt.
- enable
- Enables a interrupt at a given priority
- enable_cpu_ ⚠interrupt 
- Enable a CPU interrupt
- enable_direct 
- Enable an interrupt by directly binding it to a available CPU interrupt
- map⚠
- Assign a peripheral interrupt to an CPU interrupt.
- priority
- Get interrupt priority.
- priority_by_ core 
- Get interrupt priority for the CPU
- set_kind 
- Set the interrupt kind (i.e. level or edge) of an CPU interrupt
- set_priority ⚠
- Set the priority level of an CPU interrupt
- status
- Get status of peripheral interrupts