aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml32
-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
-rw-r--r--examples/init.rs4
7 files changed, 61 insertions, 30 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index b1655f1c..4bc1028c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -578,27 +578,34 @@ jobs:
- name: Build books
run: |
langs=( en ru )
- latest=0.5
- vers=( 0.4.x )
+ devver=dev
+ # Query git for tagged releases, all releases start with "v"
+ # followed by MAJOR.MINOR.PATCH, see semver.org
+ # Then remove all pre-releases/tags with hyphens (-).
+ # The latest release is last, finally trim "v" and PATCH
+ stable=$(git tag | grep "^v" | grep -v "-" | tail -n 1 | cut -c2-4)
+ vers=( 0.5.x 0.4.x )
# Create directories
td=$(mktemp -d)
- mkdir -p $td/$latest/book/
- cp -r target/doc $td/$latest/api
+ mkdir -p $td/$devver/book/
+ cp -r target/doc $td/$devver/api
- # sed fixes
- sed 's|URL|rtic/index.html|g' redirect.html > $td/$latest/api/index.html
- sed 's|URL|0.5|g' redirect.html > $td/index.html
- sed 's|URL|book/en|g' redirect.html > $td/$latest/index.html
+ # Redirect the main site to the stable release
+ sed "s|URL|$stable|g" redirect.html > $td/index.html
+
+ # Create the redirects for dev-version
+ sed 's|URL|rtic/index.html|g' redirect.html > $td/$devver/api/index.html
+ sed 's|URL|book/en|g' redirect.html > $td/$devver/index.html
# Build books
for lang in ${langs[@]}; do
( cd book/$lang && mdbook build )
- cp -r book/$lang/book $td/$latest/book/$lang
- cp LICENSE-* $td/$latest/book/$lang/
+ cp -r book/$lang/book $td/$devver/book/$lang
+ cp LICENSE-* $td/$devver/book/$lang/
done
- # Build older versions
+ # Build older versions, including stable
root=$(pwd)
for ver in ${vers[@]}; do
prefix=${ver%.*}
@@ -623,6 +630,9 @@ jobs:
rm -rf $src
done
+ # Create alias for the stable release
+ ln -s $td/$stable $td/stable
+
# Forward CNAME file
cp CNAME $td/
mv $td/ bookstodeploy
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
diff --git a/examples/init.rs b/examples/init.rs
index aaf71f97..ea543338 100644
--- a/examples/init.rs
+++ b/examples/init.rs
@@ -23,6 +23,10 @@ mod app {
// Safe access to local `static mut` variable
let _x: &'static mut u32 = X;
+ // Access to the critical section token,
+ // to indicate that this is a critical seciton
+ let _cs_token: bare_metal::CriticalSection = cx.cs;
+
hprintln!("init").unwrap();
debug::exit(debug::EXIT_SUCCESS);