#raspberry-pi #interrupt #bare-metal #ruspiro

nightly sys no-std ruspiro-interrupt

Providing a simple and convenient way to implement interrupt handler for Raspberry Pi interrupts

11 releases

0.5.0 Nov 26, 2021
0.4.3 Apr 28, 2021
0.4.1 Feb 6, 2021
0.3.1 Sep 11, 2020
0.1.1 Aug 9, 2019

#2122 in Embedded development


Used in 5 crates (3 directly)

Apache-2.0 OR MIT

45KB
846 lines

Interrupt RusPiRo crate

This crates provides functions and macros (custom attributes) to conviniently define and implement interrupt handler for the Raspberry Pi 3 in a bare metal environment.

CI Latest Version Documentation License

Dependencies

This crate, when used to build a final binary, assumes that there is a low level exeption handler in place that will call into a function called __isr_default. When using the ruspiro-boot crate this function is weakly exported from their to allow floawless compiling and linking. However, this empty export will be overruled by the linker with the function of the same name exported from this crate.

Usage

To use the crate just add the following dependency to your Cargo.toml file:

[dependencies]
ruspiro-interrupt = "0.5.0"

Once done the access to the features/attribute of the interrupt crate is available in your rust files like so:

extern crate ruspiro_interrupt; // needed for proper linking of weak defined functions
use ruspiro_interrupt::*;

#[IrqHandler(<irq-type-name>)]
unsafe fn my_handler(channel: Option<IsrSender<Box<dyn Any>>>) {
  /* implementation omitted */
}

In rare cases the interrupt line is shared for different sources, in this case the attribute need to specify the source:

#[IrqHandler(<irq-type-name>, <source>)]
unsafe fn my_handler_for_source(channel: Option<IsrSender<Box<dyn Any>>>) {
  /* implementation omitted */
}

The currently only implemented shared source interrupt line is the AUX interrupt. There the source could be one of: Uart1, Spi1 or Spi2.

Features

Feature Description
pi3 Uses the MMIO mapped peripheral Addresses of Raspberry Pi 3
pi4_low Uses the MMIO mapped peripheral Addresses of Raspberry Pi 4 in low-peri mode. The config.txt requires arm_peri_high=0 setting.
pi4_high Uses the MMIO mapped peripheral Addresses of Raspberry Pi 4 in high-peri mode. The config.txt requires arm_peri_high=1 setting.
async Enables the async version of the interrupt handling implementation.

License

Licensed under Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) or MIT (LICENSE-MIT or http://opensource.org/licenses/MIT)) at your choice.

Dependencies

~2MB
~43K SLoC