From 26870ae12ede1a70ca5685a7c0e0113c6bed58dd Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Mon, 22 Feb 2021 21:45:22 +0100 Subject: [PATCH] Use zero time in init for `spawn_after` to not cause panic --- macros/src/codegen/module.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index 76641faed4..b0ac65f3ed 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -269,7 +269,12 @@ pub fn codegen( where D: rtic::time::duration::Duration + rtic::time::fixed_point::FixedPoint, D::T: Into<<#app_path::#m_mangled as rtic::time::Clock>::T>, { - let instant = #app_path::#m::now(); + + let instant = if rtic::export::interrupt::free(|_| unsafe { #app_path::#m_ident.is_none() }) { + rtic::time::Instant::new(0) + } else { + #app_path::#m::now() + }; spawn_at(instant + duration, #(,#untupled)*) }