diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-12-13 00:07:39 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-13 00:07:39 +0000 |
| commit | 2a4a133b88402a513f1e2cbdd1c5dc29d057b8d5 (patch) | |
| tree | 717130a0665c4936d2f83f76a011b4424cd6a36d /docs/modules/ROOT/examples/basic/src/main.rs | |
| parent | 052abc918a987acb35d44dcd91d9db8a8aaf8ece (diff) | |
| parent | ff82c76935d86b7444e6abc7296c4c3e09261484 (diff) | |
Merge #533
533: Book poc r=Dirbaio a=lulf
This is a Proof of Concept for an embassy book. It's using Antora/Asciidoc.
* Asciidoc because it's a single specification with a slightly richer feature set than markdown.
* Antora because it allows keeping content in the embassy repo, while book definition in another repo (embassy-book).
Using antora also allows for easy embedding of embassy doc in other projects, which I think in turn increases probability of upstream contributions.
The sources of content are located in docs/ but could also be in a separate repo. However, keeping it in the embassy repo makes it easier to support one version of the book per embassy version in the future.
At present, the book is automatically built every hour from this branch and published at: https://embassy-rs.github.io/embassy-book/embassy/dev/index.html
Co-authored-by: Ulf Lilleengen <[email protected]>
Co-authored-by: Ulf Lilleengen <[email protected]>
Diffstat (limited to 'docs/modules/ROOT/examples/basic/src/main.rs')
| -rw-r--r-- | docs/modules/ROOT/examples/basic/src/main.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/docs/modules/ROOT/examples/basic/src/main.rs b/docs/modules/ROOT/examples/basic/src/main.rs new file mode 100644 index 000000000..2a9b1facc --- /dev/null +++ b/docs/modules/ROOT/examples/basic/src/main.rs | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt_rtt as _; // global logger | ||
| 6 | use panic_probe as _; | ||
| 7 | |||
| 8 | use defmt::*; | ||
| 9 | |||
| 10 | use embassy::executor::Spawner; | ||
| 11 | use embassy::time::{Duration, Timer}; | ||
| 12 | use embassy_nrf::{ | ||
| 13 | gpio::{Level, Output, OutputDrive}, | ||
| 14 | peripherals::P0_13, | ||
| 15 | Peripherals, | ||
| 16 | }; | ||
| 17 | use embedded_hal::digital::v2::OutputPin; | ||
| 18 | |||
| 19 | #[embassy::task] | ||
| 20 | async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) { | ||
| 21 | loop { | ||
| 22 | unwrap!(led.set_high()); | ||
| 23 | Timer::after(interval).await; | ||
| 24 | unwrap!(led.set_low()); | ||
| 25 | Timer::after(interval).await; | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | #[embassy::main] | ||
| 30 | async fn main(spawner: Spawner, p: Peripherals) { | ||
| 31 | let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | ||
| 32 | unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300)))); | ||
| 33 | } | ||
