aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEicke Hecht <[email protected]>2025-11-23 23:39:09 +0100
committerEicke Hecht <[email protected]>2025-11-23 23:39:09 +0100
commita227e61137a689ecd875c41a7efb5f2a6bb73876 (patch)
treeef28bf2471d3aa75127b03e922ad251f5a9f8f85
parent1a79bb51bf1490de5cc6f6ad021edd161c088b9f (diff)
fix: Formatting and clippy
-rw-r--r--examples/stm32f7/src/bin/pwm.rs30
1 files changed, 17 insertions, 13 deletions
diff --git a/examples/stm32f7/src/bin/pwm.rs b/examples/stm32f7/src/bin/pwm.rs
index 872d99859..53efc2d8a 100644
--- a/examples/stm32f7/src/bin/pwm.rs
+++ b/examples/stm32f7/src/bin/pwm.rs
@@ -1,15 +1,13 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3
4use defmt::{panic, *}; 4use defmt::*;
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_futures::join::join; 6use embassy_stm32::Config;
7use embassy_stm32::time::Hertz;
8use embassy_stm32::{Config, peripherals};
9use embassy_stm32::gpio::OutputType; 7use embassy_stm32::gpio::OutputType;
8use embassy_stm32::time::Hertz;
10use embassy_stm32::time::mhz; 9use embassy_stm32::time::mhz;
11use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; 10use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm};
12use embassy_time::Timer;
13use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
14 12
15// If you are trying this and your USB device doesn't connect, the most 13// If you are trying this and your USB device doesn't connect, the most
@@ -44,7 +42,15 @@ async fn main(_spawner: Spawner) {
44 let p = embassy_stm32::init(config); 42 let p = embassy_stm32::init(config);
45 let ch1_pin = PwmPin::new(p.PE9, OutputType::PushPull); 43 let ch1_pin = PwmPin::new(p.PE9, OutputType::PushPull);
46 let ch2_pin = PwmPin::new(p.PE11, OutputType::PushPull); 44 let ch2_pin = PwmPin::new(p.PE11, OutputType::PushPull);
47 let mut pwm = SimplePwm::new(p.TIM1, Some(ch1_pin), Some(ch2_pin), None, None, mhz(1), Default::default()); 45 let mut pwm = SimplePwm::new(
46 p.TIM1,
47 Some(ch1_pin),
48 Some(ch2_pin),
49 None,
50 None,
51 mhz(1),
52 Default::default(),
53 );
48 let mut ch1 = pwm.ch1(); 54 let mut ch1 = pwm.ch1();
49 ch1.enable(); 55 ch1.enable();
50 info!("PWM initialized"); 56 info!("PWM initialized");
@@ -53,13 +59,11 @@ async fn main(_spawner: Spawner) {
53 info!("PWM duty on channel 1 (D6) 50%"); 59 info!("PWM duty on channel 1 (D6) 50%");
54 ch1.set_duty_cycle_fraction(1, 2); 60 ch1.set_duty_cycle_fraction(1, 2);
55 info!("PWM waveform on channel 2 (D5)"); 61 info!("PWM waveform on channel 2 (D5)");
56 const max_duty: usize = 200; 62 const MAX_DUTY: usize = 200;
57 let mut duty = [0u16;max_duty]; 63 let mut duty = [0u16; MAX_DUTY];
58 for i in 0..max_duty { 64 for i in 0..MAX_DUTY {
59 duty[i] = i as u16; 65 duty[i] = i as u16;
60 } 66 }
61 pwm.waveform_continuous::<embassy_stm32::timer::Ch2>(p.DMA2_CH6, &duty).await; 67 pwm.waveform_continuous::<embassy_stm32::timer::Ch2>(p.DMA2_CH6, &duty)
62 68 .await;
63
64} 69}
65