From b08a0955c3d6e66c0163508e86f9dc7e40e142d3 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler <martin.marmsoler@gmail.com> Date: Sat, 27 Jan 2024 18:19:56 +0100 Subject: [PATCH] implement retriving duty. Description: When disabling the pwm and enabling again, it is required to restart the sequence. If the previous duty is not known, it is not possible to turn on the pwm again --- embassy-nrf/src/pwm.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs index 856e12024..90aeb09c0 100644 --- a/embassy-nrf/src/pwm.rs +++ b/embassy-nrf/src/pwm.rs @@ -736,6 +736,11 @@ impl<'d, T: Instance> SimplePwm<'d, T> { r.enable.write(|w| w.enable().disabled()); } + /// Returns the current duty of the channel + pub fn duty(&self, channel: usize) -> u16 { + self.duty[channel] + } + /// Sets duty cycle (15 bit) for a PWM channel. pub fn set_duty(&mut self, channel: usize, duty: u16) { let r = T::regs();