diff --git a/embedded-workshop-book/src/rtic-hello.md b/embedded-workshop-book/src/rtic-hello.md index 26d2a7a..5966f71 100644 --- a/embedded-workshop-book/src/rtic-hello.md +++ b/embedded-workshop-book/src/rtic-hello.md @@ -14,11 +14,22 @@ RTIC makes a clearer distinction between the application's initialization phase, You can use `rustfmt` on `target/rtic-expansion.rs` to make the generated code easier to read. Among other things, the file should contain the following lines. Note that interrupts are disabled during the execution of the `init` function: -``` rust -fn main() -> ! { +```rust +unsafe extern "C" fn main() -> ! { rtic::export::interrupt::disable(); - let late = init(init::Context::new(/* .. */)); - rtic::export::interrupt::enable(); - idle(idle::Context::new(/* .. */)) + let mut core: rtic::export::Peripherals = rtic::export::Peripherals::steal().into(); + #[inline(never)] + fn __rtic_init_resources(f: F) + where + F: FnOnce(), + { + f(); + } + __rtic_init_resources(|| { + let (shared_resources, local_resources, mut monotonics) = + init(init::Context::new(core.into())); + rtic::export::interrupt::enable(); + }); + idle(idle::Context::new(&rtic::export::Priority::new(0))) } -``` +``` \ No newline at end of file