docs.rs 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 docs.rs builds.
If you believe this is docs.rs' fault,
open an issue.
# 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
```no_run
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};
#[IrqHandler(ArmTimer)]
fn timer_handler(channel: Option
>>) {
// 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:
```no_run
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>>) {
// 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.
```no_run
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::initialize();
// 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);
enable_interrupts();
// 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(_) = timer_rx.next().await {
// 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.