mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-10-01 06:10:41 +00:00
Merge pull request #4302 from Jacke-debug/get_max_duty_off_by_one
Get max duty off by one for Center-aligned mode
This commit is contained in:
commit
7d657ac16b
@ -111,7 +111,11 @@ impl<'d, T: AdvancedInstance4Channel> ComplementaryPwm<'d, T> {
|
||||
///
|
||||
/// This value depends on the configured frequency and the timer's clock rate from RCC.
|
||||
pub fn get_max_duty(&self) -> u16 {
|
||||
self.inner.get_max_compare_value() as u16 + 1
|
||||
if self.inner.get_counting_mode().is_center_aligned() {
|
||||
self.inner.get_max_compare_value() as u16
|
||||
} else {
|
||||
self.inner.get_max_compare_value() as u16 + 1
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the duty for a given channel.
|
||||
@ -161,7 +165,11 @@ impl<'d, T: AdvancedInstance4Channel> embedded_hal_02::Pwm for ComplementaryPwm<
|
||||
}
|
||||
|
||||
fn get_max_duty(&self) -> Self::Duty {
|
||||
self.inner.get_max_compare_value() as u16 + 1
|
||||
if self.inner.get_counting_mode().is_center_aligned() {
|
||||
self.inner.get_max_compare_value() as u16
|
||||
} else {
|
||||
self.inner.get_max_compare_value() as u16 + 1
|
||||
}
|
||||
}
|
||||
|
||||
fn set_duty(&mut self, channel: Self::Channel, duty: Self::Duty) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user