Skip to content

Commit

Permalink
Merge pull request #723 from redolution/pio-irq-zst
Browse files Browse the repository at this point in the history
Make PIO IRQ IDs into ZSTs
  • Loading branch information
jannic authored Nov 23, 2023
2 parents 41b3e41 + 12f8484 commit cfd6c12
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions rp2040-hal/src/pio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,29 @@ impl<P: PIOExt> PIO<P> {
self.pio
}

/// This PIO's IRQ0 interrupt.
pub fn irq0(&self) -> Interrupt<'_, P, 0> {
/// This PIO's interrupt by index.
pub fn irq<const IRQ: usize>(&self) -> Interrupt<'_, P, IRQ> {
struct IRQSanity<const X: usize>;
impl<const IRQ: usize> IRQSanity<IRQ> {
const CHECK: () = assert!(IRQ <= 1, "IRQ index must be either 0 or 1");
}

#[allow(clippy::let_unit_value)]
let _ = IRQSanity::<IRQ>::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.
Expand Down

0 comments on commit cfd6c12

Please sign in to comment.