[][src]Crate ruspiro_interrupt

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

Usage

extern crate ruspiro_interrupt; // <- this kind of usage is VERY IMPORTANT to ensure linking works as expected!
use ruspiro_interrupt::*;
 
#[IrqHandler(ArmTimer)]
fn timer_handler() {
    // TODO: 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 helds a lock the code inside this handler tries to aquire the same one
    println!("timer interrupt raised");
}
 
fn doc() {
    // 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
    IRQ_MANAGER.take_for(|irq_mgr| {
        irq_mgr.enable();
        irq_mgr.activate(Interrupt.ArmTimer);
    });
}

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:

#[IrqHandler(Aux, Uart1)]
fn aux_uart1_handler() {
    // implement Uart1 interrupt handler here
}

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

Re-exports

pub use irqtypes::*;

Modules

irqtypes

Interrupt Types

Structs

InterruptManager

The interrupt manager representation

Statics

IRQ_MANAGER

The singleton accessor to the interrupt manager

Functions

disable_fiq

globally disable FIQ interrupts from beeing triggered. This function stores the state of the current enabling/disabling of interrupts. If disable is called multiple times after each other this will than ultimately store "disabled" as last state. In this case a previous enabled state (before the multiple calls) is not able to recover with a call to re_enable_fiq.

disable_interrupts

globally disabling interrupts (IRQ/FIQ) from beeing triggered

disable_irq

globally disable IRQ interrupts from beeing triggered. This function stores the state of the current enabling/disabling of interrupts. If disable is called multiple times after each other this will than ultimately store "disabled" as last state. In this case a previous enabled state (before the multiple calls) is not able to recover with a call to re_enable_irq.

enable_fiq

globally enable FIQ interrupts to be triggered

enable_interrupts

globally enabling interrupts (IRQ/FIQ) to be triggered

enable_irq

globally enable IRQ interrupts to be triggered

re_enable_fiq

globally re-enabe FIQ interrupts to be triggered based on the global state that was set before disabling FIQ interrupts wihin the disable_fiq function.

re_enable_interrupts

globally re-enabling interrupts (IRQ/FIQ) to be triggered. This is done based on the global state that was set before the interrupts were disable using the disable_interrupts function.

re_enable_irq

globally re-enabe IRQ interrupts to be triggered based on the global state that was set before disabling IRQ interrupts wihin the disable_irq function.