Skip to content

Commit 2528f45

Browse files
Merge #1058
1058: Fix some errors in the documentation r=lulf a=johannesneyer Co-authored-by: Johannes Neyer <[email protected]>
2 parents d05979c + 9505a6f commit 2528f45

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

docs/modules/ROOT/pages/basic_application.adoc

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Then, what follows are some declarations on how to deal with panics and faults.
2121

2222
[source,rust]
2323
----
24-
include::example$basic/src/main.rs[lines="11..12"]
24+
include::example$basic/src/main.rs[lines="10"]
2525
----
2626

2727
=== Task declaration
@@ -30,7 +30,7 @@ After a bit of import declaration, the tasks run by the application should be de
3030

3131
[source,rust]
3232
----
33-
include::example$basic/src/main.rs[lines="13..22"]
33+
include::example$basic/src/main.rs[lines="12..20"]
3434
----
3535

3636
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
4545

4646
[source,rust]
4747
----
48-
include::example$basic/src/main.rs[lines="23..-1"]
48+
include::example$basic/src/main.rs[lines="22..-1"]
4949
----
5050

51-
`#[embassy_executor::main]` takes an optional `config` parameter specifying a function that returns an instance of HAL's `Config` struct. For example:
52-
53-
```rust
54-
fn embassy_config() -> embassy_nrf::config::Config {
55-
embassy_nrf::config::Config::default()
56-
}
57-
58-
#[embassy_executor::main(config = "embassy_config()")]
59-
async fn main(_spawner: Spawner, p: embassy_nrf::Peripherals) {
60-
// ...
61-
}
62-
```
63-
64-
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:
6552

6653
. Creates an Embassy Executor
6754
. Initializes the microcontroller HAL to get the `Peripherals`
@@ -76,7 +63,7 @@ The project definition needs to contain the embassy dependencies:
7663

7764
[source,toml]
7865
----
79-
include::example$basic/Cargo.toml[lines="8..9"]
66+
include::example$basic/Cargo.toml[lines="9..11"]
8067
----
8168

8269
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).

docs/modules/ROOT/pages/layer_by_layer.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The application we'll write is a simple 'push button, blink led' application, wh
88

99
== PAC version
1010

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
1212
to make accessing peripheral registers easier, but it does not prevent you from writing unsafe code.
1313

1414
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:
2020
include::example$layer-by-layer/blinky-pac/src/main.rs[]
2121
----
2222

23-
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.
2424

2525
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.
2626

2727
== HAL version
2828

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:
3030

3131
* Automatically enabling the peripheral clock when you're using the peripheral
3232
* Deriving and applying register configuration from higher level types
@@ -39,7 +39,7 @@ The HAL example is shown below:
3939
include::example$layer-by-layer/blinky-hal/src/main.rs[]
4040
----
4141

42-
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.
4343

4444
The same downside from the PAC example still applies though: the application is busy looping and consuming more power than necessary.
4545

docs/modules/ROOT/pages/stm32.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ The link:https://github.com/embassy-rs/embassy/tree/master/embassy-stm32[Embassy
44

55
== The infinite variant problem
66

7-
STM32 microcontrollers comes in many families and flavors, and supporting all of them is a big undertaking. Embassy has taken advantage of the fact
7+
STM32 microcontrollers come in many families, and flavors and supporting all of them is a big undertaking. Embassy has taken advantage of the fact
88
that the STM32 peripheral versions are shared across chip families. Instead of re-implementing the SPI
9-
peripheral for every STM32 chip family, embassy have a single SPI implementation that depends on
9+
peripheral for every STM32 chip family, embassy has a single SPI implementation that depends on
1010
code-generated register types that are identical for STM32 families with the same version of a given peripheral.
1111

1212
=== The metapac

0 commit comments

Comments
 (0)