From 667a93b5c89c1d71077ef6a8d58a35621d9f498a Mon Sep 17 00:00:00 2001 From: Jacob Rosenthal Date: Thu, 11 Nov 2021 23:46:27 -0700 Subject: [PATCH] sequence pwm remove disable fn for clarity, and disable peripheral on stop --- embassy-nrf/src/pwm.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs index 9a5659cc..3301093f 100644 --- a/embassy-nrf/src/pwm.rs +++ b/embassy-nrf/src/pwm.rs @@ -102,9 +102,6 @@ impl<'d, T: Instance> SequencePwm<'d, T> { r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) }); r.shorts.reset(); - // Enable - r.enable.write(|w| w.enable().enabled()); - r.seq0 .ptr .write(|w| unsafe { w.bits(sequence.as_ptr() as u32) }); @@ -208,6 +205,8 @@ impl<'d, T: Instance> SequencePwm<'d, T> { pub fn stop(&self) { let r = T::regs(); + r.enable.write(|w| w.enable().disabled()); + r.shorts.reset(); compiler_fence(Ordering::SeqCst); @@ -215,13 +214,6 @@ impl<'d, T: Instance> SequencePwm<'d, T> { // tasks_stop() doesn't exist in all svds so write its bit instead r.tasks_stop.write(|w| unsafe { w.bits(0x01) }); } - - /// Disables the PWM generator. - #[inline(always)] - pub fn disable(&self) { - let r = T::regs(); - r.enable.write(|w| w.enable().disabled()); - } } impl<'a, T: Instance> Drop for SequencePwm<'a, T> { @@ -229,7 +221,6 @@ impl<'a, T: Instance> Drop for SequencePwm<'a, T> { let r = T::regs(); self.stop(); - self.disable(); if let Some(pin) = &self.ch0 { pin.set_low();