aboutsummaryrefslogtreecommitdiff
path: root/book/en/src/by-example/app_init.md
diff options
context:
space:
mode:
authorFranz Dietrich <dietrich@teilgedanken.de>2024-04-04 00:01:46 +0200
committerGitHub <noreply@github.com>2024-04-03 22:01:46 +0000
commit53ed7bf7edb21180cb18c0bf6a7dbe6168331879 (patch)
treee7b86edf26aa3bfcf6af4dd825d67a627e8c1252 /book/en/src/by-example/app_init.md
parentfa2a5b449f1746b4b3bb3da08dab532ee24ba286 (diff)
fix included examples and markdown(book) (#912)
* fix included examples and markdown(book) fixes: #911 * fix footnote pre_init * more example link updates * Restore pool example name * Example: pool: Upgrade to heapless v0.8 * Example: pool: thumbv6 unsupported: wild cfg-if Experiment with multi-backend example contained in the example * Example: lm3s6965: Updated cargo.lock * Book: Use cargo xtask for by-example * Docs: Contributing: cargo xtask --------- Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
Diffstat (limited to 'book/en/src/by-example/app_init.md')
-rw-r--r--book/en/src/by-example/app_init.md19
1 files changed, 10 insertions, 9 deletions
diff --git a/book/en/src/by-example/app_init.md b/book/en/src/by-example/app_init.md
index 52d657a..49f0bc3 100644
--- a/book/en/src/by-example/app_init.md
+++ b/book/en/src/by-example/app_init.md
@@ -3,13 +3,14 @@
An RTIC application requires an `init` task setting up the system. The corresponding `init` function must have the
signature `fn(init::Context) -> (Shared, Local)`, where `Shared` and `Local` are resource structures defined by the user.
-The `init` task executes after system reset, [after an optionally defined `pre-init` code section][pre-init] and an always occurring internal RTIC initialization.
-[pre-init]: https://docs.rs/cortex-m-rt/latest/cortex_m_rt/attr.pre_init.html
+The `init` task executes after system reset, [after an optionally defined `pre-init` code section][^pre-init] and an always occurring internal RTIC initialization.
-The `init` and optional `pre-init` tasks runs *with interrupts disabled* and have exclusive access to Cortex-M (the `bare_metal::CriticalSection` token is available as `cs`).
+The `init` and optional `pre-init` tasks runs _with interrupts disabled_ and have exclusive access to Cortex-M (the `bare_metal::CriticalSection` token is available as `cs`).
Device specific peripherals are available through the `core` and `device` fields of `init::Context`.
+[^pre-init]: [https://docs.rs/cortex-m-rt/latest/cortex_m_rt/attr.pre_init.html](https://docs.rs/cortex-m-rt/latest/cortex_m_rt/attr.pre_init.html)
+
## Example
The example below shows the types of the `core`, `device` and `cs` fields, and showcases the use of a `local` variable with `'static` lifetime. Such variables can be delegated from the `init` task to other tasks of the RTIC application.
@@ -17,16 +18,16 @@ The example below shows the types of the `core`, `device` and `cs` fields, and s
The `device` field is only available when the `peripherals` argument is set to the default value `true`.
In the rare case you want to implement an ultra-slim application you can explicitly set `peripherals` to `false`.
-``` rust,noplayground
-{{#include ../../../../rtic/examples/init.rs}}
+```rust,noplayground
+{{#include ../../../../examples/lm3s6965/examples/init.rs}}
```
Running the example will print `init` to the console and then exit the QEMU process.
-``` console
-$ cargo run --target thumbv7m-none-eabi --example init
+```console
+$ cargo xtask qemu --verbose --example init
```
-``` console
-{{#include ../../../../rtic/ci/expected/init.run}}
+```console
+{{#include ../../../../ci/expected/lm3s6965/init.run}}
```