pub fn enable_direct(
interrupt: Interrupt,
level: Priority,
cpu_interrupt: CpuInterrupt,
handler: unsafe extern "C" fn(),
) -> Result<(), Error>Available on crate feature
unstable and riscv only.Expand description
Enable an interrupt by directly binding it to a available CPU interrupt
⚠️ This installs a raw trap handler, the handler user provides is written directly into the
CPU interrupt vector table. That means:
- Provided handler will be used as an actual trap-handler
- It is user’s responsibility to:
- Save and restore all registers they use.
- Clear the interrupt source if necessary.
- Return using the
mretinstruction.
- The handler should be declared as naked function. The compiler will not insert a function
prologue/epilogue for the user, normal Rust
fnwill result in an error.
Unless you are sure that you need such low-level control to achieve the lowest possible latency,
you most likely want to use enable instead.
Trying using a reserved interrupt from RESERVED_INTERRUPTS will return
an error.
§Example
Visit the interrupt test to see a proper example of how to use direct vectoring.