2022-08-16 07:17:28 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
2022-09-22 16:42:49 +02:00
|
|
|
use core::future::poll_fn;
|
2022-08-16 07:17:28 +02:00
|
|
|
use core::task::Poll;
|
|
|
|
|
2022-08-19 06:53:06 +02:00
|
|
|
use embassy_executor::Spawner;
|
2023-10-15 01:57:25 +02:00
|
|
|
use embassy_time::{Instant, Timer};
|
2022-08-16 07:47:18 +02:00
|
|
|
#[cfg(feature = "log")]
|
|
|
|
use log::*;
|
|
|
|
use panic_probe as _;
|
2022-08-16 07:17:28 +02:00
|
|
|
// N.B. systemview_target cannot be used at the same time as defmt_rtt.
|
|
|
|
use rtos_trace;
|
|
|
|
use systemview_target::SystemView;
|
|
|
|
|
|
|
|
static LOGGER: systemview_target::SystemView = systemview_target::SystemView::new();
|
2022-08-16 07:47:18 +02:00
|
|
|
rtos_trace::global_trace! {SystemView}
|
2022-08-16 07:17:28 +02:00
|
|
|
|
|
|
|
struct TraceInfo();
|
|
|
|
|
|
|
|
impl rtos_trace::RtosTraceApplicationCallbacks for TraceInfo {
|
|
|
|
fn system_description() {}
|
|
|
|
fn sysclock() -> u32 {
|
|
|
|
64000000
|
|
|
|
}
|
|
|
|
}
|
2022-08-16 07:47:18 +02:00
|
|
|
rtos_trace::global_application_callbacks! {TraceInfo}
|
2022-08-16 07:17:28 +02:00
|
|
|
|
|
|
|
#[embassy_executor::task]
|
|
|
|
async fn run1() {
|
|
|
|
loop {
|
2022-08-16 07:20:07 +02:00
|
|
|
#[cfg(feature = "log")]
|
2022-08-16 07:17:28 +02:00
|
|
|
info!("DING DONG");
|
2022-08-16 07:20:07 +02:00
|
|
|
#[cfg(not(feature = "log"))]
|
|
|
|
rtos_trace::trace::marker(13);
|
2023-10-15 01:57:25 +02:00
|
|
|
Timer::after_ticks(16000).await;
|
2022-08-16 07:17:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[embassy_executor::task]
|
|
|
|
async fn run2() {
|
|
|
|
loop {
|
|
|
|
Timer::at(Instant::from_ticks(0)).await;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[embassy_executor::task]
|
|
|
|
async fn run3() {
|
2022-09-22 16:42:49 +02:00
|
|
|
poll_fn(|cx| {
|
2022-08-16 07:17:28 +02:00
|
|
|
cx.waker().wake_by_ref();
|
|
|
|
Poll::<()>::Pending
|
|
|
|
})
|
|
|
|
.await;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[embassy_executor::main]
|
2022-08-19 06:53:06 +02:00
|
|
|
async fn main(spawner: Spawner) {
|
|
|
|
let _p = embassy_nrf::init(Default::default());
|
2022-08-16 07:17:28 +02:00
|
|
|
LOGGER.init();
|
2022-08-16 07:20:07 +02:00
|
|
|
#[cfg(feature = "log")]
|
|
|
|
{
|
|
|
|
::log::set_logger(&LOGGER).ok();
|
|
|
|
::log::set_max_level(::log::LevelFilter::Trace);
|
|
|
|
}
|
2022-08-16 07:17:28 +02:00
|
|
|
|
|
|
|
spawner.spawn(run1()).unwrap();
|
|
|
|
spawner.spawn(run2()).unwrap();
|
|
|
|
spawner.spawn(run3()).unwrap();
|
|
|
|
}
|