diff --git a/rp2040-hal/src/pio.rs b/rp2040-hal/src/pio.rs index 6343a1845..58705dade 100644 --- a/rp2040-hal/src/pio.rs +++ b/rp2040-hal/src/pio.rs @@ -123,20 +123,29 @@ impl PIO

{ self.pio } - /// This PIO's IRQ0 interrupt. - pub fn irq0(&self) -> Interrupt<'_, P, 0> { + /// This PIO's interrupt by index. + pub fn irq(&self) -> Interrupt<'_, P, IRQ> { + struct IRQSanity; + impl IRQSanity { + const CHECK: () = assert!(IRQ <= 1, "IRQ index must be either 0 or 1"); + } + + #[allow(clippy::let_unit_value)] + let _ = IRQSanity::::CHECK; Interrupt { block: self.pio.deref(), _phantom: core::marker::PhantomData, } } + /// This PIO's IRQ0 interrupt. + pub fn irq0(&self) -> Interrupt<'_, P, 0> { + self.irq() + } + /// This PIO's IRQ1 interrupt. pub fn irq1(&self) -> Interrupt<'_, P, 1> { - Interrupt { - block: self.pio.deref(), - _phantom: core::marker::PhantomData, - } + self.irq() } /// Get raw irq flags.