Allow rtos_trace example to be used without log

This commit is contained in:
Quentin Smith 2022-08-16 01:20:07 -04:00
parent c1d8c8cf36
commit cd561b19ef
2 changed files with 10 additions and 4 deletions

View File

@ -35,7 +35,6 @@ log = [
rtos-trace = [ rtos-trace = [
"dep:rtos-trace", "dep:rtos-trace",
"dep:systemview-target", "dep:systemview-target",
"log",
"embassy-executor/rtos-trace", "embassy-executor/rtos-trace",
"embassy-executor/rtos-trace-interrupt", "embassy-executor/rtos-trace-interrupt",
] ]
@ -68,7 +67,7 @@ log = { version = "0.4.17", optional = true }
[[bin]] [[bin]]
name = "rtos_trace" name = "rtos_trace"
required-features = ["nightly", "rtos-trace", "log"] required-features = ["nightly", "rtos-trace"]
[patch.crates-io] [patch.crates-io]
rtos-trace = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" } rtos-trace = { git = "https://gitlab.com/quentinmit/rtos-trace.git", branch = "build-fix" }

View File

@ -13,6 +13,7 @@ use embassy_nrf::Peripherals;
use rtos_trace; use rtos_trace;
use systemview_target::SystemView; use systemview_target::SystemView;
use panic_probe as _; use panic_probe as _;
#[cfg(feature = "log")]
use log::*; use log::*;
static LOGGER: systemview_target::SystemView = systemview_target::SystemView::new(); static LOGGER: systemview_target::SystemView = systemview_target::SystemView::new();
@ -31,7 +32,10 @@ rtos_trace::global_application_callbacks!{TraceInfo}
#[embassy_executor::task] #[embassy_executor::task]
async fn run1() { async fn run1() {
loop { loop {
#[cfg(feature = "log")]
info!("DING DONG"); info!("DING DONG");
#[cfg(not(feature = "log"))]
rtos_trace::trace::marker(13);
Timer::after(Duration::from_ticks(16000)).await; Timer::after(Duration::from_ticks(16000)).await;
} }
} }
@ -55,8 +59,11 @@ async fn run3() {
#[embassy_executor::main] #[embassy_executor::main]
async fn main(spawner: Spawner, _p: Peripherals) { async fn main(spawner: Spawner, _p: Peripherals) {
LOGGER.init(); LOGGER.init();
::log::set_logger(&LOGGER).ok(); #[cfg(feature = "log")]
::log::set_max_level(::log::LevelFilter::Trace); {
::log::set_logger(&LOGGER).ok();
::log::set_max_level(::log::LevelFilter::Trace);
}
spawner.spawn(run1()).unwrap(); spawner.spawn(run1()).unwrap();
spawner.spawn(run2()).unwrap(); spawner.spawn(run2()).unwrap();