esp_hal

Module interrupt

Source
Available on crate feature 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| {
    SWINT0.borrow_ref(cs).as_ref().unwrap().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| {
        SWINT0.borrow_ref(cs).as_ref().unwrap().reset();
    });
}

Modules§

Structs§

  • An interrupt handler Note: Interrupts are handled on the core they were setup on, if a driver is initialized on core 0, and moved to core 1, core 0 will still handle the interrupt.
  • Representation of peripheral-interrupt status bits.
  • Iterator over set interrupt status bits

Enums§

Constants§

Statics§

Traits§

Functions§

  • Binds the given interrupt to the given handler.
  • Returns the currently bound interrupt handler.
  • Clear the given CPU interrupt
  • Disable the given peripheral interrupt
  • Enable the given peripheral interrupt
  • Enable an interrupt by directly binding it to a available CPU interrupt
  • map
    Assign a peripheral interrupt to an CPU interrupt
  • Get status of peripheral interrupts