diff options
Diffstat (limited to 'embassy-stm32/src/timer/complementary_pwm.rs')
| -rw-r--r-- | embassy-stm32/src/timer/complementary_pwm.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/embassy-stm32/src/timer/complementary_pwm.rs b/embassy-stm32/src/timer/complementary_pwm.rs index 77f19a37b..d194899c6 100644 --- a/embassy-stm32/src/timer/complementary_pwm.rs +++ b/embassy-stm32/src/timer/complementary_pwm.rs | |||
| @@ -178,9 +178,9 @@ impl<'d, T: AdvancedInstance4Channel> ComplementaryPwm<'d, T> { | |||
| 178 | /// This value depends on the configured frequency and the timer's clock rate from RCC. | 178 | /// This value depends on the configured frequency and the timer's clock rate from RCC. |
| 179 | pub fn get_max_duty(&self) -> u16 { | 179 | pub fn get_max_duty(&self) -> u16 { |
| 180 | if self.inner.get_counting_mode().is_center_aligned() { | 180 | if self.inner.get_counting_mode().is_center_aligned() { |
| 181 | self.inner.get_max_compare_value() as u16 | 181 | unwrap!(self.inner.get_max_compare_value().try_into()) |
| 182 | } else { | 182 | } else { |
| 183 | self.inner.get_max_compare_value() as u16 + 1 | 183 | unwrap!(self.inner.get_max_compare_value().try_into()) + 1 |
| 184 | } | 184 | } |
| 185 | } | 185 | } |
| 186 | 186 | ||
| @@ -189,7 +189,7 @@ impl<'d, T: AdvancedInstance4Channel> ComplementaryPwm<'d, T> { | |||
| 189 | /// The value ranges from 0 for 0% duty, to [`get_max_duty`](Self::get_max_duty) for 100% duty, both included. | 189 | /// The value ranges from 0 for 0% duty, to [`get_max_duty`](Self::get_max_duty) for 100% duty, both included. |
| 190 | pub fn set_duty(&mut self, channel: Channel, duty: u16) { | 190 | pub fn set_duty(&mut self, channel: Channel, duty: u16) { |
| 191 | assert!(duty <= self.get_max_duty()); | 191 | assert!(duty <= self.get_max_duty()); |
| 192 | self.inner.set_compare_value(channel, duty as _) | 192 | self.inner.set_compare_value(channel, duty.into()) |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | /// Set the output polarity for a given channel. | 195 | /// Set the output polarity for a given channel. |
| @@ -220,7 +220,7 @@ impl<'d, T: AdvancedInstance4Channel> ComplementaryPwm<'d, T> { | |||
| 220 | /// | 220 | /// |
| 221 | /// Note: | 221 | /// Note: |
| 222 | /// you will need to provide corresponding TIMx_UP DMA channel to use this method. | 222 | /// you will need to provide corresponding TIMx_UP DMA channel to use this method. |
| 223 | pub async fn waveform_up(&mut self, dma: Peri<'_, impl super::UpDma<T>>, channel: Channel, duty: &[u16]) { | 223 | pub async fn waveform_up(&mut self, dma: Peri<'_, impl super::UpDma<T>>, channel: Channel, duty: &[T::Word]) { |
| 224 | self.inner.enable_channel(channel, true); | 224 | self.inner.enable_channel(channel, true); |
| 225 | self.inner.enable_update_dma(true); | 225 | self.inner.enable_update_dma(true); |
| 226 | self.inner.setup_update_dma(dma, channel, duty).await; | 226 | self.inner.setup_update_dma(dma, channel, duty).await; |
| @@ -261,7 +261,7 @@ impl<'d, T: AdvancedInstance4Channel> ComplementaryPwm<'d, T> { | |||
| 261 | dma: Peri<'_, impl super::UpDma<T>>, | 261 | dma: Peri<'_, impl super::UpDma<T>>, |
| 262 | starting_channel: Channel, | 262 | starting_channel: Channel, |
| 263 | ending_channel: Channel, | 263 | ending_channel: Channel, |
| 264 | duty: &[u16], | 264 | duty: &[T::Word], |
| 265 | ) { | 265 | ) { |
| 266 | self.inner.enable_update_dma(true); | 266 | self.inner.enable_update_dma(true); |
| 267 | self.inner | 267 | self.inner |
| @@ -291,20 +291,20 @@ impl<'d, T: AdvancedInstance4Channel> embedded_hal_02::Pwm for ComplementaryPwm< | |||
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | fn get_duty(&self, channel: Self::Channel) -> Self::Duty { | 293 | fn get_duty(&self, channel: Self::Channel) -> Self::Duty { |
| 294 | self.inner.get_compare_value(channel) as u16 | 294 | unwrap!(self.inner.get_compare_value(channel).try_into()) |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | fn get_max_duty(&self) -> Self::Duty { | 297 | fn get_max_duty(&self) -> Self::Duty { |
| 298 | if self.inner.get_counting_mode().is_center_aligned() { | 298 | if self.inner.get_counting_mode().is_center_aligned() { |
| 299 | self.inner.get_max_compare_value() as u16 | 299 | unwrap!(self.inner.get_max_compare_value().try_into()) |
| 300 | } else { | 300 | } else { |
| 301 | self.inner.get_max_compare_value() as u16 + 1 | 301 | unwrap!(self.inner.get_max_compare_value().try_into()) + 1 |
| 302 | } | 302 | } |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | fn set_duty(&mut self, channel: Self::Channel, duty: Self::Duty) { | 305 | fn set_duty(&mut self, channel: Self::Channel, duty: Self::Duty) { |
| 306 | assert!(duty <= self.get_max_duty()); | 306 | assert!(duty <= self.get_max_duty()); |
| 307 | self.inner.set_compare_value(channel, duty as u32) | 307 | self.inner.set_compare_value(channel, unwrap!(duty.try_into())) |
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | fn set_period<P>(&mut self, period: P) | 310 | fn set_period<P>(&mut self, period: P) |
