Expand description
Interaction with interrupts
The RIOT wrappers offer two ways to interact with interrupts:
-
Utility functions can disable interrupts (creating critical sections), check whether interrupts are enabled or to determine whether code is executed in a thread or an ISR.
-
Some functions (eg. set_during) take callbacks that will be called in an interrupt context.
These are typechecked to be Send, as they are moved from the thread to the interrupt context.
Not provided by riot-wrappers are methods of implementing interrupts that are directly called
by the CPU’s interrupt mechanism. These are extern "C"
functions (often with a () -> ()
signature) exported under a particular name using #[no_mangle]
. Any platform specifics (such
as the riot_sys::inline::cortexm_isr_end()
function) need to be managed by the
implementer, just as when implementing a C interrupt.
Rust code intended for use within interrupts does not generally need special precautions – but
several functions (generally, anything that blocks) are discouraged (as they may fail or stall
the system) outside of a thread context, or even “forbidden” (because they reliably lock up the
system, such as crate::mutex::Mutex::lock()). These functions often have preferred
alternatives that can be statically known to be executed in a thread context by keeping a copy
of crate::thread::InThread
.
Structs§
- Proof of running inside a critical section. Reexported from the bare_metal crate. Critical section token.
Functions§
- Run a closure in the current context, but with interrupts disabled.
- Trivial safe wrapper for
irq_is_enabled
- Trivial safe wrapper for
irq_is_in