aboutsummaryrefslogtreecommitdiff
path: root/book/en/src
diff options
context:
space:
mode:
Diffstat (limited to 'book/en/src')
-rw-r--r--book/en/src/by-example/app.md19
-rw-r--r--book/en/src/by-example/new.md3
-rw-r--r--book/en/src/by-example/resources.md12
-rw-r--r--book/en/src/by-example/tasks.md9
-rw-r--r--book/en/src/by-example/tips.md12
5 files changed, 36 insertions, 19 deletions
diff --git a/book/en/src/by-example/app.md b/book/en/src/by-example/app.md
index 42623914..ab6f4524 100644
--- a/book/en/src/by-example/app.md
+++ b/book/en/src/by-example/app.md
@@ -26,15 +26,16 @@ required).
This initialization function will be the first part of the application to run.
The `init` function will run *with interrupts disabled* and has exclusive access
-to Cortex-M and, optionally, device specific peripherals through the `core` and
-`device` fields of `init::Context`.
+to Cortex-M where the `bare_metal::CriticalSection` token is available as `cs`.
+And optionally, device specific peripherals through the `core` and `device` fields
+of `init::Context`.
`static mut` variables declared at the beginning of `init` will be transformed
into `&'static mut` references that are safe to access.
[`rtic::Peripherals`]: ../../api/rtic/struct.Peripherals.html
-The example below shows the types of the `core` and `device` fields and
+The example below shows the types of the `core`, `device` and `cs` fields, and
showcases safe access to a `static mut` variable. The `device` field is only
available when the `peripherals` argument is set to `true` (it defaults to
`false`).
@@ -48,7 +49,8 @@ process.
``` console
$ cargo run --example init
-{{#include ../../../../ci/expected/init.run}}```
+{{#include ../../../../ci/expected/init.run}}
+```
## `idle`
@@ -79,7 +81,8 @@ in LLVM which miss-optimizes empty loops to a `UDF` instruction in release mode.
``` console
$ cargo run --example idle
-{{#include ../../../../ci/expected/idle.run}}```
+{{#include ../../../../ci/expected/idle.run}}
+```
## Hardware tasks
@@ -100,7 +103,8 @@ mut` variables are safe to use within a hardware task.
``` console
$ cargo run --example hardware
-{{#include ../../../../ci/expected/hardware.run}}```
+{{#include ../../../../ci/expected/hardware.run}}
+```
So far all the RTIC applications we have seen look no different than the
applications one can write using only the `cortex-m-rt` crate. From this point
@@ -132,7 +136,8 @@ The following example showcases the priority based scheduling of tasks.
``` console
$ cargo run --example preempt
-{{#include ../../../../ci/expected/preempt.run}}```
+{{#include ../../../../ci/expected/preempt.run}}
+```
Note that the task `gpiob` does *not* preempt task `gpioc` because its priority
is the *same* as `gpioc`'s. However, once `gpioc` terminates the execution of
diff --git a/book/en/src/by-example/new.md b/book/en/src/by-example/new.md
index abcc36de..866a9fa5 100644
--- a/book/en/src/by-example/new.md
+++ b/book/en/src/by-example/new.md
@@ -63,4 +63,5 @@ $ cargo add panic-semihosting
``` console
$ # NOTE: I have uncommented the `runner` option in `.cargo/config`
$ cargo run
-{{#include ../../../../ci/expected/init.run}}```
+{{#include ../../../../ci/expected/init.run}}
+```
diff --git a/book/en/src/by-example/resources.md b/book/en/src/by-example/resources.md
index 62efdc68..d082dfc1 100644
--- a/book/en/src/by-example/resources.md
+++ b/book/en/src/by-example/resources.md
@@ -31,7 +31,8 @@ access to a resource named `shared`.
``` console
$ cargo run --example resource
-{{#include ../../../../ci/expected/resource.run}}```
+{{#include ../../../../ci/expected/resource.run}}
+```
Note that the `shared` resource cannot be accessed from `idle`. Attempting to do
so results in a compile error.
@@ -73,7 +74,8 @@ lowest priority handler.
``` console
$ cargo run --example lock
-{{#include ../../../../ci/expected/lock.run}}```
+{{#include ../../../../ci/expected/lock.run}}
+```
## Late resources
@@ -99,7 +101,8 @@ the consumer resource.
``` console
$ cargo run --example late
-{{#include ../../../../ci/expected/late.run}}```
+{{#include ../../../../ci/expected/late.run}}
+```
## Only shared access
@@ -129,4 +132,5 @@ any kind of lock.
``` console
$ cargo run --example only-shared-access
-{{#include ../../../../ci/expected/only-shared-access.run}}```
+{{#include ../../../../ci/expected/only-shared-access.run}}
+```
diff --git a/book/en/src/by-example/tasks.md b/book/en/src/by-example/tasks.md
index 9fefd022..ba164048 100644
--- a/book/en/src/by-example/tasks.md
+++ b/book/en/src/by-example/tasks.md
@@ -25,7 +25,8 @@ priorities. The three software tasks are mapped to 2 interrupts handlers.
``` console
$ cargo run --example task
-{{#include ../../../../ci/expected/task.run}}```
+{{#include ../../../../ci/expected/task.run}}
+```
## Message passing
@@ -41,7 +42,8 @@ The example below showcases three tasks, two of them expect a message.
``` console
$ cargo run --example message
-{{#include ../../../../ci/expected/message.run}}```
+{{#include ../../../../ci/expected/message.run}}
+```
## Capacity
@@ -63,7 +65,8 @@ fail (panic).
``` console
$ cargo run --example capacity
-{{#include ../../../../ci/expected/capacity.run}}```
+{{#include ../../../../ci/expected/capacity.run}}
+```
## Error handling
diff --git a/book/en/src/by-example/tips.md b/book/en/src/by-example/tips.md
index 0b6555e1..d8264c90 100644
--- a/book/en/src/by-example/tips.md
+++ b/book/en/src/by-example/tips.md
@@ -24,7 +24,8 @@ Here's one such example:
``` console
$ cargo run --example generics
-{{#include ../../../../ci/expected/generics.run}}```
+{{#include ../../../../ci/expected/generics.run}}
+```
Using generics also lets you change the static priorities of tasks during
development without having to rewrite a bunch code every time.
@@ -47,7 +48,8 @@ the program has been compiled using the `dev` profile.
$ cargo run --example cfg --release
$ cargo run --example cfg
-{{#include ../../../../ci/expected/cfg.run}}```
+{{#include ../../../../ci/expected/cfg.run}}
+```
## Running tasks from RAM
@@ -78,7 +80,8 @@ Running this program produces the expected output.
``` console
$ cargo run --example ramfunc
-{{#include ../../../../ci/expected/ramfunc.run}}```
+{{#include ../../../../ci/expected/ramfunc.run}}
+```
One can look at the output of `cargo-nm` to confirm that `bar` ended in RAM
(`0x2000_0000`), whereas `foo` ended in Flash (`0x0000_0000`).
@@ -115,7 +118,8 @@ Here's an example where `heapless::Pool` is used to "box" buffers of 128 bytes.
```
``` console
$ cargo run --example pool
-{{#include ../../../../ci/expected/pool.run}}```
+{{#include ../../../../ci/expected/pool.run}}
+```
## Inspecting the expanded code