Expand description
Interrupt configuration and access.
Interrupts are handled through OwnedInterruptSet
s. 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§
- Module containing types and traits representing
OwnedInterruptSet
type states
Structs§
- Controls enabling and line selection of interrupts.
- A set of CAN interrupts.
- No interrupt with that number exists
- An iterator over the items of an
InterruptSet
. - An input
InterruptSet
contained interrupts that were not available. The set wrapped in the error indicates which elements caused the problem. - Has exclusive access to a set of interrupts for
Id
CAN peripheral. Permits safe access to the owned interrupt flags.
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
.