Trait riscv_pac::InterruptNumber
source · pub unsafe trait InterruptNumber: Copy {
const MAX_INTERRUPT_NUMBER: u16;
// Required methods
fn number(self) -> u16;
fn from_number(value: u16) -> Result<Self, u16>;
}
Expand description
Trait for enums of target-specific external interrupt numbers.
This trait should be implemented by a peripheral access crate (PAC)
on its enum of available external interrupts for a specific device.
Each variant must convert to a u16
of its interrupt number.
§Safety
- This trait must only be implemented on a PAC of a RISC-V target.
- This trait must only be implemented on enums of external interrupts.
- Each enum variant must represent a distinct value (no duplicates are permitted),
- Each enum variant must always return the same value (do not change at runtime).
- All the interrupt numbers must be less than or equal to
MAX_INTERRUPT_NUMBER
. MAX_INTERRUPT_NUMBER
must coincide with the highest allowed interrupt number.
Required Associated Constants§
sourceconst MAX_INTERRUPT_NUMBER: u16
const MAX_INTERRUPT_NUMBER: u16
Highest number assigned to an interrupt source.
Required Methods§
sourcefn from_number(value: u16) -> Result<Self, u16>
fn from_number(value: u16) -> Result<Self, u16>
Tries to convert a number to a valid interrupt source. If the conversion fails, it returns an error with the number back.
Object Safety§
This trait is not object safe.