aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/module.rs
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2021-02-22 21:45:22 +0100
committerGravatar Emil Fresk <emil.fresk@gmail.com> 2021-02-22 21:47:59 +0100
commit26870ae12ede1a70ca5685a7c0e0113c6bed58dd (patch)
tree6292fbb2c4527ecb955198d69d7650fcf24c6c92 /macros/src/codegen/module.rs
parent56d99c02bd809dfa96d6c1f102e046533c5c631f (diff)
downloadrtic-26870ae12ede1a70ca5685a7c0e0113c6bed58dd.tar.gz
rtic-26870ae12ede1a70ca5685a7c0e0113c6bed58dd.tar.zst
rtic-26870ae12ede1a70ca5685a7c0e0113c6bed58dd.zip
Use zero time in init for `spawn_after` to not cause panic
Diffstat (limited to '')
-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 76641fae..b0ac65f3 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)*)
}