You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An 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.
@@ -45,23 +45,10 @@ The `Spawner` is the way the main application spawns other tasks. The `Periphera
What 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:
51
+
What happens when the `blinker` task has 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
52
66
53
. Creates an Embassy Executor
67
54
. Initializes the microcontroller HAL to get the `Peripherals`
@@ -76,7 +63,7 @@ The project definition needs to contain the embassy dependencies:
76
63
77
64
[source,toml]
78
65
----
79
-
include::example$basic/Cargo.toml[lines="8..9"]
66
+
include::example$basic/Cargo.toml[lines="9..11"]
80
67
----
81
68
82
69
Depending on your microcontroller, you may need to replace `embassy-nrf` with something else (`embassy-stm32` for STM32. Remember to update feature flags as well).
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/layer_by_layer.adoc
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ The application we'll write is a simple 'push button, blink led' application, wh
8
8
9
9
== PAC version
10
10
11
-
The PAC is the lowest API for accessing peripherals and registers, if you don't count reading/writing directly to memory addresses. It provide distinct types
11
+
The PAC is the lowest API for accessing peripherals and registers, if you don't count reading/writing directly to memory addresses. It provides distinct types
12
12
to make accessing peripheral registers easier, but it does not prevent you from writing unsafe code.
13
13
14
14
Writing an application using the PAC directly is therefore not recommended, but if the functionality you want to use is not exposed in the upper layers, that's what you need to use.
@@ -20,13 +20,13 @@ The blinky app using PAC is shown below:
As you can see, there are a lot of code needed to enable the peripheral clocks, configuring the input pins and the output pins of the application.
23
+
As you can see, a lot of code is needed to enable the peripheral clocks and to configure the input pins and the output pins of the application.
24
24
25
25
Another downside of this application is that it is busy-looping while polling the button state. This prevents the microcontroller from utilizing any sleep mode to save power.
26
26
27
27
== HAL version
28
28
29
-
To simplify our application, we can use the HAL instead. The HAL exposes higher level APIs that handle details such
29
+
To simplify our application, we can use the HAL instead. The HAL exposes higher level APIs that handle details such as:
30
30
31
31
* Automatically enabling the peripheral clock when you're using the peripheral
32
32
* Deriving and applying register configuration from higher level types
As you can see, the application becomes a lot simpler, even without using any async code. The `Input` and `Output` hides all the details accessing the GPIO registers, and allow you to use a much simpler API to query the state of the button and toggle the LED output accordingly.
42
+
As you can see, the application becomes a lot simpler, even without using any async code. The `Input` and `Output` types hide all the details of accessing the GPIO registers and allow you to use a much simpler API for querying the state of the button and toggling the LED output.
43
43
44
44
The same downside from the PAC example still applies though: the application is busy looping and consuming more power than necessary.
0 commit comments