Skip to content

Commit 6216224

Browse files
Merge #741
741: Docs 2 r=korken89 a=datdenkikniet Working on the migration guide and other docs TODO: - [x] Migration guide - [x] Hardcoded examples should link to example code that is tested (this was already done, AFAICT) - [x] Address #699 - [x] Discuss: should we remove references to non-v2, apart from the migration guide and link to the book for v1? (Off-github conclusion: yes) - [x] RTIC {vs,and} Embassy (important: distinction between embassy runtime & HALs) - [x] More descriptive docs on how to implement & PR implementations of `Monotonic` to `rtic-monotonics` Co-authored-by: datdenkikniet <[email protected]>
2 parents 21b0d97 + 9fa073f commit 6216224

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+584
-259
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/target
66
Cargo.lock
77
*.hex
8+
book-target/

book/en/src/by-example/monotonic.md renamed to book/en/archive/by_example/monotonic.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This activates the monotonics making it possible to use them.
3434

3535
See the following example:
3636

37-
``` rust
37+
``` rust,noplayground
3838
{{#include ../../../../examples/schedule.rs}}
3939
```
4040

@@ -54,7 +54,7 @@ which allows canceling or rescheduling of the task scheduled to run in the futur
5454
If `cancel` or `reschedule_at`/`reschedule_after` returns an `Err` it means that the operation was
5555
too late and that the task is already sent for execution. The following example shows this in action:
5656

57-
``` rust
57+
``` rust,noplayground
5858
{{#include ../../../../examples/cancel-reschedule.rs}}
5959
```
6060

book/en/src/by-example/tips_from_ram.md renamed to book/en/archive/by_example/tips/from_ram.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ improve performance in some cases.
1111

1212
The example below shows how to place the higher priority task, `bar`, in RAM.
1313

14-
``` rust
15-
{{#include ../../../../rtic/examples/ramfunc.rs}}
14+
``` rust,noplayground
15+
{{#include ../../../../../rtic/examples/ramfunc.rs}}
1616
```
1717

1818
Running this program produces the expected output.
@@ -22,7 +22,7 @@ $ cargo run --target thumbv7m-none-eabi --example ramfunc
2222
```
2323

2424
``` console
25-
{{#include ../../../../rtic/ci/expected/ramfunc.run}}
25+
{{#include ../../../../../rtic/ci/expected/ramfunc.run}}
2626
```
2727

2828
One can look at the output of `cargo-nm` to confirm that `bar` ended in RAM
@@ -33,13 +33,13 @@ $ cargo nm --example ramfunc --release | grep ' foo::'
3333
```
3434

3535
``` console
36-
{{#include ../../../../rtic/ci/expected/ramfunc.run.grep.foo}}
36+
{{#include ../../../../../rtic/ci/expected/ramfunc.run.grep.foo}}
3737
```
3838

3939
``` console
4040
$ cargo nm --example ramfunc --target thumbv7m-none-eabi --release | grep '*bar::'
4141
```
4242

4343
``` console
44-
{{#include ../../../../rtic/ci/expected/ramfunc.run.grep.bar}}
44+
{{#include ../../../../../rtic/ci/expected/ramfunc.run.grep.bar}}
4545
```
File renamed without changes.

book/en/src/migration/migration_rtic.md renamed to book/en/archive/migration/migration_rtic.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ cortex-m-rtic = "0.5.3"
2727
The only code change that needs to be made is that any reference to `rtfm` before now need to point
2828
to `rtic` as follows:
2929

30-
``` rust
30+
``` rust,noplayground
3131
//
3232
// Change this
3333
//

book/en/src/migration/migration_v4.md renamed to book/en/archive/migration/migration_v4.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ framework: `resources`, `spawn`, `schedule` -- these variables will become
4242
fields of the `Context` structure. Each function within the `#[rtfm::app]` item
4343
gets a different `Context` type.
4444

45-
``` rust
45+
``` rust,noplayground
4646
#[rtfm::app(/* .. */)]
4747
const APP: () = {
4848
// change this
@@ -90,7 +90,7 @@ const APP: () = {
9090
The syntax used to declare resources has changed from `static mut`
9191
variables to a `struct Resources`.
9292

93-
``` rust
93+
``` rust,noplayground
9494
#[rtfm::app(/* .. */)]
9595
const APP: () = {
9696
// change this
@@ -118,7 +118,7 @@ the `device` field of the `init::Context` structure.
118118

119119
Change this:
120120

121-
``` rust
121+
``` rust,noplayground
122122
#[rtfm::app(/* .. */)]
123123
const APP: () = {
124124
#[init]
@@ -132,7 +132,7 @@ const APP: () = {
132132

133133
Into this:
134134

135-
``` rust
135+
``` rust,noplayground
136136
#[rtfm::app(/* .. */, peripherals = true)]
137137
// ^^^^^^^^^^^^^^^^^^
138138
const APP: () = {
@@ -155,7 +155,7 @@ attribute with the `binds` argument instead.
155155

156156
Change this:
157157

158-
``` rust
158+
``` rust,noplayground
159159
#[rtfm::app(/* .. */)]
160160
const APP: () = {
161161
// hardware tasks
@@ -175,7 +175,7 @@ const APP: () = {
175175

176176
Into this:
177177

178-
``` rust
178+
``` rust,noplayground
179179
#[rtfm::app(/* .. */)]
180180
const APP: () = {
181181
#[task(binds = SVCall)]
@@ -212,7 +212,7 @@ ensure it is enabled by the application inside `init`.
212212

213213
Change this:
214214

215-
``` rust
215+
``` rust,noplayground
216216
use rtfm::{Duration, Instant, U32Ext};
217217
218218
#[rtfm::app(/* .. */)]
@@ -226,7 +226,7 @@ const APP: () = {
226226

227227
Into this:
228228

229-
``` rust
229+
``` rust,noplayground
230230
use rtfm::cyccnt::{Duration, Instant, U32Ext};
231231
// ^^^^^^^^
232232

book/en/src/migration/migration_v5.md renamed to book/en/archive/migration/migration_v5.md

+18-18
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ With the support of attributes on modules the `const APP` workaround is not need
1212

1313
Change
1414

15-
``` rust
15+
``` rust,noplayground
1616
#[rtic::app(/* .. */)]
1717
const APP: () = {
1818
[code here]
@@ -21,7 +21,7 @@ const APP: () = {
2121

2222
into
2323

24-
``` rust
24+
``` rust,noplayground
2525
#[rtic::app(/* .. */)]
2626
mod app {
2727
[code here]
@@ -75,7 +75,7 @@ mod app {
7575

7676
Change
7777

78-
``` rust
78+
``` rust,noplayground
7979
#[rtic::app(/* .. */)]
8080
const APP: () = {
8181
[code here]
@@ -92,7 +92,7 @@ const APP: () = {
9292

9393
into
9494

95-
``` rust
95+
``` rust,noplayground
9696
#[rtic::app(/* .. */, dispatchers = [SSI0, QEI0])]
9797
mod app {
9898
[code here]
@@ -106,7 +106,7 @@ This works also for ram functions, see examples/ramfunc.rs
106106

107107
Previously the RTIC resources had to be in in a struct named exactly "Resources":
108108

109-
``` rust
109+
``` rust,noplayground
110110
struct Resources {
111111
// Resources defined in here
112112
}
@@ -115,7 +115,7 @@ struct Resources {
115115
With RTIC v1.0.0 the resources structs are annotated similarly like
116116
`#[task]`, `#[init]`, `#[idle]`: with the attributes `#[shared]` and `#[local]`
117117

118-
``` rust
118+
``` rust,noplayground
119119
#[shared]
120120
struct MySharedResources {
121121
// Resources shared between tasks are defined here
@@ -136,7 +136,7 @@ In v1.0.0 resources are split between `shared` resources and `local` resources.
136136

137137
In v0.5.x:
138138

139-
``` rust
139+
``` rust,noplayground
140140
struct Resources {
141141
local_to_b: i64,
142142
shared_by_a_and_b: i64,
@@ -151,7 +151,7 @@ fn b(_: b::Context) {}
151151

152152
In v1.0.0:
153153

154-
``` rust
154+
``` rust,noplayground
155155
#[shared]
156156
struct Shared {
157157
shared_by_a_and_b: i64,
@@ -176,7 +176,7 @@ to be used for all `shared` resource access.
176176
In old code one could do the following as the high priority
177177
task has exclusive access to the resource:
178178

179-
``` rust
179+
``` rust,noplayground
180180
#[task(priority = 2, resources = [r])]
181181
fn foo(cx: foo::Context) {
182182
cx.resources.r = /* ... */;
@@ -190,7 +190,7 @@ fn bar(cx: bar::Context) {
190190

191191
And with symmetric locks one needs to use locks in both tasks:
192192

193-
``` rust
193+
``` rust,noplayground
194194
#[task(priority = 2, shared = [r])]
195195
fn foo(cx: foo::Context) {
196196
cx.shared.r.lock(|r| r = /* ... */);
@@ -211,7 +211,7 @@ This is still possible in 1.0: the `#[shared]` resource must be annotated with t
211211

212212
v0.5 code:
213213

214-
``` rust
214+
``` rust,noplayground
215215
struct Resources {
216216
counter: u64,
217217
}
@@ -229,7 +229,7 @@ fn b(cx: b::Context) {
229229

230230
v1.0 code:
231231

232-
``` rust
232+
``` rust,noplayground
233233
#[shared]
234234
struct Shared {
235235
#[lock_free]
@@ -254,7 +254,7 @@ Instead of that syntax, use the `local` argument in `#[init]`.
254254

255255
v0.5.x code:
256256

257-
``` rust
257+
``` rust,noplayground
258258
#[init]
259259
fn init(_: init::Context) {
260260
static mut BUFFER: [u8; 1024] = [0; 1024];
@@ -264,7 +264,7 @@ fn init(_: init::Context) {
264264

265265
v1.0.0 code:
266266

267-
``` rust
267+
``` rust,noplayground
268268
#[init(local = [
269269
buffer: [u8; 1024] = [0; 1024]
270270
// type ^^^^^^^^^^^^ ^^^^^^^^^ initial value
@@ -282,7 +282,7 @@ In order to make the API more symmetric the #[init]-task always returns a late r
282282

283283
From this:
284284

285-
``` rust
285+
``` rust,noplayground
286286
#[rtic::app(device = lm3s6965)]
287287
const APP: () = {
288288
#[init]
@@ -296,7 +296,7 @@ const APP: () = {
296296

297297
to this:
298298

299-
``` rust
299+
``` rust,noplayground
300300
#[rtic::app(device = lm3s6965)]
301301
mod app {
302302
#[shared]
@@ -321,7 +321,7 @@ mod app {
321321
With the new spawn/spawn_after/spawn_at interface,
322322
old code requiring the context `cx` for spawning such as:
323323

324-
``` rust
324+
``` rust,noplayground
325325
#[task(spawn = [bar])]
326326
fn foo(cx: foo::Context) {
327327
cx.spawn.bar().unwrap();
@@ -335,7 +335,7 @@ fn bar(cx: bar::Context) {
335335

336336
Will now be written as:
337337

338-
``` rust
338+
``` rust,noplayground
339339
#[task]
340340
fn foo(_c: foo::Context) {
341341
bar::spawn().unwrap();

book/en/src/SUMMARY.md

+24-15
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,40 @@
22

33
[Preface](./preface.md)
44

5+
---
6+
7+
- [Starting a new project](./starting_a_project.md)
58
- [RTIC by example](./by-example.md)
69
- [The `app`](./by-example/app.md)
7-
- [Hardware tasks & `pend`](./by-example/hardware_tasks.md)
10+
- [Hardware tasks](./by-example/hardware_tasks.md)
811
- [Software tasks & `spawn`](./by-example/software_tasks.md)
912
- [Resources](./by-example/resources.md)
1013
- [The init task](./by-example/app_init.md)
1114
- [The idle task](./by-example/app_idle.md)
1215
- [Channel based communication](./by-example/channel.md)
13-
- [Delay and Timeout](./by-example/delay.md)
14-
- [Starting a new project](./by-example/starting_a_project.md)
16+
- [Delay and Timeout using Monotonics](./by-example/delay.md)
1517
- [The minimal app](./by-example/app_minimal.md)
16-
- [Tips & Tricks](./by-example/tips.md)
17-
- [Implementing Monotonic](./by-example/tips_monotonic_impl.md)
18-
- [Resource de-structure-ing](./by-example/tips_destructureing.md)
19-
- [Avoid copies when message passing](./by-example/tips_indirection.md)
20-
- [`'static` super-powers](./by-example/tips_static_lifetimes.md)
21-
- [Inspecting generated code](./by-example/tips_view_code.md)
22-
<!-- - [Running tasks from RAM](./by-example/tips_from_ram.md) -->
23-
<!-- - [`#[cfg(..)]` support](./by-example/tips.md) -->
18+
- [Tips & Tricks](./by-example/tips/index.md)
19+
- [Resource de-structure-ing](./by-example/tips/destructureing.md)
20+
- [Avoid copies when message passing](./by-example/tips/indirection.md)
21+
- [`'static` super-powers](./by-example/tips/static_lifetimes.md)
22+
- [Inspecting generated code](./by-example/tips/view_code.md)
23+
- [Monotonics & the Timer Queue](./monotonic_impl.md)
2424
- [RTIC vs. the world](./rtic_vs.md)
25+
- [RTIC and Embassy](./rtic_and_embassy.md)
2526
- [Awesome RTIC examples](./awesome_rtic.md)
26-
<!-- - [Migration Guides](./migration.md)
27-
- [v0.5.x to v1.0.x](./migration/migration_v5.md)
28-
- [v0.4.x to v0.5.x](./migration/migration_v4.md)
29-
- [RTFM to RTIC](./migration/migration_rtic.md) -->
27+
28+
---
29+
30+
- [Migrating from v1.0.x to v2.0.0](./migration_v1_v2.md)
31+
- [Rust Nightly & features](./migration_v1_v2/nightly.md)
32+
- [Migrating to `rtic-monotonics`](./migration_v1_v2/monotonics.md)
33+
- [Software tasks must now be `async`](./migration_v1_v2/async_tasks.md)
34+
- [Using and understanding `rtic-sync`](./migration_v1_v2/rtic-sync.md)
35+
- [A code example on migration](./migration_v1_v2/complete_example.md)
36+
37+
---
38+
3039
- [Under the hood](./internals.md)
3140
- [Cortex-M architectures](./internals/targets.md)
3241
<!--- [Interrupt configuration](./internals/interrupt-configuration.md)-->

book/en/src/awesome_rtic.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Awesome RTIC examples
22

3-
See the [`rtic-rs/rtic-examples`][rticexamples] repository for community
4-
provided complete examples.
3+
See the [`rtic-rs/rtic/examples`][rticexamples] repository for complete examples.
54

6-
Pull-requests to this repo are welcome!
5+
Pull-requests are welcome!
76

8-
[rticexamples]: https://github.com/rtic-rs/rtic-examples
7+
[rticexamples]: https://github.com/rtic-rs/rtic/tree/master/examples

0 commit comments

Comments
 (0)