diff options
| author | Ulf Lilleengen <[email protected]> | 2024-05-18 10:17:03 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2024-05-21 10:05:21 +0200 |
| commit | 739e5861c2e47db251725163fcd91cd822cf97b7 (patch) | |
| tree | 947dc7961ca7c42ec216056fc2adf616ab812b10 /docs/examples/layer-by-layer/blinky-async/src/main.rs | |
| parent | 51d553092550059afb22b2620cea14bbed21abff (diff) | |
convert from antora to asciidoctor
Diffstat (limited to 'docs/examples/layer-by-layer/blinky-async/src/main.rs')
| -rw-r--r-- | docs/examples/layer-by-layer/blinky-async/src/main.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/examples/layer-by-layer/blinky-async/src/main.rs b/docs/examples/layer-by-layer/blinky-async/src/main.rs new file mode 100644 index 000000000..004602816 --- /dev/null +++ b/docs/examples/layer-by-layer/blinky-async/src/main.rs | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use embassy_executor::Spawner; | ||
| 5 | use embassy_stm32::exti::ExtiInput; | ||
| 6 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; | ||
| 7 | use {defmt_rtt as _, panic_probe as _}; | ||
| 8 | |||
| 9 | #[embassy_executor::main] | ||
| 10 | async fn main(_spawner: Spawner) { | ||
| 11 | let p = embassy_stm32::init(Default::default()); | ||
| 12 | let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh); | ||
| 13 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); | ||
| 14 | |||
| 15 | loop { | ||
| 16 | button.wait_for_any_edge().await; | ||
| 17 | if button.is_low() { | ||
| 18 | led.set_high(); | ||
| 19 | } else { | ||
| 20 | led.set_low(); | ||
| 21 | } | ||
| 22 | } | ||
| 23 | } | ||
