diff options
Diffstat (limited to 'book')
| -rw-r--r-- | book/en/src/by-example/app.md | 5 | ||||
| -rw-r--r-- | book/en/src/migration/migration_v5.md | 49 |
2 files changed, 46 insertions, 8 deletions
diff --git a/book/en/src/by-example/app.md b/book/en/src/by-example/app.md index 6a01193..50f2842 100644 --- a/book/en/src/by-example/app.md +++ b/book/en/src/by-example/app.md @@ -23,9 +23,8 @@ to use the [`cortex_m_rt::entry`] attribute. ## `init` Within the `app` module the attribute expects to find an initialization -function marked with the `init` attribute. This function must have signature -`fn(init::Context) [-> init::LateResources]` (the return type is not always -required). +function marked with the `init` attribute. This function must have +signature `fn(init::Context) -> (init::LateResources, init::Monotonics)`. 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 diff --git a/book/en/src/migration/migration_v5.md b/book/en/src/migration/migration_v5.md index 8edefd2..505a8b6 100644 --- a/book/en/src/migration/migration_v5.md +++ b/book/en/src/migration/migration_v5.md @@ -30,7 +30,46 @@ mod app { Now that a regular Rust module is used it means it is possible to have custom user code within that module. -Additionally, it means that `use`-statements for resources etc may be required. +Additionally, it means that `use`-statements for resources used in user +code must be moved inside `mod app`, or be referred to with `super`. For +example, change: + +```rust +use some_crate::some_func; + +#[rtic::app(/* .. */)] +const APP: () = { + fn func() { + some_crate::some_func(); + } +}; +``` + +into + +```rust +#[rtic::app(/* .. */)] +mod app { + use some_crate::some_func; + + fn func() { + some_crate::some_func(); + } +} +``` + +or + +```rust +use some_crate::some_func; + +#[rtic::app(/* .. */)] +mod app { + fn func() { + super::some_crate::some_func(); + } +}; +``` ## Move Dispatchers from `extern "C"` to app arguments. @@ -71,14 +110,14 @@ From this: ``` rust #[rtic::app(device = lm3s6965)] -mod app { +const APP: () = { #[init] fn init(_: init::Context) { rtic::pend(Interrupt::UART0); } // [more code] -} +}; ``` to this: @@ -87,10 +126,10 @@ to this: #[rtic::app(device = lm3s6965)] mod app { #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { rtic::pend(Interrupt::UART0); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } // [more code] |
