commit
681393150d
1 changed files with 8 additions and 1 deletions
|
@ -736,6 +736,11 @@ impl<'d, T: Instance> SimplePwm<'d, T> {
|
||||||
r.enable.write(|w| w.enable().disabled());
|
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.
|
/// Sets duty cycle (15 bit) for a PWM channel.
|
||||||
pub fn set_duty(&mut self, channel: usize, duty: u16) {
|
pub fn set_duty(&mut self, channel: usize, duty: u16) {
|
||||||
let r = T::regs();
|
let r = T::regs();
|
||||||
|
@ -755,7 +760,9 @@ impl<'d, T: Instance> SimplePwm<'d, T> {
|
||||||
|
|
||||||
// defensive wait until waveform is loaded after seqstart so set_duty
|
// defensive wait until waveform is loaded after seqstart so set_duty
|
||||||
// can't be called again while dma is still reading
|
// can't be called again while dma is still reading
|
||||||
while r.events_seqend[0].read().bits() == 0 {}
|
if self.is_enabled() {
|
||||||
|
while r.events_seqend[0].read().bits() == 0 {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the PWM clock prescaler.
|
/// Sets the PWM clock prescaler.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue