diff options
| author | Adam Greig <[email protected]> | 2023-10-15 00:57:25 +0100 |
|---|---|---|
| committer | Adam Greig <[email protected]> | 2023-10-15 01:30:12 +0100 |
| commit | 0621e957a0ddc7010d46b3ea3ddc8b9852bc8333 (patch) | |
| tree | f6caefe939109e55a73e9141c736d2f6c20f51e8 /examples/stm32g4/src/bin | |
| parent | 7559f9e5834799b041d899767ef4305dcfdf0181 (diff) | |
time: Update examples, tests, and other code to use new Timer::after_x convenience methods
Diffstat (limited to 'examples/stm32g4/src/bin')
| -rw-r--r-- | examples/stm32g4/src/bin/adc.rs | 4 | ||||
| -rw-r--r-- | examples/stm32g4/src/bin/blinky.rs | 6 | ||||
| -rw-r--r-- | examples/stm32g4/src/bin/pll.rs | 4 | ||||
| -rw-r--r-- | examples/stm32g4/src/bin/pwm.rs | 10 |
4 files changed, 12 insertions, 12 deletions
diff --git a/examples/stm32g4/src/bin/adc.rs b/examples/stm32g4/src/bin/adc.rs index 30a112b7e..9daf4e4cb 100644 --- a/examples/stm32g4/src/bin/adc.rs +++ b/examples/stm32g4/src/bin/adc.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_stm32::adc::{Adc, SampleTime}; | 7 | use embassy_stm32::adc::{Adc, SampleTime}; |
| 8 | use embassy_stm32::rcc::{AdcClockSource, ClockSrc, Pll, PllM, PllN, PllR, PllSrc}; | 8 | use embassy_stm32::rcc::{AdcClockSource, ClockSrc, Pll, PllM, PllN, PllR, PllSrc}; |
| 9 | use embassy_stm32::Config; | 9 | use embassy_stm32::Config; |
| 10 | use embassy_time::{Delay, Duration, Timer}; | 10 | use embassy_time::{Delay, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| @@ -36,6 +36,6 @@ async fn main(_spawner: Spawner) { | |||
| 36 | loop { | 36 | loop { |
| 37 | let measured = adc.read(&mut p.PA7); | 37 | let measured = adc.read(&mut p.PA7); |
| 38 | info!("measured: {}", measured); | 38 | info!("measured: {}", measured); |
| 39 | Timer::after(Duration::from_millis(500)).await; | 39 | Timer::after_millis(500).await; |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
diff --git a/examples/stm32g4/src/bin/blinky.rs b/examples/stm32g4/src/bin/blinky.rs index 8a65b0692..cbeb0dee1 100644 --- a/examples/stm32g4/src/bin/blinky.rs +++ b/examples/stm32g4/src/bin/blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| @@ -18,10 +18,10 @@ async fn main(_spawner: Spawner) { | |||
| 18 | loop { | 18 | loop { |
| 19 | info!("high"); | 19 | info!("high"); |
| 20 | led.set_high(); | 20 | led.set_high(); |
| 21 | Timer::after(Duration::from_millis(300)).await; | 21 | Timer::after_millis(300).await; |
| 22 | 22 | ||
| 23 | info!("low"); | 23 | info!("low"); |
| 24 | led.set_low(); | 24 | led.set_low(); |
| 25 | Timer::after(Duration::from_millis(300)).await; | 25 | Timer::after_millis(300).await; |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
diff --git a/examples/stm32g4/src/bin/pll.rs b/examples/stm32g4/src/bin/pll.rs index f8159cb53..43242647f 100644 --- a/examples/stm32g4/src/bin/pll.rs +++ b/examples/stm32g4/src/bin/pll.rs | |||
| @@ -6,7 +6,7 @@ use defmt::*; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rcc::{ClockSrc, Pll, PllM, PllN, PllR, PllSrc}; | 7 | use embassy_stm32::rcc::{ClockSrc, Pll, PllM, PllN, PllR, PllSrc}; |
| 8 | use embassy_stm32::Config; | 8 | use embassy_stm32::Config; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| @@ -29,7 +29,7 @@ async fn main(_spawner: Spawner) { | |||
| 29 | info!("Hello World!"); | 29 | info!("Hello World!"); |
| 30 | 30 | ||
| 31 | loop { | 31 | loop { |
| 32 | Timer::after(Duration::from_millis(1000)).await; | 32 | Timer::after_millis(1000).await; |
| 33 | info!("1s elapsed"); | 33 | info!("1s elapsed"); |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
diff --git a/examples/stm32g4/src/bin/pwm.rs b/examples/stm32g4/src/bin/pwm.rs index 01e9cb476..eed0b6ad7 100644 --- a/examples/stm32g4/src/bin/pwm.rs +++ b/examples/stm32g4/src/bin/pwm.rs | |||
| @@ -8,7 +8,7 @@ use embassy_stm32::gpio::OutputType; | |||
| 8 | use embassy_stm32::time::khz; | 8 | use embassy_stm32::time::khz; |
| 9 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 9 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 10 | use embassy_stm32::timer::Channel; | 10 | use embassy_stm32::timer::Channel; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | #[embassy_executor::main] | 14 | #[embassy_executor::main] |
| @@ -26,12 +26,12 @@ async fn main(_spawner: Spawner) { | |||
| 26 | 26 | ||
| 27 | loop { | 27 | loop { |
| 28 | pwm.set_duty(Channel::Ch1, 0); | 28 | pwm.set_duty(Channel::Ch1, 0); |
| 29 | Timer::after(Duration::from_millis(300)).await; | 29 | Timer::after_millis(300).await; |
| 30 | pwm.set_duty(Channel::Ch1, max / 4); | 30 | pwm.set_duty(Channel::Ch1, max / 4); |
| 31 | Timer::after(Duration::from_millis(300)).await; | 31 | Timer::after_millis(300).await; |
| 32 | pwm.set_duty(Channel::Ch1, max / 2); | 32 | pwm.set_duty(Channel::Ch1, max / 2); |
| 33 | Timer::after(Duration::from_millis(300)).await; | 33 | Timer::after_millis(300).await; |
| 34 | pwm.set_duty(Channel::Ch1, max - 1); | 34 | pwm.set_duty(Channel::Ch1, max - 1); |
| 35 | Timer::after(Duration::from_millis(300)).await; | 35 | Timer::after_millis(300).await; |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
