mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-12-28 04:49:33 +01:00
Merge #377
377: Updated documentation to include the critical section token in init r=AfoHT a=korken89 Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
This commit is contained in:
commit
35baf20c61
2 changed files with 8 additions and 3 deletions
|
@ -33,15 +33,16 @@ required).
|
|||
|
||||
This initialization function will be the first part of the application to run.
|
||||
The `init` function will run *with interrupts disabled* and has exclusive access
|
||||
to Cortex-M and, optionally, device specific peripherals through the `core` and
|
||||
`device` fields of `init::Context`.
|
||||
to Cortex-M where the `bare_metal::CriticalSection` token is available as `cs`.
|
||||
And optionally, device specific peripherals through the `core` and `device` fields
|
||||
of `init::Context`.
|
||||
|
||||
`static mut` variables declared at the beginning of `init` will be transformed
|
||||
into `&'static mut` references that are safe to access.
|
||||
|
||||
[`rtic::Peripherals`]: ../../api/rtic/struct.Peripherals.html
|
||||
|
||||
The example below shows the types of the `core` and `device` fields and
|
||||
The example below shows the types of the `core`, `device` and `cs` fields, and
|
||||
showcases safe access to a `static mut` variable. The `device` field is only
|
||||
available when the `peripherals` argument is set to `true` (it defaults to
|
||||
`false`).
|
||||
|
|
|
@ -23,6 +23,10 @@ const APP: () = {
|
|||
// Safe access to local `static mut` variable
|
||||
let _x: &'static mut u32 = X;
|
||||
|
||||
// Access to the critical section token,
|
||||
// to indicate that this is a critical seciton
|
||||
let _cs_token: bare_metal::CriticalSection = cx.cs;
|
||||
|
||||
hprintln!("init").unwrap();
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
|
Loading…
Reference in a new issue