Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PIO IRQ IDs into ZSTs #723

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading