embassy-nrf

Crates

git

Versions

nrf52820

Flavors

embassy_nrf

Macro bind_interrupts

Source
macro_rules! bind_interrupts {
    ($vis:vis struct $name:ident {
        $(
            $(#[cfg($cond_irq:meta)])?
            $irq:ident => $(
                $(#[cfg($cond_handler:meta)])?
                $handler:ty
            ),*;
        )*
    }) => { ... };
    (@inner $($t:tt)*) => { ... };
}
Expand description

Macro to bind interrupts to handlers.

This defines the right interrupt handlers, and creates a unit struct (like struct Irqs;) and implements the right [Binding]s for it. You can pass this struct to drivers to prove at compile-time that the right interrupts have been bound.

Example of how to bind one interrupt:

use embassy_nrf::{bind_interrupts, spim, peripherals};

bind_interrupts!(struct Irqs {
    SPIM3 => spim::InterruptHandler<peripherals::SPI3>;
});

Example of how to bind multiple interrupts in a single macro invocation:

use embassy_nrf::{bind_interrupts, spim, twim, peripherals};

bind_interrupts!(struct Irqs {
    SPIM3 => spim::InterruptHandler<peripherals::SPI3>;
    TWISPI0 => twim::InterruptHandler<peripherals::TWISPI0>;
});