aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmil Fresk <emil.fresk@gmail.com>2021-02-22 21:45:22 +0100
committerEmil Fresk <emil.fresk@gmail.com>2021-02-22 21:47:59 +0100
commit26870ae12ede1a70ca5685a7c0e0113c6bed58dd (patch)
tree6292fbb2c4527ecb955198d69d7650fcf24c6c92
parent56d99c02bd809dfa96d6c1f102e046533c5c631f (diff)
Use zero time in init for `spawn_after` to not cause panic
-rw-r--r--macros/src/codegen/module.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs
index 76641fa..b0ac65f 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)*)
}