diff options
-rw-r--r-- | .github/workflows/build.yml | 1 | ||||
-rw-r--r-- | book/en/src/migration/migration_v5.md | 8 | ||||
-rw-r--r-- | examples/t-schedule.rs | 2 | ||||
-rw-r--r-- | macros/src/codegen.rs | 20 |
4 files changed, 24 insertions, 7 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e5f99434..93e32545 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -740,6 +740,7 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./bookstodeploy + force_orphan: true # Refs: https://github.com/rust-lang/crater/blob/9ab6f9697c901c4a44025cf0a39b73ad5b37d198/.github/workflows/bors.yml#L125-L149 # diff --git a/book/en/src/migration/migration_v5.md b/book/en/src/migration/migration_v5.md index d56d7ffd..505a8b6c 100644 --- a/book/en/src/migration/migration_v5.md +++ b/book/en/src/migration/migration_v5.md @@ -110,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: @@ -126,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] diff --git a/examples/t-schedule.rs b/examples/t-schedule.rs index 5e38dbaf..d7051609 100644 --- a/examples/t-schedule.rs +++ b/examples/t-schedule.rs @@ -40,7 +40,7 @@ mod app { let _: Result<(), ()> = handle.unwrap().cancel(); // Using default - let _: Result<foo::SpawnHandle, ()> = foo::spawn_at(monotonics::MyMono::now()); + let _: Result<foo::SpawnHandle, ()> = foo::spawn_at(monotonics::now()); let handle: Result<foo::SpawnHandle, ()> = foo::spawn_after(Seconds(1_u32)); let _: Result<foo::SpawnHandle, ()> = handle.unwrap().reschedule_after(Seconds(1_u32)); diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs index cf728a7d..e0e09bbe 100644 --- a/macros/src/codegen.rs +++ b/macros/src/codegen.rs @@ -66,9 +66,17 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { #(#pre_init_stmts)* - #call_init + #[inline(never)] + fn __rtic_init_resources<F>(f: F) where F: FnOnce() { + f(); + } + + // Wrap late_init_stmts in a function to ensure that stack space is reclaimed. + __rtic_init_resources(||{ + #call_init - #(#post_init_stmts)* + #(#post_init_stmts)* + }); #call_idle } @@ -111,7 +119,15 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { ); let user_imports = &app.user_imports; + let default_monotonic = if monotonic.args.default { + quote!(pub use #name::now;) + } else { + quote!() + }; + quote! { + #default_monotonic + #[doc = #doc] #[allow(non_snake_case)] pub mod #name { |