diff options
| author | Martin Marmsoler <[email protected]> | 2024-01-27 18:19:56 +0100 |
|---|---|---|
| committer | Martin Marmsoler <[email protected]> | 2024-01-27 18:21:40 +0100 |
| commit | b08a0955c3d6e66c0163508e86f9dc7e40e142d3 (patch) | |
| tree | d95747c642c2f5cd38fd09222edf1713a16ccb87 /embassy-nrf/src | |
| parent | 702007f68b31718d0bea5af403c4c0a299fb6b6e (diff) | |
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
Diffstat (limited to 'embassy-nrf/src')
| -rw-r--r-- | embassy-nrf/src/pwm.rs | 5 |
1 files changed, 5 insertions, 0 deletions
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> { | |||
| 736 | r.enable.write(|w| w.enable().disabled()); | 736 | r.enable.write(|w| w.enable().disabled()); |
| 737 | } | 737 | } |
| 738 | 738 | ||
| 739 | /// Returns the current duty of the channel | ||
| 740 | pub fn duty(&self, channel: usize) -> u16 { | ||
| 741 | self.duty[channel] | ||
| 742 | } | ||
| 743 | |||
| 739 | /// Sets duty cycle (15 bit) for a PWM channel. | 744 | /// Sets duty cycle (15 bit) for a PWM channel. |
| 740 | pub fn set_duty(&mut self, channel: usize, duty: u16) { | 745 | pub fn set_duty(&mut self, channel: usize, duty: u16) { |
| 741 | let r = T::regs(); | 746 | let r = T::regs(); |
