Skip to main content

main

Attribute Macro main 

Source
#[main]
Available on crate feature embassy only.
Expand description

Attribute to declare the entry point of the program.

Accepts both blocking and async main functions:

  • A blocking function (fn main() -> !) is treated as a bare-metal entry point.
  • An async function (async fn main(spawner: Spawner)) is spawned inside an esp_rtos::embassy::Executor.

§Examples

§Blocking (bare-metal)

#[main]
fn main() -> ! {
    loop { /* .. */ }
}

§Async (embassy executor)

#[main]
async fn main(spawner: Spawner) {
    // spawn tasks, await futures, …
}