[−][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() { // 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 helds a lock the code inside this handler tries to aquire the same one } 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 IRQ_MANAGER.take_for(|irq_mgr| { irq_mgr.initialize(); irq_mgr.activate(Interrupt::ArmTimer); irq_mgr.activate(Interrupt::Aux); }); enable_interrupts(); }
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() { // implement Uart1 interrupt handler here }
Limitations
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 |
entering_interrupt_handler | Function used to store a cross core global flag that an interrupt is currently handled |
leaving_interrupt_handler | Function used to clear a cross core global flag that no interrupt is currently handled |
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 |
Attribute Macros
IrqHandler |