Added enable/disable timer calls

This commit is contained in:
Emil Fresk 2021-02-22 20:59:03 +01:00
parent e52088bbd8
commit 82d051e8e9
2 changed files with 19 additions and 7 deletions

View file

@ -230,11 +230,13 @@ pub fn codegen(
// Schedule caller // Schedule caller
for (_, monotonic) in &app.monotonics { for (_, monotonic) in &app.monotonics {
let instants = util::monotonic_instants_ident(name, &monotonic.ident); 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 tq = util::tq_ident(&monotonic.ident.to_string());
let t = util::schedule_t_ident(); let t = util::schedule_t_ident();
let m = &monotonic.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 m_isr = &monotonic.args.binds;
let enum_ = util::interrupt_ident(); let enum_ = util::interrupt_ident();
@ -296,11 +298,18 @@ pub fn codegen(
task: #app_path::#t::#name, task: #app_path::#t::#name,
}; };
rtic::export::interrupt::free(|_| #app_path::#tq.enqueue_unchecked( rtic::export::interrupt::free(|_|
nr, if let Some(mono) = #app_path::#m_ident.as_mut() {
|| #enable_interrupt, #app_path::#tq.enqueue_unchecked(
|| #pend, 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(()) Ok(())
} else { } else {

View file

@ -29,6 +29,7 @@ where
nr: NotReady<Mono, Task>, nr: NotReady<Mono, Task>,
enable_interrupt: F1, enable_interrupt: F1,
pend_handler: F2, pend_handler: F2,
mono: &mut Mono,
) where ) where
F1: FnOnce(), F1: FnOnce(),
F2: FnOnce(), F2: FnOnce(),
@ -46,7 +47,8 @@ where
.unwrap_or(true); .unwrap_or(true);
if if_heap_max_greater_than_nr { if if_heap_max_greater_than_nr {
if Mono::DISABLE_INTERRUPT_ON_EMPTY_QUEUE && is_empty { if Mono::DISABLE_INTERRUPT_ON_EMPTY_QUEUE && is_empty {
// mem::transmute::<_, SYST>(()).enable_interrupt(); // mem::transmute::<_, SYST>(()).enable_interrupt();A
mono.enable_timer();
enable_interrupt(); enable_interrupt();
} }
@ -108,6 +110,7 @@ where
// The queue is empty, disable the interrupt. // The queue is empty, disable the interrupt.
if Mono::DISABLE_INTERRUPT_ON_EMPTY_QUEUE { if Mono::DISABLE_INTERRUPT_ON_EMPTY_QUEUE {
disable_interrupt(); disable_interrupt();
mono.disable_timer();
} }
None None