diff options
| author | Ulf Lilleengen <[email protected]> | 2022-02-23 09:48:32 +0100 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2022-02-23 09:48:32 +0100 |
| commit | 092eef3ae7f90e33564f09fa6a887e8fc9ed88b8 (patch) | |
| tree | 547db6b7241e749f1cad0285c12124d26de37639 /docs/modules/ROOT/examples/layer-by-layer/blinky-async | |
| parent | 4c6e61b3b1a82212510695b0d202bc8612b16b6c (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')
| -rw-r--r-- | docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml | 14 | ||||
| -rw-r--r-- | docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs | 28 |
2 files changed, 42 insertions, 0 deletions
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml new file mode 100644 index 000000000..e0c63251e --- /dev/null +++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | [package] | ||
| 2 | name = "blinky-async" | ||
| 3 | version = "0.1.0" | ||
| 4 | edition = "2021" | ||
| 5 | |||
| 6 | [dependencies] | ||
| 7 | cortex-m = "0.7" | ||
| 8 | cortex-m-rt = "0.7" | ||
| 9 | embassy-stm32 = { version = "0.1.0", features = ["stm32l475vg", "memory-x", "exti"], default-features = false } | ||
| 10 | embassy = { version = "0.1.0", default-features = false, features = ["nightly"] } | ||
| 11 | |||
| 12 | defmt = "0.3.0" | ||
| 13 | defmt-rtt = "0.3.0" | ||
| 14 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } | ||
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 | } | ||
