From fb693080581b891e36fec178890b7fb6471f0ac2 Mon Sep 17 00:00:00 2001 From: contradict Date: Wed, 27 Oct 2021 08:25:47 -0700 Subject: [PATCH] Add methods to set and clear the PWM Interrupt force register. --- rp2040-hal/src/pwm/mod.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/rp2040-hal/src/pwm/mod.rs b/rp2040-hal/src/pwm/mod.rs index a206e01..6690a66 100644 --- a/rp2040-hal/src/pwm/mod.rs +++ b/rp2040-hal/src/pwm/mod.rs @@ -412,6 +412,28 @@ where pub fn clear_interrupt(&mut self) { unsafe { (*pac::PWM::ptr()).intr.write(|w| w.bits(self.bitmask())) }; } + + /// Force the interrupt. This bit is not cleared by hardware and must be manually cleared to + /// stop the interrupt from continuing to be asserted. + #[inline] + pub fn force_interrupt(&mut self) { + unsafe { + let pwm = &(*pac::PWM::ptr()); + let reg = (&pwm.intf).as_ptr(); + write_bitmask_set(reg, self.bitmask()); + } + } + + /// Clear force interrupt. This bit is not cleared by hardware and must be manually cleared to + /// stop the interrupt from continuing to be asserted. + #[inline] + pub fn clear_force_interrupt(&mut self) { + unsafe { + let pwm = &(*pac::PWM::ptr()); + let reg = (&pwm.intf).as_ptr(); + write_bitmask_clear(reg, self.bitmask()); + } + } } macro_rules! pwm {