Added critical sections

This commit is contained in:
Emil Fresk 2020-10-08 17:33:16 +02:00
parent 0bc2168cd6
commit e8b4fa7b32

View file

@ -350,13 +350,6 @@ pub fn codegen(
let device = extra.device; let device = extra.device;
let enum_ = util::interrupt_ident(); let enum_ = util::interrupt_ident();
let interrupt = &analysis.interrupts.get(&priority); let interrupt = &analysis.interrupts.get(&priority);
let pend = {
quote!(
rtic::pend(#device::#enum_::#interrupt);
)
};
eprintln!("pend {}", &pend);
items.push(quote!( items.push(quote!(
#(#cfgs)* #(#cfgs)*
@ -365,25 +358,26 @@ pub fn codegen(
use rtic::Mutex as _; use rtic::Mutex as _;
let input = #tupled; let input = #tupled;
// TODO: use critical section, now we are unsafe
if let Some(index) = rtic::export::interrupt::free(|_| #app_path::#fq.dequeue()) {
unsafe { unsafe {
if let Some(index) = #app_path::#fq.dequeue() {
#app_path::#inputs #app_path::#inputs
.get_unchecked_mut(usize::from(index)) .get_unchecked_mut(usize::from(index))
.as_mut_ptr() .as_mut_ptr()
.write(input); .write(input);
}
// #write_instant, do we need? rtic::export::interrupt::free(|_| {
#app_path::#rq.enqueue_unchecked((#app_path::#t::#name, index)); #app_path::#rq.enqueue_unchecked((#app_path::#t::#name, index));
});
#pend rtic::pend(#device::#enum_::#interrupt);
Ok(()) Ok(())
} else { } else {
Err(input) Err(input)
} }
}
})); }));
} }