embassy/examples/std/src/bin/tick.rs

30 lines
627 B
Rust
Raw Normal View History

2021-02-03 05:05:05 +01:00
#![feature(type_alias_impl_trait)]
#![allow(incomplete_features)]
2021-02-03 05:05:05 +01:00
use embassy::executor::Executor;
2021-02-03 05:05:05 +01:00
use embassy::time::{Duration, Timer};
use embassy::util::Forever;
use log::*;
#[embassy::task]
2021-02-03 05:05:05 +01:00
async fn run() {
loop {
info!("tick");
Timer::after(Duration::from_secs(1)).await;
}
}
static EXECUTOR: Forever<Executor> = Forever::new();
fn main() {
env_logger::builder()
.filter_level(log::LevelFilter::Debug)
.format_timestamp_nanos()
.init();
let executor = EXECUTOR.put(Executor::new());
executor.run(|spawner| {
spawner.spawn(run()).unwrap();
});
}