Module 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§

state
Module containing types and traits representing OwnedInterruptSet type states

Structs§

InterruptConfiguration
Controls enabling and line selection of interrupts.
InterruptSet
A set of CAN interrupts.
InvalidInterruptNumber
No interrupt with that number exists
Iter
An iterator over the items of an InterruptSet.
MaskError
An input InterruptSet contained interrupts that were not available. The set wrapped in the error indicates which elements caused the problem.
OwnedInterruptSet
Has exclusive access to a set of interrupts for Id CAN peripheral. Permits safe access to the owned interrupt flags.

Enums§

Interrupt
A single interrupt.
InterruptLine
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.