ruspiro-interrupt 0.5.0

Providing a simple and convenient way to implement interrupt handler for Raspberry Pi interrupts. failed to build ruspiro-interrupt-0.5.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure builds.
If you believe this is' fault, open an issue.
Visit the last successful build: ruspiro-interrupt-0.3.1

Interrupt handler for Raspberry Pi

This crates provides functions and macros (custom attribute) to conviniently implement interrupt handler for Raspberry Pi 3. The possible interrupts a handler can be implemented for are available as enum [irqtypes::Interrupt]


extern crate ruspiro_interrupt; // <- this kind of usage is VERY IMPORTANT to ensure linking works as expected!
use ruspiro_interrupt::{self as irq, IrqHandler, IsrSender, isr_channel};

fn timer_handler(channel: Option<IsrSender<Box<dyn Any>>>) {
// IMPORTANT: acknowledge the irq !

// implement stuff that shall be executed if the interrupt is raised...
// be careful when this code uses spinlocks as this might lead to dead-locks if the
// executing code interrupted currently holds a lock the code inside this handler tries to aquire as well

In some cases the interrupt type/line is shared between different sources. In those cases a handler need to be implemented for the specific interrupt source. The source is given in the custom attribute like this:

extern crate ruspiro_interrupt; // <- this kind of usage is VERY IMPORTANT to ensure linking works as expected!
use ruspiro_interrupt::*;

#[IrqHandler(Aux, Uart1)]
fn aux_uart1_handler(channel: Option<IsrSender<Box<dyn Any>>>) {
// implement Uart1 interrupt handler here

With the actual interrupt handling routines in place the corresponding interrupts need to be configured and activated like the following.

fn main() {
// as we have an interrupt handler defined we need to enable interrupt handling globally as well
// as the specific interrupt we have a handler implemented for
// activate an irq that uses a channel to allow data to flow from the interrupt handler to the "normal"
// processing
let (timer_tx, mut timer_rx) = isr_channel::<()>();
irq::activate(Interrupt::ArmTimer, timer_tx);
// activate an irq that does not use a channel as all processing is done inside it's handler
irq::activate(Interrupt::Aux, None);


// wait for the interrupt to send some data along (blocking current execution)
let _ = timer_rx.recv();

// when the crate is used with the feature `async` beeing set, waiting for
// for the data send by the interrupt would look like this:
while let Some(_) = {
// do stuff ...

Limitations for shared interrupt lines

However, only a limited ammount of shared interrupt lines implementation is available with the current version - which is only the Aux interrupt at the moment.