aboutsummaryrefslogtreecommitdiff
path: root/docs/modules/ROOT/examples/basic/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'docs/modules/ROOT/examples/basic/src/main.rs')
-rw-r--r--docs/modules/ROOT/examples/basic/src/main.rs33
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
5use defmt_rtt as _; // global logger
6use panic_probe as _;
7
8use defmt::*;
9
10use embassy::executor::Spawner;
11use embassy::time::{Duration, Timer};
12use embassy_nrf::{
13 gpio::{Level, Output, OutputDrive},
14 peripherals::P0_13,
15 Peripherals,
16};
17use embedded_hal::digital::v2::OutputPin;
18
19#[embassy::task]
20async 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]
30async 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}