From b8beaba6df08c4455f55780a6e13191d95ad9eec Mon Sep 17 00:00:00 2001 From: Grant Miller Date: Fri, 6 Sep 2024 15:08:58 -0500 Subject: [PATCH] last oops I promise --- embassy-stm32/src/timer/simple_pwm.rs | 6 +++--- examples/stm32f4/src/bin/pwm.rs | 3 +-- examples/stm32f4/src/bin/ws2812_pwm.rs | 2 +- examples/stm32g0/src/bin/pwm_input.rs | 1 - examples/stm32g4/src/bin/pwm.rs | 3 +-- examples/stm32h7/src/bin/pwm.rs | 5 ++--- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/embassy-stm32/src/timer/simple_pwm.rs b/embassy-stm32/src/timer/simple_pwm.rs index 47188053c..7e2e9c202 100644 --- a/embassy-stm32/src/timer/simple_pwm.rs +++ b/embassy-stm32/src/timer/simple_pwm.rs @@ -129,7 +129,7 @@ impl<'d, T: GeneralInstance4Channel> SimplePwmChannel<'d, T> { /// Get the duty for a given channel. /// /// The value ranges from 0 for 0% duty, to [`max_duty_cycle`](Self::max_duty_cycle) for 100% duty, both included. - pub fn get_duty(&self) -> u16 { + pub fn current_duty_cycle(&self) -> u16 { unwrap!(self.timer.get_compare_value(self.channel).try_into()) } @@ -300,7 +300,7 @@ impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T> { #[allow(clippy::let_unit_value)] // eg. stm32f334 let req = dma.request(); - let original_duty_state = self.channel(channel).get_duty(); + let original_duty_state = self.channel(channel).current_duty_cycle(); let original_enable_state = self.channel(channel).is_enabled(); let original_update_dma_state = self.inner.get_update_dma_state(); @@ -370,7 +370,7 @@ macro_rules! impl_waveform_chx { let cc_channel = Channel::$cc_ch; - let original_duty_state = self.channel(cc_channel).get_duty(); + let original_duty_state = self.channel(cc_channel).current_duty_cycle(); let original_enable_state = self.channel(cc_channel).is_enabled(); let original_cc_dma_on_update = self.inner.get_cc_dma_selection() == Ccds::ONUPDATE; let original_cc_dma_enabled = self.inner.get_cc_dma_enable_state(cc_channel); diff --git a/examples/stm32f4/src/bin/pwm.rs b/examples/stm32f4/src/bin/pwm.rs index 0cd65a258..04811162b 100644 --- a/examples/stm32f4/src/bin/pwm.rs +++ b/examples/stm32f4/src/bin/pwm.rs @@ -6,7 +6,6 @@ use embassy_executor::Spawner; use embassy_stm32::gpio::OutputType; use embassy_stm32::time::khz; use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; -use embassy_stm32::timer::Channel; use embassy_time::Timer; use {defmt_rtt as _, panic_probe as _}; @@ -28,7 +27,7 @@ async fn main(_spawner: Spawner) { Timer::after_millis(300).await; ch1.set_duty_cycle_fraction(1, 4); Timer::after_millis(300).await; - ch1.set_dutycycle_fraction(1, 2); + ch1.set_duty_cycle_fraction(1, 2); Timer::after_millis(300).await; ch1.set_duty_cycle(ch1.max_duty_cycle() - 1); Timer::after_millis(300).await; diff --git a/examples/stm32f4/src/bin/ws2812_pwm.rs b/examples/stm32f4/src/bin/ws2812_pwm.rs index 7a9fa302b..3ab93d6e0 100644 --- a/examples/stm32f4/src/bin/ws2812_pwm.rs +++ b/examples/stm32f4/src/bin/ws2812_pwm.rs @@ -84,7 +84,7 @@ async fn main(_spawner: Spawner) { let pwm_channel = Channel::Ch1; // make sure PWM output keep low on first start - ws2812_pwm.channel(pwm_channel).set_duty(0); + ws2812_pwm.channel(pwm_channel).set_duty_cycle(0); // flip color at 2 Hz let mut ticker = Ticker::every(Duration::from_millis(500)); diff --git a/examples/stm32g0/src/bin/pwm_input.rs b/examples/stm32g0/src/bin/pwm_input.rs index 983705e2f..db9cf4f8a 100644 --- a/examples/stm32g0/src/bin/pwm_input.rs +++ b/examples/stm32g0/src/bin/pwm_input.rs @@ -14,7 +14,6 @@ use embassy_stm32::gpio::{Level, Output, OutputType, Pull, Speed}; use embassy_stm32::time::khz; use embassy_stm32::timer::pwm_input::PwmInput; use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; -use embassy_stm32::timer::Channel; use embassy_stm32::{bind_interrupts, peripherals, timer}; use embassy_time::Timer; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32g4/src/bin/pwm.rs b/examples/stm32g4/src/bin/pwm.rs index 3833be58f..6c965012c 100644 --- a/examples/stm32g4/src/bin/pwm.rs +++ b/examples/stm32g4/src/bin/pwm.rs @@ -6,7 +6,6 @@ use embassy_executor::Spawner; use embassy_stm32::gpio::OutputType; use embassy_stm32::time::khz; use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; -use embassy_stm32::timer::Channel; use embassy_time::Timer; use {defmt_rtt as _, panic_probe as _}; @@ -28,7 +27,7 @@ async fn main(_spawner: Spawner) { Timer::after_millis(300).await; ch1.set_duty_cycle_fraction(1, 4); Timer::after_millis(300).await; - ch1.set_dutycycle_fraction(1, 2); + ch1.set_duty_cycle_fraction(1, 2); Timer::after_millis(300).await; ch1.set_duty_cycle(ch1.max_duty_cycle() - 1); Timer::after_millis(300).await; diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index 1d0b89e97..a1c53fc3f 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs @@ -6,7 +6,6 @@ use embassy_executor::Spawner; use embassy_stm32::gpio::OutputType; use embassy_stm32::time::khz; use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; -use embassy_stm32::timer::Channel; use embassy_stm32::Config; use embassy_time::Timer; use {defmt_rtt as _, panic_probe as _}; @@ -39,7 +38,7 @@ async fn main(_spawner: Spawner) { let ch1_pin = PwmPin::new_ch1(p.PA6, OutputType::PushPull); let mut pwm = SimplePwm::new(p.TIM3, Some(ch1_pin), None, None, None, khz(10), Default::default()); - let mut ch1 = pwm.ch1; + let mut ch1 = pwm.ch1(); ch1.enable(); info!("PWM initialized"); @@ -50,7 +49,7 @@ async fn main(_spawner: Spawner) { Timer::after_millis(300).await; ch1.set_duty_cycle_fraction(1, 4); Timer::after_millis(300).await; - ch1.set_dutycycle_fraction(1, 2); + ch1.set_duty_cycle_fraction(1, 2); Timer::after_millis(300).await; ch1.set_duty_cycle(ch1.max_duty_cycle() - 1); Timer::after_millis(300).await;