Module mcan::interrupt

source ·
Expand description

Interrupt configuration and access.

Interrupts are handled through OwnedInterruptSets. They allow multiple parties to concurrently read or clear interrupts, as long as the sets of interrupts they operate on are disjoint. Initially, all interrupts will reside in a single OwnedInterruptSet, which can be OwnedInterruptSet::split to produce disjoint sets.

Interrupts can be assigned to one of two interrupt lines of the processor’s interrupt controller, or they can be disabled. Reconfiguring whether they are enabled and if so on which line requires more synchronization than the typical reading and clearing of flags, so this is done through methods on the InterruptConfiguration.

use mcan::interrupt::{Interrupt, InterruptLine};
// During initialization
let enabled_interrupts = can
    .interrupt_configuration
    .enable_line_0(
        can.interrupts
            .split(
                [Interrupt::BusOff, Interrupt::RxFifo0NewMessage]
                    .iter()
                    .copied()
                    .collect(),
            )
            .unwrap(),
    );

// When an interrupt arrives
for interrupt in enabled_interrupts.iter_flagged() {
    match interrupt {
        Interrupt::BusOff => {
            // ...
        }
        Interrupt::RxFifo0NewMessage => {
            // ...
        }
        _ => (),
    }
}

Modules§

Structs§

Enums§

  • A single interrupt.
  • CAN interrupt lines The CAN peripheral provides two interrupt lines to the system interrupt controller. Which interrupts trigger which interrupt line is configurable via InterruptConfiguration.