aboutsummaryrefslogtreecommitdiff
path: root/docs/modules/ROOT/pages/basic_application.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'docs/modules/ROOT/pages/basic_application.adoc')
-rw-r--r--docs/modules/ROOT/pages/basic_application.adoc20
1 files changed, 10 insertions, 10 deletions
diff --git a/docs/modules/ROOT/pages/basic_application.adoc b/docs/modules/ROOT/pages/basic_application.adoc
index a8875aa93..4dc4a6359 100644
--- a/docs/modules/ROOT/pages/basic_application.adoc
+++ b/docs/modules/ROOT/pages/basic_application.adoc
@@ -21,7 +21,7 @@ Then, what follows are some declarations on how to deal with panics and faults.
21 21
22[source,rust] 22[source,rust]
23---- 23----
24include::example$basic/src/main.rs[lines="5..6"] 24include::example$basic/src/main.rs[lines="11..12"]
25---- 25----
26 26
27=== Task declaration 27=== Task declaration
@@ -30,7 +30,7 @@ After a bit of import declaration, the tasks run by the application should be de
30 30
31[source,rust] 31[source,rust]
32---- 32----
33include::example$basic/src/main.rs[lines="18..27"] 33include::example$basic/src/main.rs[lines="13..22"]
34---- 34----
35 35
36An embassy task must be declared `async`, and may NOT take generic arguments. In this case, we are handed the LED that should be blinked and the interval of the blinking. 36An embassy task must be declared `async`, and may NOT take generic arguments. In this case, we are handed the LED that should be blinked and the interval of the blinking.
@@ -39,32 +39,32 @@ NOTE: Notice that there is no busy waiting going on in this task. It is using th
39 39
40=== Main 40=== Main
41 41
42The main entry point of an Embassy application is defined using the `#[embassy::main]` macro. The entry point is also required to take a `Spawner` and a `Peripherals` argument. 42The main entry point of an Embassy application is defined using the `#[embassy_executor::main]` macro. The entry point is also required to take a `Spawner` and a `Peripherals` argument.
43 43
44The `Spawner` is the way the main application spawns other tasks. The `Peripherals` type holds all peripherals that the application may use. In this case, we want to configure one of the pins as a GPIO output driving the LED: 44The `Spawner` is the way the main application spawns other tasks. The `Peripherals` type comes from the HAL and holds all peripherals that the application may use. In this case, we want to configure one of the pins as a GPIO output driving the LED:
45 45
46[source,rust] 46[source,rust]
47---- 47----
48include::example$basic/src/main.rs[lines="28..-1"] 48include::example$basic/src/main.rs[lines="23..-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: 51`#[embassy_executor::main]` takes an optional `config` parameter specifying a function that returns an instance of HAL's `Config` struct. For example:
52 52
53```rust 53```rust
54fn embassy_config() -> embassy_nrf::config::Config { 54fn embassy_config() -> embassy_nrf::config::Config {
55 embassy_nrf::config::Config::default() 55 embassy_nrf::config::Config::default()
56} 56}
57 57
58#[embassy::main(config = "embassy_config()")] 58#[embassy_executor::main(config = "embassy_config()")]
59async fn main(_spawner: embassy::executor::Spawner, p: embassy_nrf::Peripherals) { 59async fn main(_spawner: Spawner, p: embassy_nrf::Peripherals) {
60 // ... 60 // ...
61} 61}
62``` 62```
63 63
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: 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:
65 65
66. Creates an Embassy Executor instance 66. Creates an Embassy Executor
67. Initializes the microcontroller to get the `Peripherals` 67. Initializes the microcontroller HAL to get the `Peripherals`
68. Defines a main task for the entry point 68. Defines a main task for the entry point
69. Runs the executor spawning the main task 69. Runs the executor spawning the main task
70 70