diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-05-23 06:26:28 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-23 06:26:28 +0000 |
| commit | 62162241d4c7d82dfbb310113f7525d134cfde9b (patch) | |
| tree | 4346cbe248835eba381003d8592248102028dac5 /book/en/src/internals/critical-sections.md | |
| parent | 21b0d97e17922c023a3b5d8148a414d4277f7b87 (diff) | |
| parent | 9fa073f7936782bddf5d02b7b1949032e84de1bd (diff) | |
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 <jcdra1@gmail.com>
Diffstat (limited to 'book/en/src/internals/critical-sections.md')
| -rw-r--r-- | book/en/src/internals/critical-sections.md | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/book/en/src/internals/critical-sections.md b/book/en/src/internals/critical-sections.md index a064ad0..cd66c2b 100644 --- a/book/en/src/internals/critical-sections.md +++ b/book/en/src/internals/critical-sections.md @@ -30,7 +30,7 @@ task we give it a *resource proxy*, whereas we give a unique reference The example below shows the different types handed out to each task: -``` rust +``` rust,noplayground #[rtic::app(device = ..)] mut app { struct Resources { @@ -62,7 +62,7 @@ mut app { Now let's see how these types are created by the framework. -``` rust +``` rust,noplayground fn foo(c: foo::Context) { // .. user code .. } @@ -149,7 +149,7 @@ The semantics of the `BASEPRI` register are as follows: Thus the dynamic priority at any point in time can be computed as -``` rust +``` rust,noplayground dynamic_priority = max(hw2logical(BASEPRI), hw2logical(static_priority)) ``` @@ -160,7 +160,7 @@ In this particular example we could implement the critical section as follows: > **NOTE:** this is a simplified implementation -``` rust +``` rust,noplayground impl rtic::Mutex for resources::x { type T = u64; @@ -194,7 +194,7 @@ calls to it. This is required for memory safety, as nested calls would produce multiple unique references (`&mut-`) to `x` breaking Rust aliasing rules. See below: -``` rust +``` rust,noplayground #[interrupt(binds = UART0, priority = 1, resources = [x])] fn foo(c: foo::Context) { // resource proxy @@ -223,7 +223,7 @@ provides extra information to the compiler. Consider this program: -``` rust +``` rust,noplayground #[rtic::app(device = ..)] mod app { struct Resources { @@ -282,7 +282,7 @@ mod app { The code generated by the framework looks like this: -``` rust +``` rust,noplayground // omitted: user code pub mod resources { @@ -374,7 +374,7 @@ mod app { At the end the compiler will optimize the function `foo` into something like this: -``` rust +``` rust,noplayground fn foo(c: foo::Context) { // NOTE: BASEPRI contains the value `0` (its reset value) at this point @@ -428,7 +428,7 @@ should not result in an observable change of BASEPRI. This invariant needs to be preserved to avoid raising the dynamic priority of a handler through preemption. This is best observed in the following example: -``` rust +``` rust,noplayground #[rtic::app(device = ..)] mod app { struct Resources { @@ -490,7 +490,7 @@ mod app { IMPORTANT: let's say we *forget* to roll back `BASEPRI` in `UART1` -- this would be a bug in the RTIC code generator. -``` rust +``` rust,noplayground // code generated by RTIC mod app { |
