diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index d15b5eca8a..93fbeaef03 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -135,7 +135,7 @@ pub fn codegen( /// Monotonics used by the system #[allow(non_snake_case)] pub struct Monotonics( - #(#monotonic_types),* + #(pub #monotonic_types),* ); )); } @@ -258,10 +258,13 @@ pub fn codegen( items.push(quote!( pub mod #m { #(#cfgs)* - pub fn spawn_after( - duration: rtic::time::duration::Duration, + pub fn spawn_after( + duration: D, #(,#args)* - ) -> Result<(), #ty> { + ) -> Result<(), #ty> + where D: rtic::time::duration::Duration + rtic::time::fixed_point::FixedPoint, + D::T: Into<<#app_path::#m as rtic::time::Clock>::T>, + { let instant = <#app_path::#m as rtic::Monotonic>::now(); spawn_at(instant + duration, #(,#untupled)*) diff --git a/macros/src/codegen/post_init.rs b/macros/src/codegen/post_init.rs index 9174daebcb..9268e040f1 100644 --- a/macros/src/codegen/post_init.rs +++ b/macros/src/codegen/post_init.rs @@ -25,6 +25,10 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec { } } + for (monotonic, _) in app.monotonics.iter() { + stmts.push(quote!(#monotonic::reset();)); + } + // Forget the monotonics so they won't be dropped. stmts.push(quote!(core::mem::forget(monotonics);)); diff --git a/macros/src/codegen/timer_queue.rs b/macros/src/codegen/timer_queue.rs index 99dfa5bf2a..9a430a0717 100644 --- a/macros/src/codegen/timer_queue.rs +++ b/macros/src/codegen/timer_queue.rs @@ -108,6 +108,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec