aboutsummaryrefslogtreecommitdiff
path: root/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2022-02-23 09:48:32 +0100
committerUlf Lilleengen <[email protected]>2022-02-23 09:48:32 +0100
commit092eef3ae7f90e33564f09fa6a887e8fc9ed88b8 (patch)
tree547db6b7241e749f1cad0285c12124d26de37639 /docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs
parent4c6e61b3b1a82212510695b0d202bc8612b16b6c (diff)
Add documentation about the different embassy abstraction layers
The guide demonstrates the functionality offered by each layer in Embassy, using code examples.
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.rs28
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
5use defmt_rtt as _;
6use panic_probe as _;
7
8use embassy::executor::Spawner;
9use embassy_stm32::{
10 exti::ExtiInput,
11 gpio::{Input, Level, Output, Pull, Speed},
12 Peripherals,
13};
14
15#[embassy::main]
16async 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}