2022-06-03 19:47:17 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
|
|
|
use defmt::{info, unwrap};
|
2022-06-12 07:16:56 +02:00
|
|
|
use embassy::channel::signal::Signal;
|
2022-06-03 19:47:17 +02:00
|
|
|
use embassy::executor::Spawner;
|
|
|
|
use embassy::time::{Duration, Timer};
|
|
|
|
use embassy_stm32::Peripherals;
|
2022-06-12 22:15:44 +02:00
|
|
|
use {defmt_rtt as _, panic_probe as _};
|
2022-06-03 19:47:17 +02:00
|
|
|
|
|
|
|
static SIGNAL: Signal<u32> = Signal::new();
|
|
|
|
|
|
|
|
#[embassy::task]
|
|
|
|
async fn my_sending_task() {
|
|
|
|
let mut counter: u32 = 0;
|
|
|
|
|
|
|
|
loop {
|
|
|
|
Timer::after(Duration::from_secs(1)).await;
|
|
|
|
|
|
|
|
SIGNAL.signal(counter);
|
|
|
|
|
|
|
|
counter = counter.wrapping_add(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[embassy::main]
|
|
|
|
async fn main(spawner: Spawner, _p: Peripherals) {
|
|
|
|
unwrap!(spawner.spawn(my_sending_task()));
|
|
|
|
|
|
|
|
loop {
|
|
|
|
let received_counter = SIGNAL.wait().await;
|
|
|
|
|
|
|
|
info!("signalled, counter: {}", received_counter);
|
|
|
|
}
|
|
|
|
}
|