diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-07-23 14:16:51 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-07-23 14:16:51 +0000 |
| commit | 6b8cd6fbb3e4dd23750550c50b301ebba70c443a (patch) | |
| tree | 2b3975074c806fe2c2981b488e8f91be62be3660 /examples | |
| parent | e61e36a8158073ec92df1a751cfdd7fce5004cf8 (diff) | |
| parent | b5ff7c5d60cd5cba905720b4b8f6cb8c73859ca6 (diff) | |
Merge #856
856: embassy-stm32/pwm: Generalize channel selection r=Dirbaio a=bgamari
550da471be7b56927b50b5955a6de0916ebe6b1f previously refactored the STM32
PWM logic in such a way to preclude use of non-contiguous channels (e.g.
channel 2 but not channel 1). Refactor it yet again to yet again allow
this sort of usage.
Co-authored-by: Ben Gamari <[email protected]>
Co-authored-by: Dario Nieuwenhuis <[email protected]>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32f4/src/bin/pwm.rs | 5 | ||||
| -rw-r--r-- | examples/stm32g4/src/bin/pwm.rs | 5 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/pwm.rs | 5 |
3 files changed, 9 insertions, 6 deletions
diff --git a/examples/stm32f4/src/bin/pwm.rs b/examples/stm32f4/src/bin/pwm.rs index c99f3cc26..b39bbbe28 100644 --- a/examples/stm32f4/src/bin/pwm.rs +++ b/examples/stm32f4/src/bin/pwm.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 7 | use embassy::time::{Duration, Timer}; | 7 | use embassy::time::{Duration, Timer}; |
| 8 | use embassy_stm32::pwm::simple_pwm::SimplePwm; | 8 | use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; |
| 9 | use embassy_stm32::pwm::Channel; | 9 | use embassy_stm32::pwm::Channel; |
| 10 | use embassy_stm32::time::khz; | 10 | use embassy_stm32::time::khz; |
| 11 | use embassy_stm32::Peripherals; | 11 | use embassy_stm32::Peripherals; |
| @@ -15,7 +15,8 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 15 | async fn main(_spawner: Spawner, p: Peripherals) { |
| 16 | info!("Hello World!"); | 16 | info!("Hello World!"); |
| 17 | 17 | ||
| 18 | let mut pwm = SimplePwm::new_1ch(p.TIM1, p.PE9, khz(10)); | 18 | let ch1 = PwmPin::new_ch1(p.PE9); |
| 19 | let mut pwm = SimplePwm::new(p.TIM1, Some(ch1), None, None, None, khz(10)); | ||
| 19 | let max = pwm.get_max_duty(); | 20 | let max = pwm.get_max_duty(); |
| 20 | pwm.enable(Channel::Ch1); | 21 | pwm.enable(Channel::Ch1); |
| 21 | 22 | ||
diff --git a/examples/stm32g4/src/bin/pwm.rs b/examples/stm32g4/src/bin/pwm.rs index 579e289b0..dc4e164ab 100644 --- a/examples/stm32g4/src/bin/pwm.rs +++ b/examples/stm32g4/src/bin/pwm.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 7 | use embassy::time::{Duration, Timer}; | 7 | use embassy::time::{Duration, Timer}; |
| 8 | use embassy_stm32::pwm::simple_pwm::SimplePwm; | 8 | use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; |
| 9 | use embassy_stm32::pwm::Channel; | 9 | use embassy_stm32::pwm::Channel; |
| 10 | use embassy_stm32::time::khz; | 10 | use embassy_stm32::time::khz; |
| 11 | use embassy_stm32::Peripherals; | 11 | use embassy_stm32::Peripherals; |
| @@ -15,7 +15,8 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 15 | async fn main(_spawner: Spawner, p: Peripherals) { |
| 16 | info!("Hello World!"); | 16 | info!("Hello World!"); |
| 17 | 17 | ||
| 18 | let mut pwm = SimplePwm::new_1ch(p.TIM2, p.PA5, khz(10)); | 18 | let ch1 = PwmPin::new_ch1(p.PA5); |
| 19 | let mut pwm = SimplePwm::new(p.TIM2, Some(ch1), None, None, None, khz(10)); | ||
| 19 | let max = pwm.get_max_duty(); | 20 | let max = pwm.get_max_duty(); |
| 20 | pwm.enable(Channel::Ch1); | 21 | pwm.enable(Channel::Ch1); |
| 21 | 22 | ||
diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index f072c5375..730f637e9 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 7 | use embassy::time::{Duration, Timer}; | 7 | use embassy::time::{Duration, Timer}; |
| 8 | use embassy_stm32::pwm::simple_pwm::SimplePwm; | 8 | use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; |
| 9 | use embassy_stm32::pwm::Channel; | 9 | use embassy_stm32::pwm::Channel; |
| 10 | use embassy_stm32::time::{khz, mhz}; | 10 | use embassy_stm32::time::{khz, mhz}; |
| 11 | use embassy_stm32::{Config, Peripherals}; | 11 | use embassy_stm32::{Config, Peripherals}; |
| @@ -27,7 +27,8 @@ pub fn config() -> Config { | |||
| 27 | async fn main(_spawner: Spawner, p: Peripherals) { | 27 | async fn main(_spawner: Spawner, p: Peripherals) { |
| 28 | info!("Hello World!"); | 28 | info!("Hello World!"); |
| 29 | 29 | ||
| 30 | let mut pwm = SimplePwm::new_1ch(p.TIM3, p.PA6, khz(10)); | 30 | let ch1 = PwmPin::new_ch1(p.PA6); |
| 31 | let mut pwm = SimplePwm::new(p.TIM3, Some(ch1), None, None, None, khz(10)); | ||
| 31 | let max = pwm.get_max_duty(); | 32 | let max = pwm.get_max_duty(); |
| 32 | pwm.enable(Channel::Ch1); | 33 | pwm.enable(Channel::Ch1); |
| 33 | 34 | ||
