Interaction with interrupts
The RIOT wrappers offer three 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.
ZTimer::set_ticks_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.
Writing interrupt handlers (using the
Writing interrupt handlers is something that obviously needs some care; when using this module, you must understand the implications of not doing so within the CPU implementation. (Note: The author does not).
This is intended to be used for implementing special interfaces that have no generalization in RIOT (eg. setting actions at particular points in a PWM cycle).
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.