aboutsummaryrefslogtreecommitdiff
path: root/examples/common/mod.rs
blob: db97463795c15ce45ebb93f4ba9e4446ede620f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
mod std_async_tcp;
use embassy_executor::Executor;
use static_cell::StaticCell;
pub use std_async_tcp::AsyncTcp;

pub static EXECUTOR: StaticCell<Executor> = StaticCell::new();

#[macro_export]
macro_rules! example_main {
    () => {
        fn main() {
            // Initialize tracing if tracing feature is enabled
            #[cfg(feature = "tracing")]
            {
                tracing_subscriber::fmt()
                    .with_max_level(tracing::Level::DEBUG)
                    .init();
            }

            let executor = common::EXECUTOR.init(Executor::new());
            executor.run(|spawner| {
                spawner.must_spawn(main_task(spawner));
            });
        }
    };
}