diff options
author | 2021-02-22 20:59:03 +0100 | |
---|---|---|
committer | 2021-02-22 20:59:03 +0100 | |
commit | 82d051e8e967522af735fff47a1738ce4952f950 (patch) | |
tree | c4e921ef5d6203e732b8ec7a0b25b3ad42d05066 /macros/src | |
parent | e52088bbd8f4f15b0d49ced8a24c5a2fc8c8c11f (diff) | |
download | rtic-82d051e8e967522af735fff47a1738ce4952f950.tar.gz rtic-82d051e8e967522af735fff47a1738ce4952f950.tar.zst rtic-82d051e8e967522af735fff47a1738ce4952f950.zip |
Added enable/disable timer calls
Diffstat (limited to 'macros/src')
-rw-r--r-- | macros/src/codegen/module.rs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index f0f403b2..76641fae 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -230,11 +230,13 @@ pub fn codegen( // Schedule caller for (_, monotonic) in &app.monotonics { let instants = util::monotonic_instants_ident(name, &monotonic.ident); + let monotonic_name = monotonic.ident.to_string(); let tq = util::tq_ident(&monotonic.ident.to_string()); let t = util::schedule_t_ident(); let m = &monotonic.ident; - let m_mangled = util::mangle_monotonic_type(&monotonic.ident.to_string()); + let m_mangled = util::mangle_monotonic_type(&monotonic_name); + let m_ident = util::monotonic_ident(&monotonic_name); let m_isr = &monotonic.args.binds; let enum_ = util::interrupt_ident(); @@ -296,11 +298,18 @@ pub fn codegen( task: #app_path::#t::#name, }; - rtic::export::interrupt::free(|_| #app_path::#tq.enqueue_unchecked( - nr, - || #enable_interrupt, - || #pend, - )); + rtic::export::interrupt::free(|_| + if let Some(mono) = #app_path::#m_ident.as_mut() { + #app_path::#tq.enqueue_unchecked( + nr, + || #enable_interrupt, + || #pend, + mono) + } else { + // We can only use the timer queue if `init` has returned, and it + // writes the `Some(monotonic)` we are accessing here. + core::hint::unreachable_unchecked() + }); Ok(()) } else { |