rtic/book/en/src/by-example.md

38 lines
1.4 KiB
Markdown
Raw Normal View History

2020-06-11 19:18:29 +02:00
# RTIC by example
2018-11-03 17:02:41 +01:00
2020-06-11 19:18:29 +02:00
This part of the book introduces the Real-Time Interrupt-driven Concurrency (RTIC) framework
2018-11-03 17:02:41 +01:00
to new users by walking them through examples of increasing complexity.
2021-12-14 22:46:15 +01:00
All examples in this part of the book are accessible at the
[GitHub repository][repoexamples].
The examples are runnable on QEMU (emulating a Cortex M3 target),
thus no special hardware required to follow along.
2018-11-03 17:02:41 +01:00
2021-12-14 22:46:15 +01:00
[repoexamples]: https://github.com/rtic-rs/cortex-m-rtic/tree/master/examples
2018-11-03 17:02:41 +01:00
2021-12-14 22:46:15 +01:00
To run the examples with QEMU you will need the `qemu-system-arm` program.
Check [the embedded Rust book] for instructions on how to set up an
2018-11-03 17:02:41 +01:00
embedded development environment that includes QEMU.
[the embedded Rust book]: https://rust-embedded.github.io/book/intro/install.html
2022-01-21 13:28:14 +01:00
To run the examples found in `examples/` locally, cargo needs a supported `target` and
either `--examples` (run all examples) or `--example NAME` to run a specific example.
Assuming dependencies in place, running:
``` console
$ cargo run --target thumbv7m-none-eabi --example locals
```
Yields this output:
``` console
{{#include ../../../ci/expected/locals.run}}
```
2022-09-27 17:29:03 +02:00
> **NOTE**: You can choose target device by passing a target
> triple to cargo (e.g. `cargo run --example init --target thumbv7m-none-eabi`) or
> configure a default target in `.cargo/config.toml`.
>
> For running the examples, we use a Cortex M3 emulated in QEMU, so the target is `thumbv7m-none-eabi`.