mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-19 22:35:19 +01:00
Remove linked list impl - use heapless, linked list init now const fn
This commit is contained in:
parent
74b3964978
commit
bc3eb5c547
8 changed files with 16 additions and 625 deletions
|
|
@ -327,7 +327,7 @@ pub fn codegen(
|
|||
impl #internal_spawn_handle_ident {
|
||||
pub fn cancel(self) -> Result<#ty, ()> {
|
||||
rtic::export::interrupt::free(|_| unsafe {
|
||||
let tq = &mut *#tq.get_mut_unchecked().as_mut_ptr();
|
||||
let tq = #tq.get_mut_unchecked();
|
||||
if let Some((_task, index)) = tq.cancel_marker(self.marker) {
|
||||
// Get the message
|
||||
let msg = #inputs
|
||||
|
|
@ -359,7 +359,7 @@ pub fn codegen(
|
|||
let marker = *#tq_marker.get_mut_unchecked();
|
||||
*#tq_marker.get_mut_unchecked() = #tq_marker.get_mut_unchecked().wrapping_add(1);
|
||||
|
||||
let tq = &mut *#tq.get_mut_unchecked().as_mut_ptr();
|
||||
let tq = #tq.get_mut_unchecked();
|
||||
|
||||
tq.update_marker(self.marker, marker, instant, || #pend).map(|_| #name::#m::SpawnHandle { marker })
|
||||
})
|
||||
|
|
@ -420,7 +420,7 @@ pub fn codegen(
|
|||
|
||||
*#tq_marker.get_mut_unchecked() = #tq_marker.get_mut_unchecked().wrapping_add(1);
|
||||
|
||||
let tq = &mut *#tq.get_mut_unchecked().as_mut_ptr();
|
||||
let tq = #tq.get_mut_unchecked();
|
||||
|
||||
tq.enqueue_unchecked(
|
||||
nr,
|
||||
|
|
|
|||
|
|
@ -77,18 +77,10 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
|||
);));
|
||||
}
|
||||
|
||||
// Initialize monotonic's interrupts and timer queues
|
||||
// Initialize monotonic's interrupts
|
||||
for (_, monotonic) in &app.monotonics {
|
||||
let priority = &monotonic.args.priority;
|
||||
let binds = &monotonic.args.binds;
|
||||
let monotonic_name = monotonic.ident.to_string();
|
||||
let tq = util::tq_ident(&monotonic_name);
|
||||
let tq = util::mark_internal_ident(&tq);
|
||||
|
||||
// Initialize timer queues
|
||||
stmts.push(
|
||||
quote!(#tq.get_mut_unchecked().as_mut_ptr().write(rtic::export::TimerQueue::new());),
|
||||
);
|
||||
|
||||
// Compile time assert that this priority is supported by the device
|
||||
stmts.push(quote!(let _ = [(); ((1 << #nvic_prio_bits) - #priority as usize)];));
|
||||
|
|
|
|||
|
|
@ -62,21 +62,20 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
|||
{
|
||||
// For future use
|
||||
// let doc = &format!("Timer queue for {}", monotonic_name);
|
||||
let cap: u8 = app
|
||||
let cap: usize = app
|
||||
.software_tasks
|
||||
.iter()
|
||||
.map(|(_name, task)| task.args.capacity)
|
||||
.map(|(_name, task)| task.args.capacity as usize)
|
||||
.sum();
|
||||
let n = util::capacity_literal(cap as usize);
|
||||
let tq_ty =
|
||||
quote!(core::mem::MaybeUninit<rtic::export::TimerQueue<#mono_type, #t, #n>>);
|
||||
let n = util::capacity_literal(cap);
|
||||
let tq_ty = quote!(rtic::export::TimerQueue<#mono_type, #t, #n>);
|
||||
|
||||
// For future use
|
||||
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
|
||||
items.push(quote!(
|
||||
#[doc(hidden)]
|
||||
static #tq: rtic::RacyCell<#tq_ty> =
|
||||
rtic::RacyCell::new(core::mem::MaybeUninit::uninit());
|
||||
rtic::RacyCell::new(rtic::export::TimerQueue(rtic::export::SortedLinkedList::new_u16()));
|
||||
));
|
||||
|
||||
let mono = util::monotonic_ident(&monotonic_name);
|
||||
|
|
@ -138,7 +137,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
|||
unsafe fn #bound_interrupt() {
|
||||
while let Some((task, index)) = rtic::export::interrupt::free(|_|
|
||||
if let Some(mono) = #m_ident.get_mut_unchecked().as_mut() {
|
||||
(&mut *#tq.get_mut_unchecked().as_mut_ptr()).dequeue(|| #disable_isr, mono)
|
||||
#tq.get_mut_unchecked().dequeue(|| #disable_isr, mono)
|
||||
} else {
|
||||
// We can only use the timer queue if `init` has returned, and it
|
||||
// writes the `Some(monotonic)` we are accessing here.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue