From 34e74f4bb36b0866be94c9bfdb41c11270b448a7 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 16 Dec 2018 20:56:57 +0100 Subject: book: add an example of conditional compilation of resources and tasks --- book/src/by-example/tips.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'book/src/by-example') diff --git a/book/src/by-example/tips.md b/book/src/by-example/tips.md index c163328..5057c80 100644 --- a/book/src/by-example/tips.md +++ b/book/src/by-example/tips.md @@ -20,6 +20,20 @@ rewrite code. If you consistently use `lock`s to access the data behind shared resources then your code will continue to compile when you change the priority of tasks. +## Conditional compilation + +You can use conditional compilation (`#[cfg]`) on resources (`static [mut]` +items) and tasks (`fn` items). The effect of using `#[cfg]` attributes is that +the resource / task will *not* be injected into the prelude of tasks that use +them (see `resources`, `spawn` and `schedule`) if the condition doesn't hold. + +The example below logs a message whenever the `foo` task is spawned, but only if +the program has been compiled using the `dev` profile. + +``` rust +{{#include ../../../examples/cfg.rs}} +``` + ## Running tasks from RAM The main goal of moving the specification of RTFM applications to attributes in -- cgit v1.2.3 From d98f6c9a61267abe00a827ac6c668b50b2bac714 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 16 Dec 2018 21:19:19 +0100 Subject: v0.4.0 --- book/src/by-example/app.md | 6 +++--- book/src/by-example/new.md | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'book/src/by-example') diff --git a/book/src/by-example/app.md b/book/src/by-example/app.md index ae0f4b8..26aa03f 100644 --- a/book/src/by-example/app.md +++ b/book/src/by-example/app.md @@ -9,9 +9,9 @@ This is the smallest possible RTFM application: All RTFM applications use the [`app`] attribute (`#[app(..)]`). This attribute must be applied to a `const` item that contains items. The `app` attribute has a mandatory `device` argument that takes a *path* as a value. This path must -point to a *device* crate generated using [`svd2rust`] **v0.14.x**. The `app` -attribute will expand into a suitable entry point so it's not required to use -the [`cortex_m_rt::entry`] attribute. +point to a *peripheral access crate* (PAC) generated using [`svd2rust`] +**v0.14.x**. The `app` attribute will expand into a suitable entry point so it's +not required to use the [`cortex_m_rt::entry`] attribute. [`app`]: ../../api/cortex_m_rtfm_macros/attr.app.html [`svd2rust`]: https://crates.io/crates/svd2rust diff --git a/book/src/by-example/new.md b/book/src/by-example/new.md index b6c4643..b7d18a7 100644 --- a/book/src/by-example/new.md +++ b/book/src/by-example/new.md @@ -16,9 +16,9 @@ $ cargo generate \ $ # follow the rest of the instructions ``` -2. Add a device crate that was generated using [`svd2rust`] **v0.14.x**, or a - board support crate that depends on one such device crate as a dependency. - Make sure that the `rt` feature of the crate is enabled. +2. Add a peripheral access crate (PAC) that was generated using [`svd2rust`] + **v0.14.x**, or a board support crate that depends on one such PAC as a + dependency. Make sure that the `rt` feature of the crate is enabled. [`svd2rust`]: https://crates.io/crates/svd2rust @@ -40,7 +40,7 @@ $ rm memory.x build.rs `timer-queue` feature. ``` console -$ cargo add cortex-m-rtfm --allow-prerelease --upgrade=none +$ cargo add cortex-m-rtfm ``` 4. Write your RTFM application. @@ -49,7 +49,7 @@ Here I'll use the `init` example from the `cortex-m-rtfm` crate. ``` console $ curl \ - -L https://github.com/japaric/cortex-m-rtfm/raw/v0.4.0-beta.1/examples/init.rs \ + -L https://github.com/japaric/cortex-m-rtfm/raw/v0.4.0/examples/init.rs \ > src/main.rs ``` -- cgit v1.2.3 From 5b032243e63e230c504d52ad85d4f275adf1d58d Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 16 Dec 2018 21:24:10 +0100 Subject: book: add some notes about the timer queue --- book/src/by-example/timer-queue.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'book/src/by-example') diff --git a/book/src/by-example/timer-queue.md b/book/src/by-example/timer-queue.md index a9c3622..f8066c2 100644 --- a/book/src/by-example/timer-queue.md +++ b/book/src/by-example/timer-queue.md @@ -1,8 +1,16 @@ # Timer queue When the `timer-queue` feature is enabled the RTFM framework includes a *global -timer queue* that applications can use to *schedule* software tasks to run some -time in the future. +timer queue* that applications can use to *schedule* software tasks to run at +some time in the future. + +> **NOTE**: The timer-queue feature can't be enabled when the target is +> `thumbv6m-none-eabi` because there's no timer queue support for ARMv6-M. This +> may change in the future. + +> **NOTE**: When the `timer-queue` feature is enabled you will *not* be able to +> use the `SysTick` exception as a hardware task because the runtime uses it to +> implement the global timer queue. To be able to schedule a software task the name of the task must appear in the `schedule` argument of the context attribute. When scheduling a task the -- cgit v1.2.3