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 --- docs/modules/ROOT/examples/basic/src/main.rs | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 docs/modules/ROOT/examples/basic/src/main.rs (limited to 'docs/modules/ROOT/examples/basic/src/main.rs') 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