diff options
| -rw-r--r-- | embassy-stm32/src/timer/simple_pwm.rs | 6 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/pwm.rs | 3 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/ws2812_pwm.rs | 2 | ||||
| -rw-r--r-- | examples/stm32g0/src/bin/pwm_input.rs | 1 | ||||
| -rw-r--r-- | examples/stm32g4/src/bin/pwm.rs | 3 | ||||
| -rw-r--r-- | 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> { | |||
| 129 | /// Get the duty for a given channel. | 129 | /// Get the duty for a given channel. |
| 130 | /// | 130 | /// |
| 131 | /// The value ranges from 0 for 0% duty, to [`max_duty_cycle`](Self::max_duty_cycle) for 100% duty, both included. | 131 | /// The value ranges from 0 for 0% duty, to [`max_duty_cycle`](Self::max_duty_cycle) for 100% duty, both included. |
| 132 | pub fn get_duty(&self) -> u16 { | 132 | pub fn current_duty_cycle(&self) -> u16 { |
| 133 | unwrap!(self.timer.get_compare_value(self.channel).try_into()) | 133 | unwrap!(self.timer.get_compare_value(self.channel).try_into()) |
| 134 | } | 134 | } |
| 135 | 135 | ||
| @@ -300,7 +300,7 @@ impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T> { | |||
| 300 | #[allow(clippy::let_unit_value)] // eg. stm32f334 | 300 | #[allow(clippy::let_unit_value)] // eg. stm32f334 |
| 301 | let req = dma.request(); | 301 | let req = dma.request(); |
| 302 | 302 | ||
| 303 | let original_duty_state = self.channel(channel).get_duty(); | 303 | let original_duty_state = self.channel(channel).current_duty_cycle(); |
| 304 | let original_enable_state = self.channel(channel).is_enabled(); | 304 | let original_enable_state = self.channel(channel).is_enabled(); |
| 305 | let original_update_dma_state = self.inner.get_update_dma_state(); | 305 | let original_update_dma_state = self.inner.get_update_dma_state(); |
| 306 | 306 | ||
| @@ -370,7 +370,7 @@ macro_rules! impl_waveform_chx { | |||
| 370 | 370 | ||
| 371 | let cc_channel = Channel::$cc_ch; | 371 | let cc_channel = Channel::$cc_ch; |
| 372 | 372 | ||
| 373 | let original_duty_state = self.channel(cc_channel).get_duty(); | 373 | let original_duty_state = self.channel(cc_channel).current_duty_cycle(); |
| 374 | let original_enable_state = self.channel(cc_channel).is_enabled(); | 374 | let original_enable_state = self.channel(cc_channel).is_enabled(); |
| 375 | let original_cc_dma_on_update = self.inner.get_cc_dma_selection() == Ccds::ONUPDATE; | 375 | let original_cc_dma_on_update = self.inner.get_cc_dma_selection() == Ccds::ONUPDATE; |
| 376 | let original_cc_dma_enabled = self.inner.get_cc_dma_enable_state(cc_channel); | 376 | 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; | |||
| 6 | use embassy_stm32::gpio::OutputType; | 6 | use embassy_stm32::gpio::OutputType; |
| 7 | use embassy_stm32::time::khz; | 7 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 8 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 9 | use embassy_stm32::timer::Channel; | ||
| 10 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| @@ -28,7 +27,7 @@ async fn main(_spawner: Spawner) { | |||
| 28 | Timer::after_millis(300).await; | 27 | Timer::after_millis(300).await; |
| 29 | ch1.set_duty_cycle_fraction(1, 4); | 28 | ch1.set_duty_cycle_fraction(1, 4); |
| 30 | Timer::after_millis(300).await; | 29 | Timer::after_millis(300).await; |
| 31 | ch1.set_dutycycle_fraction(1, 2); | 30 | ch1.set_duty_cycle_fraction(1, 2); |
| 32 | Timer::after_millis(300).await; | 31 | Timer::after_millis(300).await; |
| 33 | ch1.set_duty_cycle(ch1.max_duty_cycle() - 1); | 32 | ch1.set_duty_cycle(ch1.max_duty_cycle() - 1); |
| 34 | Timer::after_millis(300).await; | 33 | 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) { | |||
| 84 | let pwm_channel = Channel::Ch1; | 84 | let pwm_channel = Channel::Ch1; |
| 85 | 85 | ||
| 86 | // make sure PWM output keep low on first start | 86 | // make sure PWM output keep low on first start |
| 87 | ws2812_pwm.channel(pwm_channel).set_duty(0); | 87 | ws2812_pwm.channel(pwm_channel).set_duty_cycle(0); |
| 88 | 88 | ||
| 89 | // flip color at 2 Hz | 89 | // flip color at 2 Hz |
| 90 | let mut ticker = Ticker::every(Duration::from_millis(500)); | 90 | 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}; | |||
| 14 | use embassy_stm32::time::khz; | 14 | use embassy_stm32::time::khz; |
| 15 | use embassy_stm32::timer::pwm_input::PwmInput; | 15 | use embassy_stm32::timer::pwm_input::PwmInput; |
| 16 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 16 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 17 | use embassy_stm32::timer::Channel; | ||
| 18 | use embassy_stm32::{bind_interrupts, peripherals, timer}; | 17 | use embassy_stm32::{bind_interrupts, peripherals, timer}; |
| 19 | use embassy_time::Timer; | 18 | use embassy_time::Timer; |
| 20 | use {defmt_rtt as _, panic_probe as _}; | 19 | 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; | |||
| 6 | use embassy_stm32::gpio::OutputType; | 6 | use embassy_stm32::gpio::OutputType; |
| 7 | use embassy_stm32::time::khz; | 7 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 8 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 9 | use embassy_stm32::timer::Channel; | ||
| 10 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| @@ -28,7 +27,7 @@ async fn main(_spawner: Spawner) { | |||
| 28 | Timer::after_millis(300).await; | 27 | Timer::after_millis(300).await; |
| 29 | ch1.set_duty_cycle_fraction(1, 4); | 28 | ch1.set_duty_cycle_fraction(1, 4); |
| 30 | Timer::after_millis(300).await; | 29 | Timer::after_millis(300).await; |
| 31 | ch1.set_dutycycle_fraction(1, 2); | 30 | ch1.set_duty_cycle_fraction(1, 2); |
| 32 | Timer::after_millis(300).await; | 31 | Timer::after_millis(300).await; |
| 33 | ch1.set_duty_cycle(ch1.max_duty_cycle() - 1); | 32 | ch1.set_duty_cycle(ch1.max_duty_cycle() - 1); |
| 34 | Timer::after_millis(300).await; | 33 | 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; | |||
| 6 | use embassy_stm32::gpio::OutputType; | 6 | use embassy_stm32::gpio::OutputType; |
| 7 | use embassy_stm32::time::khz; | 7 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 8 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 9 | use embassy_stm32::timer::Channel; | ||
| 10 | use embassy_stm32::Config; | 9 | use embassy_stm32::Config; |
| 11 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -39,7 +38,7 @@ async fn main(_spawner: Spawner) { | |||
| 39 | 38 | ||
| 40 | let ch1_pin = PwmPin::new_ch1(p.PA6, OutputType::PushPull); | 39 | let ch1_pin = PwmPin::new_ch1(p.PA6, OutputType::PushPull); |
| 41 | let mut pwm = SimplePwm::new(p.TIM3, Some(ch1_pin), None, None, None, khz(10), Default::default()); | 40 | let mut pwm = SimplePwm::new(p.TIM3, Some(ch1_pin), None, None, None, khz(10), Default::default()); |
| 42 | let mut ch1 = pwm.ch1; | 41 | let mut ch1 = pwm.ch1(); |
| 43 | ch1.enable(); | 42 | ch1.enable(); |
| 44 | 43 | ||
| 45 | info!("PWM initialized"); | 44 | info!("PWM initialized"); |
| @@ -50,7 +49,7 @@ async fn main(_spawner: Spawner) { | |||
| 50 | Timer::after_millis(300).await; | 49 | Timer::after_millis(300).await; |
| 51 | ch1.set_duty_cycle_fraction(1, 4); | 50 | ch1.set_duty_cycle_fraction(1, 4); |
| 52 | Timer::after_millis(300).await; | 51 | Timer::after_millis(300).await; |
| 53 | ch1.set_dutycycle_fraction(1, 2); | 52 | ch1.set_duty_cycle_fraction(1, 2); |
| 54 | Timer::after_millis(300).await; | 53 | Timer::after_millis(300).await; |
| 55 | ch1.set_duty_cycle(ch1.max_duty_cycle() - 1); | 54 | ch1.set_duty_cycle(ch1.max_duty_cycle() - 1); |
| 56 | Timer::after_millis(300).await; | 55 | Timer::after_millis(300).await; |
