diff options
| author | Daniel Carosone <Daniel.Carosone@gmail.com> | 2020-10-07 09:22:38 +1100 |
|---|---|---|
| committer | Daniel Carosone <Daniel.Carosone@gmail.com> | 2020-10-07 09:22:38 +1100 |
| commit | f386cb63cb6d3cd6642debfb4dc1bde97b325550 (patch) | |
| tree | 30b21968997f809dbbba59117db93254607fa22d /book/en/src/internals/critical-sections.md | |
| parent | 3d6a0ea64fb2661ee1150a84425f50c18c2de9ad (diff) | |
| parent | b1e1abae29591e50ebf345a2bd249a73e564cea9 (diff) | |
Merge branch 'master'
of https://github.com/rtic-rs/cortex-m-rtic
Diffstat (limited to 'book/en/src/internals/critical-sections.md')
| -rw-r--r-- | book/en/src/internals/critical-sections.md | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/book/en/src/internals/critical-sections.md b/book/en/src/internals/critical-sections.md index f95a5a7..a064ad0 100644 --- a/book/en/src/internals/critical-sections.md +++ b/book/en/src/internals/critical-sections.md @@ -32,7 +32,7 @@ The example below shows the different types handed out to each task: ``` rust #[rtic::app(device = ..)] -const APP: () = { +mut app { struct Resources { #[init(0)] x: u64, @@ -57,7 +57,7 @@ const APP: () = { } // .. -}; +} ``` Now let's see how these types are created by the framework. @@ -99,7 +99,7 @@ pub mod bar { } } -const APP: () = { +mod app { static mut x: u64 = 0; impl rtic::Mutex for resources::x { @@ -129,7 +129,7 @@ const APP: () = { // .. }) } -}; +} ``` ## `lock` @@ -225,7 +225,7 @@ Consider this program: ``` rust #[rtic::app(device = ..)] -const APP: () = { +mod app { struct Resources { #[init(0)] x: u64, @@ -277,7 +277,7 @@ const APP: () = { } // .. -}; +} ``` The code generated by the framework looks like this: @@ -315,7 +315,7 @@ pub mod foo { } } -const APP: () = { +mod app { use cortex_m::register::basepri; #[no_mangle] @@ -368,7 +368,7 @@ const APP: () = { } // repeat for resource `y` -}; +} ``` At the end the compiler will optimize the function `foo` into something like @@ -430,7 +430,7 @@ handler through preemption. This is best observed in the following example: ``` rust #[rtic::app(device = ..)] -const APP: () = { +mod app { struct Resources { #[init(0)] x: u64, @@ -484,7 +484,7 @@ const APP: () = { // .. } -}; +} ``` IMPORTANT: let's say we *forget* to roll back `BASEPRI` in `UART1` -- this would @@ -493,7 +493,7 @@ be a bug in the RTIC code generator. ``` rust // code generated by RTIC -const APP: () = { +mod app { // .. #[no_mangle] @@ -513,7 +513,7 @@ const APP: () = { // BUG: FORGOT to roll back the BASEPRI to the snapshot value we took before basepri::write(initial); } -}; +} ``` The consequence is that `idle` will run at a dynamic priority of `2` and in fact |
