diff options
Diffstat (limited to 'docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs')
| -rw-r--r-- | docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs new file mode 100644 index 000000000..35726be64 --- /dev/null +++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt_rtt as _; | ||
| 6 | use panic_probe as _; | ||
| 7 | |||
| 8 | use embassy::executor::Spawner; | ||
| 9 | use embassy_stm32::{ | ||
| 10 | exti::ExtiInput, | ||
| 11 | gpio::{Input, Level, Output, Pull, Speed}, | ||
| 12 | Peripherals, | ||
| 13 | }; | ||
| 14 | |||
| 15 | #[embassy::main] | ||
| 16 | async fn main(_s: Spawner, p: Peripherals) { | ||
| 17 | let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh); | ||
| 18 | let mut button = ExtiInput::new(Input::new(p.PC13, Pull::Up), p.EXTI13); | ||
| 19 | |||
| 20 | loop { | ||
| 21 | button.wait_for_any_edge().await; | ||
| 22 | if button.is_low() { | ||
| 23 | led.set_high(); | ||
| 24 | } else { | ||
| 25 | led.set_low(); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | ||
