aboutsummaryrefslogtreecommitdiff
path: root/docs/modules/ROOT/pages
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-02-11 22:06:47 +0100
committerGitHub <[email protected]>2022-02-11 22:06:47 +0100
commitcf9c15760787abaef70cc0cb1784d56d0a9f5fb6 (patch)
treeb9f6ee728b5ef758555a92b380800f7fd322467a /docs/modules/ROOT/pages
parent37bd796fb3090236a9569db7f7fc2bf7b6e8e2b2 (diff)
parente15d3750ea05f3adca01d1f54b9ec39ce304b983 (diff)
Merge pull request #611 from danielzfranklin/patch-1
Document #[embassy::main(config = ...)]
Diffstat (limited to 'docs/modules/ROOT/pages')
-rw-r--r--docs/modules/ROOT/pages/basic_application.adoc12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/modules/ROOT/pages/basic_application.adoc b/docs/modules/ROOT/pages/basic_application.adoc
index 749869ec0..11362b070 100644
--- a/docs/modules/ROOT/pages/basic_application.adoc
+++ b/docs/modules/ROOT/pages/basic_application.adoc
@@ -48,6 +48,18 @@ The `Spawner` is the way the main application spawns other tasks. The `Periphera
48include::example$basic/src/main.rs[lines="28..-1"] 48include::example$basic/src/main.rs[lines="28..-1"]
49---- 49----
50 50
51`#[embassy::main]` takes an optional `config` paramter specifying a function that returns an instance of HAL's `Config` struct. For example:
52
53```rust
54fn embassy_config() -> embassy_nrf::config::Config {
55 embassy_nrf::config::Config::default()
56}
57
58#[embassy::main(config = "embassy_config()")]
59async fn main(_spawner: embassy::executor::Spawner, p: embassy_nrf::Peripherals) {
60 // ...
61}
62```
51 63
52What happens when the `blinker` task have been spawned and main returns? Well, the main entry point is actually just like any other task, except that you can only have one and it takes some specific type arguments. The magic lies within the `#[embassy::main]` macro. The macro does the following: 64What happens when the `blinker` task have been spawned and main returns? Well, the main entry point is actually just like any other task, except that you can only have one and it takes some specific type arguments. The magic lies within the `#[embassy::main]` macro. The macro does the following:
53 65