From e5d4d0952b78ef343f14205f5ebd3f1d7804f9e8 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Fri, 10 Dec 2021 12:46:41 +0100 Subject: Add doc-specific example and add it to CI --- .../modules/ROOT/examples/basic/.cargo/config.toml | 6 +++++ docs/modules/ROOT/examples/basic/Cargo.toml | 18 +++++++++++++ docs/modules/ROOT/examples/basic/src/main.rs | 30 ++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 docs/modules/ROOT/examples/basic/.cargo/config.toml create mode 100644 docs/modules/ROOT/examples/basic/Cargo.toml create mode 100644 docs/modules/ROOT/examples/basic/src/main.rs (limited to 'docs/modules/ROOT/examples/basic') diff --git a/docs/modules/ROOT/examples/basic/.cargo/config.toml b/docs/modules/ROOT/examples/basic/.cargo/config.toml new file mode 100644 index 000000000..c75b5c539 --- /dev/null +++ b/docs/modules/ROOT/examples/basic/.cargo/config.toml @@ -0,0 +1,6 @@ +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +# replace nRF82840_xxAA with your chip as listed in `probe-run --list-chips` +runner = "probe-run --chip nRF52840_xxAA" + +[build] +target = "thumbv7em-none-eabi" diff --git a/docs/modules/ROOT/examples/basic/Cargo.toml b/docs/modules/ROOT/examples/basic/Cargo.toml new file mode 100644 index 000000000..a683a28bf --- /dev/null +++ b/docs/modules/ROOT/examples/basic/Cargo.toml @@ -0,0 +1,18 @@ +[package] +authors = ["Dario Nieuwenhuis "] +edition = "2018" +name = "embassy-basic-example" +version = "0.1.0" + +[dependencies] +embassy = { version = "0.1.0", path = "../../../../embassy", features = ["defmt"] } +embassy-traits = { version = "0.1.0", path = "../../../../embassy-traits", features = ["defmt"] } +embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] } + +defmt = "0.3" +defmt-rtt = "0.3" + +cortex-m = "0.7.3" +cortex-m-rt = "0.7.0" +embedded-hal = "0.2.6" +panic-probe = { version = "0.3", features = ["print-defmt"] } 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..0152b40bb --- /dev/null +++ b/docs/modules/ROOT/examples/basic/src/main.rs @@ -0,0 +1,30 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use defmt_rtt as _; // global logger +use panic_probe as _; + +use defmt::*; + +use embassy::executor::Spawner; +use embassy::time::{Duration, Timer}; +use embassy_nrf::gpio::{Level, Output, OutputDrive}; +use embassy_nrf::Peripherals; +use embedded_hal::digital::v2::OutputPin; + +#[embassy::task] +async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) { + loop { + unwrap!(led.set_high()); + Timer::after(interval).await; + unwrap!(led.set_low()); + Timer::after(interval).await; + } +} + +#[embassy::main] +async fn main(spawner: Spawner, p: Peripherals) { + let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); + unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300)))); +} -- cgit