diff options
| author | Ulf Lilleengen <[email protected]> | 2021-12-10 12:46:41 +0100 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2021-12-10 12:46:41 +0100 |
| commit | e5d4d0952b78ef343f14205f5ebd3f1d7804f9e8 (patch) | |
| tree | 2286467ce8c28f8eb7858d4fd33863ac52b81f65 /docs/modules/ROOT/examples/basic/src/main.rs | |
| parent | 9b01eed1956421dd7c0ad644f77e14a05ab92923 (diff) | |
Add doc-specific example and add it to CI
Diffstat (limited to 'docs/modules/ROOT/examples/basic/src/main.rs')
| -rw-r--r-- | docs/modules/ROOT/examples/basic/src/main.rs | 30 |
1 files changed, 30 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..0152b40bb --- /dev/null +++ b/docs/modules/ROOT/examples/basic/src/main.rs | |||
| @@ -0,0 +1,30 @@ | |||
| 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::gpio::{Level, Output, OutputDrive}; | ||
| 13 | use embassy_nrf::Peripherals; | ||
| 14 | use embedded_hal::digital::v2::OutputPin; | ||
| 15 | |||
| 16 | #[embassy::task] | ||
| 17 | async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) { | ||
| 18 | loop { | ||
| 19 | unwrap!(led.set_high()); | ||
| 20 | Timer::after(interval).await; | ||
| 21 | unwrap!(led.set_low()); | ||
| 22 | Timer::after(interval).await; | ||
| 23 | } | ||
| 24 | } | ||
| 25 | |||
| 26 | #[embassy::main] | ||
| 27 | async fn main(spawner: Spawner, p: Peripherals) { | ||
| 28 | let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | ||
| 29 | unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300)))); | ||
| 30 | } | ||
