diff options
| author | everdrone <[email protected]> | 2025-11-10 02:01:56 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-10 02:01:56 +0100 |
| commit | 5926690bfbd366beca13c8b5d0ab4b7a3519aa44 (patch) | |
| tree | 4b0df8b2b36c3324364e8aa49b4d8fea93cc485c /docs | |
| parent | e2807058ffc73bd0fc2f4ce9f29e5a56f3e5a18e (diff) | |
| parent | 4ef7f91663b51e2cfeb6ef40d907bfff90737de8 (diff) | |
Merge branch 'main' into stm32_sai_frame_length
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/examples/basic/Cargo.toml | 2 | ||||
| -rw-r--r-- | docs/examples/basic/src/main.rs | 33 | ||||
| -rw-r--r-- | docs/pages/embassy_in_the_wild.adoc | 4 |
3 files changed, 30 insertions, 9 deletions
diff --git a/docs/examples/basic/Cargo.toml b/docs/examples/basic/Cargo.toml index b90180853..fadda102b 100644 --- a/docs/examples/basic/Cargo.toml +++ b/docs/examples/basic/Cargo.toml | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | authors = ["Dario Nieuwenhuis <[email protected]>"] | 2 | authors = ["Dario Nieuwenhuis <[email protected]>"] |
| 3 | edition = "2018" | 3 | edition = "2024" |
| 4 | name = "embassy-basic-example" | 4 | name = "embassy-basic-example" |
| 5 | version = "0.1.0" | 5 | version = "0.1.0" |
| 6 | license = "MIT OR Apache-2.0" | 6 | license = "MIT OR Apache-2.0" |
diff --git a/docs/examples/basic/src/main.rs b/docs/examples/basic/src/main.rs index 6e274bacb..42797612c 100644 --- a/docs/examples/basic/src/main.rs +++ b/docs/examples/basic/src/main.rs | |||
| @@ -3,24 +3,41 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 6 | use embassy_nrf::Peri; |
| 7 | use embassy_time::{Duration, Timer}; | 7 | use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pull}; |
| 8 | use {defmt_rtt as _, panic_probe as _}; // global logger | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | ||
| 9 | 10 | ||
| 11 | // Declare async tasks | ||
| 10 | #[embassy_executor::task] | 12 | #[embassy_executor::task] |
| 11 | async fn blinker(mut led: Output<'static>, interval: Duration) { | 13 | async fn blink(pin: Peri<'static, AnyPin>) { |
| 14 | let mut led = Output::new(pin, Level::Low, OutputDrive::Standard); | ||
| 15 | |||
| 12 | loop { | 16 | loop { |
| 17 | // Timekeeping is globally available, no need to mess with hardware timers. | ||
| 13 | led.set_high(); | 18 | led.set_high(); |
| 14 | Timer::after(interval).await; | 19 | Timer::after_millis(150).await; |
| 15 | led.set_low(); | 20 | led.set_low(); |
| 16 | Timer::after(interval).await; | 21 | Timer::after_millis(150).await; |
| 17 | } | 22 | } |
| 18 | } | 23 | } |
| 19 | 24 | ||
| 25 | // Main is itself an async task as well. | ||
| 20 | #[embassy_executor::main] | 26 | #[embassy_executor::main] |
| 21 | async fn main(spawner: Spawner) { | 27 | async fn main(spawner: Spawner) { |
| 28 | // Initialize the embassy-nrf HAL. | ||
| 22 | let p = embassy_nrf::init(Default::default()); | 29 | let p = embassy_nrf::init(Default::default()); |
| 23 | 30 | ||
| 24 | let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | 31 | // Spawned tasks run in the background, concurrently. |
| 25 | spawner.spawn(unwrap!(blinker(led, Duration::from_millis(300)))); | 32 | spawner.spawn(blink(p.P0_13.into()).unwrap()); |
| 33 | |||
| 34 | let mut button = Input::new(p.P0_11, Pull::Up); | ||
| 35 | loop { | ||
| 36 | // Asynchronously wait for GPIO events, allowing other tasks | ||
| 37 | // to run, or the core to sleep. | ||
| 38 | button.wait_for_low().await; | ||
| 39 | info!("Button pressed!"); | ||
| 40 | button.wait_for_high().await; | ||
| 41 | info!("Button released!"); | ||
| 42 | } | ||
| 26 | } | 43 | } |
diff --git a/docs/pages/embassy_in_the_wild.adoc b/docs/pages/embassy_in_the_wild.adoc index 3b58bb9b4..0792130eb 100644 --- a/docs/pages/embassy_in_the_wild.adoc +++ b/docs/pages/embassy_in_the_wild.adoc | |||
| @@ -4,6 +4,10 @@ Here are known examples of real-world projects which make use of Embassy. Feel f | |||
| 4 | 4 | ||
| 5 | _newer entries at the top_ | 5 | _newer entries at the top_ |
| 6 | 6 | ||
| 7 | * link:https://github.com/thataquarel/protovolt[ProtoV MINI: A USB-C mini lab power supply] | ||
| 8 | ** A dual-channel USB PD powered breadboard power supply based on the RP2040, running embedded graphics. Open-source schematics and firmware. | ||
| 9 | * link:https://github.com/Dawson-HEP/opentrig/[Opentrig: A particle physics trigger and data acquisition system] | ||
| 10 | ** Digital event trigger with threshold, data acquisition system designed to interface with AIDA-2020 TLU systems, tested at the DESY II Test Beam Facility. Based on the RP2040, and Embassy's async event handling. | ||
| 7 | * link:https://github.com/1-rafael-1/air-quality-monitor[Air Quality Monitor] | 11 | * link:https://github.com/1-rafael-1/air-quality-monitor[Air Quality Monitor] |
| 8 | ** Air Quality Monitor based on rp2350 board, ens160 and aht21 sensors and ssd1306 display. Code and 3D printable enclosure included. | 12 | ** Air Quality Monitor based on rp2350 board, ens160 and aht21 sensors and ssd1306 display. Code and 3D printable enclosure included. |
| 9 | * link:https://github.com/CarlKCarlK/clock[Embassy Clock: Layered, modular bare-metal clock with emulation] | 13 | * link:https://github.com/CarlKCarlK/clock[Embassy Clock: Layered, modular bare-metal clock with emulation] |
