embassy/docs/modules/ROOT/examples/basic/src/main.rs
Dario Nieuwenhuis a8703b7598 Run rustfmt.
2022-06-12 22:22:31 +02:00

28 lines
763 B
Rust

#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
use defmt::*;
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
use embassy_nrf::gpio::{Level, Output, OutputDrive};
use embassy_nrf::peripherals::P0_13;
use embassy_nrf::Peripherals;
use {defmt_rtt as _, panic_probe as _}; // global logger
#[embassy::task]
async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) {
loop {
led.set_high();
Timer::after(interval).await;
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))));
}