embassy/examples/nrf52840-rtic/src/bin/blinky.rs

44 lines
1.0 KiB
Rust
Raw Normal View History

2023-06-08 16:40:02 +02:00
#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
use {defmt_rtt as _, panic_probe as _};
#[rtic::app(device = embassy_nrf, peripherals = false, dispatchers = [SWI0_EGU0, SWI1_EGU1])]
mod app {
use defmt::info;
use embassy_nrf::gpio::{Level, Output, OutputDrive};
use embassy_nrf::peripherals;
use embassy_time::Timer;
2023-06-08 16:40:02 +02:00
#[shared]
struct Shared {}
#[local]
struct Local {}
#[init]
fn init(_: init::Context) -> (Shared, Local) {
info!("Hello World!");
let p = embassy_nrf::init(Default::default());
blink::spawn(p.P0_13).map_err(|_| ()).unwrap();
(Shared {}, Local {})
}
#[task(priority = 1)]
async fn blink(_cx: blink::Context, pin: peripherals::P0_13) {
let mut led = Output::new(pin, Level::Low, OutputDrive::Standard);
loop {
info!("off!");
led.set_high();
Timer::after_millis(300).await;
2023-06-08 16:40:02 +02:00
info!("on!");
led.set_low();
Timer::after_millis(300).await;
2023-06-08 16:40:02 +02:00
}
}
}