aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2020-10-03 15:30:15 +0200
committerGravatar Emil Fresk <emil.fresk@gmail.com> 2020-10-03 15:30:15 +0200
commitf0f982facadab2da5d8cdaf214829a9e19f4249e (patch)
treed78a35d13ca909718b0187377ef7127cbf0f3feb
parent97eae45fa571ba1c470e9ab649ba7570beb963b0 (diff)
downloadrtic-f0f982facadab2da5d8cdaf214829a9e19f4249e.tar.gz
rtic-f0f982facadab2da5d8cdaf214829a9e19f4249e.tar.zst
rtic-f0f982facadab2da5d8cdaf214829a9e19f4249e.zip
Updated documentation to include the critical section token in init
-rw-r--r--book/en/src/by-example/app.md7
-rw-r--r--examples/init.rs4
2 files changed, 8 insertions, 3 deletions
diff --git a/book/en/src/by-example/app.md b/book/en/src/by-example/app.md
index 344cefc7..23bff68d 100644
--- a/book/en/src/by-example/app.md
+++ b/book/en/src/by-example/app.md
@@ -33,15 +33,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`).
diff --git a/examples/init.rs b/examples/init.rs
index 315969f0..1623ca7c 100644
--- a/examples/init.rs
+++ b/examples/init.rs
@@ -23,6 +23,10 @@ const 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);