diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-07-28 22:44:03 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-07-28 22:44:03 +0000 |
| commit | bdc4aa4a3beeeecb9860644f8421bba6c8ab0cf2 (patch) | |
| tree | 593ede68752ae7bae4ccf2302c3082622bf74d06 /examples/stm32f334/src/bin/button.rs | |
| parent | cc414e63d3b7aec7da07d9097cf8a78b5d55a73a (diff) | |
| parent | 5bb5654d847b8d7a15f242d4b4078369a1b7285f (diff) | |
Merge pull request #1582 from xoviat/hrtim
Add the high resolution timer
Diffstat (limited to 'examples/stm32f334/src/bin/button.rs')
| -rw-r--r-- | examples/stm32f334/src/bin/button.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/stm32f334/src/bin/button.rs b/examples/stm32f334/src/bin/button.rs new file mode 100644 index 000000000..599c0f27d --- /dev/null +++ b/examples/stm32f334/src/bin/button.rs | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 8 | use embassy_time::{Duration, Timer}; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | ||
| 10 | |||
| 11 | #[embassy_executor::main] | ||
| 12 | async fn main(_spawner: Spawner) { | ||
| 13 | info!("Hello World!"); | ||
| 14 | |||
| 15 | let p = embassy_stm32::init(Default::default()); | ||
| 16 | |||
| 17 | let mut out1 = Output::new(p.PA8, Level::Low, Speed::High); | ||
| 18 | |||
| 19 | out1.set_high(); | ||
| 20 | Timer::after(Duration::from_millis(500)).await; | ||
| 21 | out1.set_low(); | ||
| 22 | |||
| 23 | Timer::after(Duration::from_millis(500)).await; | ||
| 24 | info!("end program"); | ||
| 25 | |||
| 26 | cortex_m::asm::bkpt(); | ||
| 27 | } | ||
