[−][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 |
disable_interrupts | globally disabling interrupts (IRQ/FIQ) from beeing triggered |
disable_irq | globally disable |
enable_fiq | globally enable |
enable_interrupts | globally enabling interrupts (IRQ/FIQ) to be triggered |
enable_irq | globally enable |
re_enable_fiq | globally re-enabe |
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 |
re_enable_irq | globally re-enabe |