take_nvic_interrupt!() { /* proc-macro */ }Expand description
Return an instance of an unnameable struct that implements NvicInterruptRegistration, which
is bound to the interrupt specified by interrupt with logical priority priority.
interrupt must name an enum variant of an enum that implements InterruptNumber with at least 2 path segments.
For instance, Interrupt::EXTI15_10 (where Interrupt implements InterruptNumber) is allowed,
but EXTI15_10 by itself, even if imported using use Interrupt::EXTI15_10, is not.
The returned struct has the following features:
- Calling
registermore than once for the sameInterruptpanics. - The bound interrupt will be masked in the NVIC before configuring the occupation of the registration, and unmasked after.
- The the amount of available NVIC priority bits is determined runtime.
§Logical priority
A logical priority with a lower value has a lower priority level. This means that the logical priority
1 has the lowest priority level, while logical priority 2^N (where N = <available priority bits on platform>)
has the highest priority level. A logical priority of 0 is not allowed, and a logical priority greater than 2^N panics
at runtime.
§Usage
use cortex_m_interrupt::take_nvic_interrupt;
// The value returned by `take_nvic_interrupt` will
// always `impl cortex_m_interrupt::NvicInterruptRegistration`.
let registration = take_nvic_interrupt!(interrupt, priority);
// For example, using stm32f1xx hal:
use stm32f1xx_hal::pac::interrupt;
let registration = cortex_m_interrupt::take_nvic_interrupt!(interrupt::EXTI15_10, 7);