diff options
| author | Grant Miller <[email protected]> | 2024-09-06 14:01:10 -0500 |
|---|---|---|
| committer | Grant Miller <[email protected]> | 2024-09-06 14:01:10 -0500 |
| commit | 71e49839fc350c19c2fd7eebda0fe76afbfdb157 (patch) | |
| tree | 27919782db237059eb6b76da5f82de2d37aeb795 /embassy-stm32 | |
| parent | 1a8977db7837a5635d3c5e0ae8213d1b3181ffb7 (diff) | |
oops
Diffstat (limited to 'embassy-stm32')
| -rw-r--r-- | embassy-stm32/src/timer/simple_pwm.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/embassy-stm32/src/timer/simple_pwm.rs b/embassy-stm32/src/timer/simple_pwm.rs index 23c727731..885abd23f 100644 --- a/embassy-stm32/src/timer/simple_pwm.rs +++ b/embassy-stm32/src/timer/simple_pwm.rs | |||
| @@ -82,7 +82,9 @@ impl<'d, T: GeneralInstance4Channel> SimplePwmChannel<'d, T> { | |||
| 82 | /// | 82 | /// |
| 83 | /// This value depends on the configured frequency and the timer's clock rate from RCC. | 83 | /// This value depends on the configured frequency and the timer's clock rate from RCC. |
| 84 | pub fn max_duty_cycle(&self) -> u16 { | 84 | pub fn max_duty_cycle(&self) -> u16 { |
| 85 | unwrap!(self.timer.get_max_compare_value().checked_add(1)) | 85 | let max = self.timer.get_max_compare_value(); |
| 86 | assert!(max < u16::MAX as u32); | ||
| 87 | max as u16 + 1 | ||
| 86 | } | 88 | } |
| 87 | 89 | ||
| 88 | /// Set the duty for a given channel. | 90 | /// Set the duty for a given channel. |
| @@ -269,7 +271,9 @@ impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T> { | |||
| 269 | /// | 271 | /// |
| 270 | /// This value depends on the configured frequency and the timer's clock rate from RCC. | 272 | /// This value depends on the configured frequency and the timer's clock rate from RCC. |
| 271 | pub fn max_duty_cycle(&self) -> u16 { | 273 | pub fn max_duty_cycle(&self) -> u16 { |
| 272 | unwrap!(self.inner.get_max_compare_value().checked_add(1)) | 274 | let max = self.inner.get_max_compare_value(); |
| 275 | assert!(max < u16::MAX as u32); | ||
| 276 | max as u16 + 1 | ||
| 273 | } | 277 | } |
| 274 | 278 | ||
| 275 | /// Generate a sequence of PWM waveform | 279 | /// Generate a sequence of PWM waveform |
