mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-29 15:04:32 +01:00
Documentation generation fixes
Test fixes
This commit is contained in:
parent
767d46e05b
commit
d351f55e1c
12 changed files with 114 additions and 96 deletions
|
@ -57,6 +57,7 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||||
|
|
||||||
let main = util::suffixed("main");
|
let main = util::suffixed("main");
|
||||||
mains.push(quote!(
|
mains.push(quote!(
|
||||||
|
#[doc(hidden)]
|
||||||
mod rtic_ext {
|
mod rtic_ext {
|
||||||
use super::*;
|
use super::*;
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -88,22 +89,6 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||||
let user_code = &app.user_code;
|
let user_code = &app.user_code;
|
||||||
let name = &app.name;
|
let name = &app.name;
|
||||||
let device = &extra.device;
|
let device = &extra.device;
|
||||||
|
|
||||||
// Get the list of all tasks
|
|
||||||
// Currently unused, might be useful
|
|
||||||
let task_list = analysis.tasks.clone();
|
|
||||||
|
|
||||||
let mut tasks = vec![];
|
|
||||||
|
|
||||||
if !task_list.is_empty() {
|
|
||||||
tasks.push(quote!(
|
|
||||||
#[allow(non_camel_case_types)]
|
|
||||||
pub enum Tasks {
|
|
||||||
#(#task_list),*
|
|
||||||
}
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
let app_name = &app.name;
|
let app_name = &app.name;
|
||||||
let app_path = quote! {crate::#app_name};
|
let app_path = quote! {crate::#app_name};
|
||||||
|
|
||||||
|
@ -114,25 +99,31 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||||
let name = &monotonic.ident;
|
let name = &monotonic.ident;
|
||||||
let name_str = &name.to_string();
|
let name_str = &name.to_string();
|
||||||
let ty = &monotonic.ty;
|
let ty = &monotonic.ty;
|
||||||
let mangled_name = util::mangle_monotonic_type(&name_str);
|
|
||||||
let ident = util::monotonic_ident(&name_str);
|
let ident = util::monotonic_ident(&name_str);
|
||||||
|
let ident = util::mark_internal_ident(&ident);
|
||||||
let panic_str = &format!(
|
let panic_str = &format!(
|
||||||
"Use of monotonic '{}' before it was passed to the runtime",
|
"Use of monotonic '{}' before it was passed to the runtime",
|
||||||
name_str
|
name_str
|
||||||
);
|
);
|
||||||
|
let doc = &format!(
|
||||||
|
"This module holds the static implementation for `{}::now()`",
|
||||||
|
name_str
|
||||||
|
);
|
||||||
|
let user_imports = &app.user_imports;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
pub use rtic::Monotonic as _;
|
pub use rtic::Monotonic as _;
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc = #doc]
|
||||||
pub type #mangled_name = #ty;
|
|
||||||
|
|
||||||
/// This module holds the static implementation for `#name::now()`
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub mod #name {
|
pub mod #name {
|
||||||
/// Access the global `Monotonic` implementation, not that this will panic
|
#(
|
||||||
/// before the this `Monotonic` has been passed to the RTIC runtime.
|
#[allow(unused_imports)]
|
||||||
pub fn now() -> rtic::time::Instant<#app_path::#mangled_name> {
|
#user_imports
|
||||||
|
)*
|
||||||
|
|
||||||
|
/// Read the current time from this monotonic
|
||||||
|
pub fn now() -> rtic::time::Instant<#ty> {
|
||||||
rtic::export::interrupt::free(|_| {
|
rtic::export::interrupt::free(|_| {
|
||||||
use rtic::Monotonic as _;
|
use rtic::Monotonic as _;
|
||||||
use rtic::time::Clock as _;
|
use rtic::time::Clock as _;
|
||||||
|
@ -182,9 +173,6 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||||
|
|
||||||
#(#root_software_tasks)*
|
#(#root_software_tasks)*
|
||||||
|
|
||||||
/// Unused
|
|
||||||
#(#tasks)*
|
|
||||||
|
|
||||||
/// app module
|
/// app module
|
||||||
#(#mod_app)*
|
#(#mod_app)*
|
||||||
|
|
||||||
|
|
|
@ -26,15 +26,16 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let doc = format!(
|
// let doc = format!(
|
||||||
"Software tasks to be dispatched at priority level {}",
|
// "Software tasks to be dispatched at priority level {}",
|
||||||
level,
|
// level,
|
||||||
);
|
// );
|
||||||
let t = util::spawn_t_ident(level);
|
let t = util::spawn_t_ident(level);
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
#[doc = #doc]
|
// #[doc = #doc]
|
||||||
|
#[doc(hidden)]
|
||||||
pub enum #t {
|
pub enum #t {
|
||||||
#(#variants,)*
|
#(#variants,)*
|
||||||
}
|
}
|
||||||
|
@ -42,6 +43,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
||||||
|
|
||||||
let n = util::capacity_typenum(channel.capacity, true);
|
let n = util::capacity_typenum(channel.capacity, true);
|
||||||
let rq = util::rq_ident(level);
|
let rq = util::rq_ident(level);
|
||||||
|
let rq = util::mark_internal_ident(&rq);
|
||||||
let (rq_ty, rq_expr) = {
|
let (rq_ty, rq_expr) = {
|
||||||
(
|
(
|
||||||
quote!(rtic::export::SCRQ<#t, #n>),
|
quote!(rtic::export::SCRQ<#t, #n>),
|
||||||
|
@ -51,12 +53,12 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let doc = format!(
|
// let doc = format!(
|
||||||
"Queue of tasks ready to be dispatched at priority level {}",
|
// "Queue of tasks ready to be dispatched at priority level {}",
|
||||||
level
|
// level
|
||||||
);
|
// );
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#[doc = #doc]
|
#[doc(hidden)]
|
||||||
static mut #rq: #rq_ty = #rq_expr;
|
static mut #rq: #rq_ty = #rq_expr;
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -67,7 +69,9 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
||||||
let task = &app.software_tasks[name];
|
let task = &app.software_tasks[name];
|
||||||
let cfgs = &task.cfgs;
|
let cfgs = &task.cfgs;
|
||||||
let fq = util::fq_ident(name);
|
let fq = util::fq_ident(name);
|
||||||
|
let fq = util::mark_internal_ident(&fq);
|
||||||
let inputs = util::inputs_ident(name);
|
let inputs = util::inputs_ident(name);
|
||||||
|
let inputs = util::mark_internal_ident(&inputs);
|
||||||
let (_, tupled, pats, _) = util::regroup_inputs(&task.inputs);
|
let (_, tupled, pats, _) = util::regroup_inputs(&task.inputs);
|
||||||
|
|
||||||
let locals_new = if task.locals.is_empty() {
|
let locals_new = if task.locals.is_empty() {
|
||||||
|
|
|
@ -49,6 +49,7 @@ pub fn codegen(
|
||||||
));
|
));
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
|
#[doc(hidden)]
|
||||||
static mut #name: #ty = #expr
|
static mut #name: #ty = #expr
|
||||||
));
|
));
|
||||||
values.push(quote!(
|
values.push(quote!(
|
||||||
|
|
|
@ -68,6 +68,7 @@ pub fn codegen(
|
||||||
|
|
||||||
if ctxt.has_resources(app) {
|
if ctxt.has_resources(app) {
|
||||||
let ident = util::resources_ident(ctxt, app);
|
let ident = util::resources_ident(ctxt, app);
|
||||||
|
let ident = util::mark_internal_ident(&ident);
|
||||||
let lt = if resources_tick {
|
let lt = if resources_tick {
|
||||||
lt = Some(quote!('a));
|
lt = Some(quote!('a));
|
||||||
Some(quote!('a))
|
Some(quote!('a))
|
||||||
|
@ -122,8 +123,8 @@ pub fn codegen(
|
||||||
.monotonics
|
.monotonics
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_, monotonic)| {
|
.map(|(_, monotonic)| {
|
||||||
let mono = util::mangle_monotonic_type(&monotonic.ident.to_string());
|
let mono = &monotonic.ty;
|
||||||
quote! {#app_path::#mono}
|
quote! {#mono}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
@ -185,8 +186,11 @@ pub fn codegen(
|
||||||
let args = &args;
|
let args = &args;
|
||||||
let tupled = &tupled;
|
let tupled = &tupled;
|
||||||
let fq = util::fq_ident(name);
|
let fq = util::fq_ident(name);
|
||||||
|
let fq = util::mark_internal_ident(&fq);
|
||||||
let rq = util::rq_ident(priority);
|
let rq = util::rq_ident(priority);
|
||||||
|
let rq = util::mark_internal_ident(&rq);
|
||||||
let inputs = util::inputs_ident(name);
|
let inputs = util::inputs_ident(name);
|
||||||
|
let inputs = util::mark_internal_ident(&inputs);
|
||||||
|
|
||||||
let device = &extra.device;
|
let device = &extra.device;
|
||||||
let enum_ = util::interrupt_ident();
|
let enum_ = util::interrupt_ident();
|
||||||
|
@ -199,6 +203,7 @@ pub fn codegen(
|
||||||
// Spawn caller
|
// Spawn caller
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
|
/// Spawns the task directly
|
||||||
pub fn spawn(#(#args,)*) -> Result<(), #ty> {
|
pub fn spawn(#(#args,)*) -> Result<(), #ty> {
|
||||||
let input = #tupled;
|
let input = #tupled;
|
||||||
|
|
||||||
|
@ -226,13 +231,16 @@ 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 instants = util::mark_internal_ident(&instants);
|
||||||
let monotonic_name = monotonic.ident.to_string();
|
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 tq = util::mark_internal_ident(&tq);
|
||||||
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_name);
|
let mono_type = &monotonic.ty;
|
||||||
let m_ident = util::monotonic_ident(&monotonic_name);
|
let m_ident = util::monotonic_ident(&monotonic_name);
|
||||||
|
let m_ident = util::mark_internal_ident(&m_ident);
|
||||||
let m_isr = &monotonic.args.binds;
|
let m_isr = &monotonic.args.binds;
|
||||||
let enum_ = util::interrupt_ident();
|
let enum_ = util::interrupt_ident();
|
||||||
|
|
||||||
|
@ -255,15 +263,24 @@ pub fn codegen(
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let user_imports = &app.user_imports;
|
||||||
|
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
|
/// Holds methods related to this monotonic
|
||||||
pub mod #m {
|
pub mod #m {
|
||||||
|
#(
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
#user_imports
|
||||||
|
)*
|
||||||
|
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
|
/// Spawns the task after a set duration relative to the current time
|
||||||
pub fn spawn_after<D>(
|
pub fn spawn_after<D>(
|
||||||
duration: D
|
duration: D
|
||||||
#(,#args)*
|
#(,#args)*
|
||||||
) -> Result<(), #ty>
|
) -> Result<(), #ty>
|
||||||
where D: rtic::time::duration::Duration + rtic::time::fixed_point::FixedPoint,
|
where D: rtic::time::duration::Duration + rtic::time::fixed_point::FixedPoint,
|
||||||
D::T: Into<<#app_path::#m_mangled as rtic::time::Clock>::T>,
|
D::T: Into<<#app_path::#mono_type as rtic::time::Clock>::T>,
|
||||||
{
|
{
|
||||||
|
|
||||||
let instant = if rtic::export::interrupt::free(|_| unsafe { #app_path::#m_ident.is_none() }) {
|
let instant = if rtic::export::interrupt::free(|_| unsafe { #app_path::#m_ident.is_none() }) {
|
||||||
|
@ -276,8 +293,9 @@ pub fn codegen(
|
||||||
}
|
}
|
||||||
|
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
|
/// Spawns the task at a fixed time instant
|
||||||
pub fn spawn_at(
|
pub fn spawn_at(
|
||||||
instant: rtic::time::Instant<#app_path::#m_mangled>
|
instant: rtic::time::Instant<#app_path::#mono_type>
|
||||||
#(,#args)*
|
#(,#args)*
|
||||||
) -> Result<(), #ty> {
|
) -> Result<(), #ty> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
|
||||||
if !analysis.late_resources.is_empty() {
|
if !analysis.late_resources.is_empty() {
|
||||||
// BTreeSet wrapped in a vector
|
// BTreeSet wrapped in a vector
|
||||||
for name in analysis.late_resources.first().unwrap() {
|
for name in analysis.late_resources.first().unwrap() {
|
||||||
let mangled_name = util::mangle_ident(&name);
|
let mangled_name = util::mark_internal_ident(&name);
|
||||||
// If it's live
|
// If it's live
|
||||||
let cfgs = app.late_resources[name].cfgs.clone();
|
let cfgs = app.late_resources[name].cfgs.clone();
|
||||||
if analysis.locations.get(name).is_some() {
|
if analysis.locations.get(name).is_some() {
|
||||||
|
@ -35,6 +35,7 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
|
||||||
|
|
||||||
// Store the monotonic
|
// Store the monotonic
|
||||||
let name = util::monotonic_ident(&monotonic.to_string());
|
let name = util::monotonic_ident(&monotonic.to_string());
|
||||||
|
let name = util::mark_internal_ident(&name);
|
||||||
stmts.push(quote!(#name = Some(monotonics.#idx);));
|
stmts.push(quote!(#name = Some(monotonics.#idx);));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
for (name, task) in &app.software_tasks {
|
for (name, task) in &app.software_tasks {
|
||||||
let cap = task.args.capacity;
|
let cap = task.args.capacity;
|
||||||
let fq_ident = util::fq_ident(name);
|
let fq_ident = util::fq_ident(name);
|
||||||
|
let fq_ident = util::mark_internal_ident(&fq_ident);
|
||||||
|
|
||||||
stmts.push(quote!(
|
stmts.push(quote!(
|
||||||
(0..#cap).for_each(|i| #fq_ident.enqueue_unchecked(i));
|
(0..#cap).for_each(|i| #fq_ident.enqueue_unchecked(i));
|
||||||
|
@ -77,19 +78,20 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize monotonic's interrupts
|
// Initialize monotonic's interrupts
|
||||||
for (ident, priority, name) in app
|
for (_, monotonic) in app.monotonics.iter()
|
||||||
.monotonics
|
//.map(|(ident, monotonic)| (ident, &monotonic.args.priority, &monotonic.args.binds))
|
||||||
.iter()
|
|
||||||
.map(|(ident, monotonic)| (ident, &monotonic.args.priority, &monotonic.args.binds))
|
|
||||||
{
|
{
|
||||||
|
let priority = &monotonic.args.priority;
|
||||||
|
let binds = &monotonic.args.binds;
|
||||||
|
|
||||||
// Compile time assert that this priority is supported by the device
|
// Compile time assert that this priority is supported by the device
|
||||||
stmts.push(quote!(let _ = [(); ((1 << #nvic_prio_bits) - #priority as usize)];));
|
stmts.push(quote!(let _ = [(); ((1 << #nvic_prio_bits) - #priority as usize)];));
|
||||||
|
|
||||||
let app_name = &app.name;
|
let app_name = &app.name;
|
||||||
let app_path = quote! {crate::#app_name};
|
let app_path = quote! {crate::#app_name};
|
||||||
let mono_type = util::mangle_monotonic_type(&ident.to_string());
|
let mono_type = &monotonic.ty;
|
||||||
|
|
||||||
if &*name.to_string() == "SysTick" {
|
if &*binds.to_string() == "SysTick" {
|
||||||
stmts.push(quote!(
|
stmts.push(quote!(
|
||||||
core.SCB.set_priority(
|
core.SCB.set_priority(
|
||||||
rtic::export::SystemHandler::SysTick,
|
rtic::export::SystemHandler::SysTick,
|
||||||
|
@ -97,7 +99,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
);
|
);
|
||||||
|
|
||||||
// Always enable monotonic interrupts if they should never be off
|
// Always enable monotonic interrupts if they should never be off
|
||||||
if !#app_path::#mono_type::DISABLE_INTERRUPT_ON_EMPTY_QUEUE {
|
if !<#mono_type as rtic::Monotonic>::DISABLE_INTERRUPT_ON_EMPTY_QUEUE {
|
||||||
core::mem::transmute::<_, cortex_m::peripheral::SYST>(())
|
core::mem::transmute::<_, cortex_m::peripheral::SYST>(())
|
||||||
.enable_interrupt();
|
.enable_interrupt();
|
||||||
}
|
}
|
||||||
|
@ -107,13 +109,13 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
let interrupt = util::interrupt_ident();
|
let interrupt = util::interrupt_ident();
|
||||||
stmts.push(quote!(
|
stmts.push(quote!(
|
||||||
core.NVIC.set_priority(
|
core.NVIC.set_priority(
|
||||||
#rt_err::#interrupt::#name,
|
#rt_err::#interrupt::#binds,
|
||||||
rtic::export::logical2hw(#priority, #nvic_prio_bits),
|
rtic::export::logical2hw(#priority, #nvic_prio_bits),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Always enable monotonic interrupts if they should never be off
|
// Always enable monotonic interrupts if they should never be off
|
||||||
if !#app_path::#mono_type::DISABLE_INTERRUPT_ON_EMPTY_QUEUE {
|
if !<#mono_type as rtic::Monotonic>::DISABLE_INTERRUPT_ON_EMPTY_QUEUE {
|
||||||
rtic::export::NVIC::unmask(#app_path::#rt_err::#interrupt::#name);
|
rtic::export::NVIC::unmask(#app_path::#rt_err::#interrupt::#binds);
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub fn codegen(
|
||||||
for (name, res, expr, _) in app.resources(analysis) {
|
for (name, res, expr, _) in app.resources(analysis) {
|
||||||
let cfgs = &res.cfgs;
|
let cfgs = &res.cfgs;
|
||||||
let ty = &res.ty;
|
let ty = &res.ty;
|
||||||
let mangled_name = util::mangle_ident(&name);
|
let mangled_name = util::mark_internal_ident(&name);
|
||||||
|
|
||||||
{
|
{
|
||||||
let section = if expr.is_none() {
|
let section = if expr.is_none() {
|
||||||
|
@ -42,6 +42,7 @@ pub fn codegen(
|
||||||
let attrs = &res.attrs;
|
let attrs = &res.attrs;
|
||||||
mod_app.push(quote!(
|
mod_app.push(quote!(
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
|
#[doc(hidden)]
|
||||||
#(#attrs)*
|
#(#attrs)*
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
#section
|
#section
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let ty = &res.ty;
|
let ty = &res.ty;
|
||||||
let mangled_name = util::mangle_ident(&name);
|
let mangled_name = util::mark_internal_ident(&name);
|
||||||
|
|
||||||
// let ownership = &analysis.ownerships[name];
|
// let ownership = &analysis.ownerships[name];
|
||||||
let r_prop = &res.properties;
|
let r_prop = &res.properties;
|
||||||
|
@ -112,6 +112,7 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
||||||
|
|
||||||
let doc = format!("Resources `{}` has access to", ctxt.ident(app));
|
let doc = format!("Resources `{}` has access to", ctxt.ident(app));
|
||||||
let ident = util::resources_ident(ctxt, app);
|
let ident = util::resources_ident(ctxt, app);
|
||||||
|
let ident = util::mark_internal_ident(&ident);
|
||||||
let item = quote!(
|
let item = quote!(
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[doc = #doc]
|
#[doc = #doc]
|
||||||
|
|
|
@ -37,6 +37,7 @@ pub fn codegen(
|
||||||
|
|
||||||
// Create free queues and inputs / instants buffers
|
// Create free queues and inputs / instants buffers
|
||||||
let fq = util::fq_ident(name);
|
let fq = util::fq_ident(name);
|
||||||
|
let fq = util::mark_internal_ident(&fq);
|
||||||
|
|
||||||
let (fq_ty, fq_expr, mk_uninit): (_, _, Box<dyn Fn() -> Option<_>>) = {
|
let (fq_ty, fq_expr, mk_uninit): (_, _, Box<dyn Fn() -> Option<_>>) = {
|
||||||
(
|
(
|
||||||
|
@ -48,8 +49,9 @@ pub fn codegen(
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
mod_app.push(quote!(
|
mod_app.push(quote!(
|
||||||
/// Queue version of a free-list that keeps track of empty slots in
|
// /// Queue version of a free-list that keeps track of empty slots in
|
||||||
/// the following buffers
|
// /// the following buffers
|
||||||
|
#[doc(hidden)]
|
||||||
static mut #fq: #fq_ty = #fq_expr;
|
static mut #fq: #fq_ty = #fq_expr;
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -57,28 +59,29 @@ pub fn codegen(
|
||||||
.map(|_| quote!(core::mem::MaybeUninit::uninit()))
|
.map(|_| quote!(core::mem::MaybeUninit::uninit()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let app_name = &app.name;
|
|
||||||
let app_path = quote! {crate::#app_name};
|
|
||||||
|
|
||||||
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 m = util::mangle_monotonic_type(&monotonic.ident.to_string());
|
let instants = util::mark_internal_ident(&instants);
|
||||||
|
let mono_type = &monotonic.ty;
|
||||||
|
|
||||||
let uninit = mk_uninit();
|
let uninit = mk_uninit();
|
||||||
mod_app.push(quote!(
|
mod_app.push(quote!(
|
||||||
#uninit
|
#uninit
|
||||||
/// Buffer that holds the instants associated to the inputs of a task
|
// /// Buffer that holds the instants associated to the inputs of a task
|
||||||
|
#[doc(hidden)]
|
||||||
static mut #instants:
|
static mut #instants:
|
||||||
[core::mem::MaybeUninit<rtic::time::Instant<#app_path::#m>>; #cap_lit] =
|
[core::mem::MaybeUninit<rtic::time::Instant<#mono_type>>; #cap_lit] =
|
||||||
[#(#elems,)*];
|
[#(#elems,)*];
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let uninit = mk_uninit();
|
let uninit = mk_uninit();
|
||||||
let inputs_ident = util::inputs_ident(name);
|
let inputs_ident = util::inputs_ident(name);
|
||||||
|
let inputs_ident = util::mark_internal_ident(&inputs_ident);
|
||||||
mod_app.push(quote!(
|
mod_app.push(quote!(
|
||||||
#uninit
|
#uninit
|
||||||
/// Buffer that holds the inputs of a task
|
// /// Buffer that holds the inputs of a task
|
||||||
|
#[doc(hidden)]
|
||||||
static mut #inputs_ident: [core::mem::MaybeUninit<#input_ty>; #cap_lit] =
|
static mut #inputs_ident: [core::mem::MaybeUninit<#input_ty>; #cap_lit] =
|
||||||
[#(#elems,)*];
|
[#(#elems,)*];
|
||||||
));
|
));
|
||||||
|
|
|
@ -26,9 +26,10 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let doc = "Tasks that can be scheduled".to_string();
|
// let doc = "Tasks that can be scheduled".to_string();
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#[doc = #doc]
|
// #[doc = #doc]
|
||||||
|
#[doc(hidden)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
enum #t {
|
enum #t {
|
||||||
|
@ -41,25 +42,27 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
||||||
for (_, monotonic) in &app.monotonics {
|
for (_, monotonic) in &app.monotonics {
|
||||||
let monotonic_name = monotonic.ident.to_string();
|
let monotonic_name = monotonic.ident.to_string();
|
||||||
let tq = util::tq_ident(&monotonic_name);
|
let tq = util::tq_ident(&monotonic_name);
|
||||||
|
let tq = util::mark_internal_ident(&tq);
|
||||||
let t = util::schedule_t_ident();
|
let t = util::schedule_t_ident();
|
||||||
let m = util::mangle_monotonic_type(&monotonic_name);
|
let mono_type = &monotonic.ty;
|
||||||
let m_ident = util::monotonic_ident(&monotonic_name);
|
let m_ident = util::monotonic_ident(&monotonic_name);
|
||||||
|
let m_ident = util::mark_internal_ident(&m_ident);
|
||||||
let app_name = &app.name;
|
let app_name = &app.name;
|
||||||
let app_path = quote! {crate::#app_name};
|
let app_path = quote! {crate::#app_name};
|
||||||
|
|
||||||
// Static variables and resource proxy
|
// Static variables and resource proxy
|
||||||
{
|
{
|
||||||
let doc = &format!("Timer queue for {}", monotonic_name);
|
// let doc = &format!("Timer queue for {}", monotonic_name);
|
||||||
let cap = app
|
let cap = app
|
||||||
.software_tasks
|
.software_tasks
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_name, task)| task.args.capacity)
|
.map(|(_name, task)| task.args.capacity)
|
||||||
.sum();
|
.sum();
|
||||||
let n = util::capacity_typenum(cap, false);
|
let n = util::capacity_typenum(cap, false);
|
||||||
let tq_ty = quote!(rtic::export::TimerQueue<#m, #t, #n>);
|
let tq_ty = quote!(rtic::export::TimerQueue<#mono_type, #t, #n>);
|
||||||
|
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#[doc = #doc]
|
#[doc(hidden)]
|
||||||
static mut #tq: #tq_ty = rtic::export::TimerQueue(
|
static mut #tq: #tq_ty = rtic::export::TimerQueue(
|
||||||
rtic::export::BinaryHeap(
|
rtic::export::BinaryHeap(
|
||||||
rtic::export::iBinaryHeap::new()
|
rtic::export::iBinaryHeap::new()
|
||||||
|
@ -68,12 +71,12 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
||||||
));
|
));
|
||||||
|
|
||||||
let mono = util::monotonic_ident(&monotonic_name);
|
let mono = util::monotonic_ident(&monotonic_name);
|
||||||
let doc = &format!("Storage for {}", monotonic_name);
|
let mono = util::mark_internal_ident(&mono);
|
||||||
let mono_ty = quote!(Option<#m>);
|
// let doc = &format!("Storage for {}", monotonic_name);
|
||||||
|
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
#[doc = #doc]
|
#[doc(hidden)]
|
||||||
static mut #mono: #mono_ty = None;
|
static mut #mono: Option<#mono_type> = None;
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +92,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
||||||
let cfgs = &task.cfgs;
|
let cfgs = &task.cfgs;
|
||||||
let priority = task.args.priority;
|
let priority = task.args.priority;
|
||||||
let rq = util::rq_ident(priority);
|
let rq = util::rq_ident(priority);
|
||||||
|
let rq = util::mark_internal_ident(&rq);
|
||||||
let rqt = util::spawn_t_ident(priority);
|
let rqt = util::spawn_t_ident(priority);
|
||||||
|
|
||||||
// The interrupt that runs the task dispatcher
|
// The interrupt that runs the task dispatcher
|
||||||
|
|
|
@ -106,8 +106,8 @@ pub fn is_exception(name: &Ident) -> bool {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mangle an ident
|
/// Mark an ident as internal
|
||||||
pub fn mangle_ident(ident: &Ident) -> Ident {
|
pub fn mark_internal_ident(ident: &Ident) -> Ident {
|
||||||
Ident::new(
|
Ident::new(
|
||||||
&format!("__rtic_internal_{}", ident.to_string()),
|
&format!("__rtic_internal_{}", ident.to_string()),
|
||||||
Span::call_site(),
|
Span::call_site(),
|
||||||
|
@ -244,11 +244,6 @@ pub fn monotonic_ident(name: &str) -> Ident {
|
||||||
Ident::new(&format!("MONOTONIC_STORAGE_{}", name), Span::call_site())
|
Ident::new(&format!("MONOTONIC_STORAGE_{}", name), Span::call_site())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates an identifier for monotonic timer storage
|
|
||||||
pub fn mangle_monotonic_type(name: &str) -> Ident {
|
|
||||||
Ident::new(&format!("MonotonicMangled{}", name), Span::call_site())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The name to get better RT flag errors
|
/// The name to get better RT flag errors
|
||||||
pub fn rt_err_ident() -> Ident {
|
pub fn rt_err_ident() -> Ident {
|
||||||
Ident::new(
|
Ident::new(
|
||||||
|
|
|
@ -4,7 +4,7 @@ error: duplicate lang item in crate `panic_halt` (which `$CRATE` depends on): `p
|
||||||
= note: first definition in `std` loaded from /usr/share/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-6f77337c1826707d.rlib
|
= note: first definition in `std` loaded from /usr/share/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-6f77337c1826707d.rlib
|
||||||
= note: second definition in `panic_halt` loaded from $DIR/target/tests/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_halt-ad4cf7fac73711f1.rmeta
|
= note: second definition in `panic_halt` loaded from $DIR/target/tests/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_halt-ad4cf7fac73711f1.rmeta
|
||||||
|
|
||||||
error[E0609]: no field `o1` on type `initResources<'_>`
|
error[E0609]: no field `o1` on type `__rtic_internal_initResources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:47:21
|
--> $DIR/resources-cfg.rs:47:21
|
||||||
|
|
|
|
||||||
47 | c.resources.o1;
|
47 | c.resources.o1;
|
||||||
|
@ -12,7 +12,7 @@ error[E0609]: no field `o1` on type `initResources<'_>`
|
||||||
|
|
|
|
||||||
= note: available fields are: `__marker__`
|
= note: available fields are: `__marker__`
|
||||||
|
|
||||||
error[E0609]: no field `o4` on type `initResources<'_>`
|
error[E0609]: no field `o4` on type `__rtic_internal_initResources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:48:21
|
--> $DIR/resources-cfg.rs:48:21
|
||||||
|
|
|
|
||||||
48 | c.resources.o4;
|
48 | c.resources.o4;
|
||||||
|
@ -20,7 +20,7 @@ error[E0609]: no field `o4` on type `initResources<'_>`
|
||||||
|
|
|
|
||||||
= note: available fields are: `__marker__`
|
= note: available fields are: `__marker__`
|
||||||
|
|
||||||
error[E0609]: no field `o5` on type `initResources<'_>`
|
error[E0609]: no field `o5` on type `__rtic_internal_initResources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:49:21
|
--> $DIR/resources-cfg.rs:49:21
|
||||||
|
|
|
|
||||||
49 | c.resources.o5;
|
49 | c.resources.o5;
|
||||||
|
@ -28,7 +28,7 @@ error[E0609]: no field `o5` on type `initResources<'_>`
|
||||||
|
|
|
|
||||||
= note: available fields are: `__marker__`
|
= note: available fields are: `__marker__`
|
||||||
|
|
||||||
error[E0609]: no field `o6` on type `initResources<'_>`
|
error[E0609]: no field `o6` on type `__rtic_internal_initResources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:50:21
|
--> $DIR/resources-cfg.rs:50:21
|
||||||
|
|
|
|
||||||
50 | c.resources.o6;
|
50 | c.resources.o6;
|
||||||
|
@ -36,7 +36,7 @@ error[E0609]: no field `o6` on type `initResources<'_>`
|
||||||
|
|
|
|
||||||
= note: available fields are: `__marker__`
|
= note: available fields are: `__marker__`
|
||||||
|
|
||||||
error[E0609]: no field `s3` on type `initResources<'_>`
|
error[E0609]: no field `s3` on type `__rtic_internal_initResources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:51:21
|
--> $DIR/resources-cfg.rs:51:21
|
||||||
|
|
|
|
||||||
51 | c.resources.s3;
|
51 | c.resources.s3;
|
||||||
|
@ -44,7 +44,7 @@ error[E0609]: no field `s3` on type `initResources<'_>`
|
||||||
|
|
|
|
||||||
= note: available fields are: `__marker__`
|
= note: available fields are: `__marker__`
|
||||||
|
|
||||||
error[E0609]: no field `o2` on type `idleResources<'_>`
|
error[E0609]: no field `o2` on type `__rtic_internal_idleResources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:58:21
|
--> $DIR/resources-cfg.rs:58:21
|
||||||
|
|
|
|
||||||
58 | c.resources.o2;
|
58 | c.resources.o2;
|
||||||
|
@ -52,7 +52,7 @@ error[E0609]: no field `o2` on type `idleResources<'_>`
|
||||||
|
|
|
|
||||||
= note: available fields are: `__marker__`
|
= note: available fields are: `__marker__`
|
||||||
|
|
||||||
error[E0609]: no field `o4` on type `idleResources<'_>`
|
error[E0609]: no field `o4` on type `__rtic_internal_idleResources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:59:21
|
--> $DIR/resources-cfg.rs:59:21
|
||||||
|
|
|
|
||||||
59 | c.resources.o4;
|
59 | c.resources.o4;
|
||||||
|
@ -60,7 +60,7 @@ error[E0609]: no field `o4` on type `idleResources<'_>`
|
||||||
|
|
|
|
||||||
= note: available fields are: `__marker__`
|
= note: available fields are: `__marker__`
|
||||||
|
|
||||||
error[E0609]: no field `s1` on type `idleResources<'_>`
|
error[E0609]: no field `s1` on type `__rtic_internal_idleResources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:60:21
|
--> $DIR/resources-cfg.rs:60:21
|
||||||
|
|
|
|
||||||
60 | c.resources.s1;
|
60 | c.resources.s1;
|
||||||
|
@ -68,7 +68,7 @@ error[E0609]: no field `s1` on type `idleResources<'_>`
|
||||||
|
|
|
|
||||||
= note: available fields are: `__marker__`
|
= note: available fields are: `__marker__`
|
||||||
|
|
||||||
error[E0609]: no field `s3` on type `idleResources<'_>`
|
error[E0609]: no field `s3` on type `__rtic_internal_idleResources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:61:21
|
--> $DIR/resources-cfg.rs:61:21
|
||||||
|
|
|
|
||||||
61 | c.resources.s3;
|
61 | c.resources.s3;
|
||||||
|
@ -76,7 +76,7 @@ error[E0609]: no field `s3` on type `idleResources<'_>`
|
||||||
|
|
|
|
||||||
= note: available fields are: `__marker__`
|
= note: available fields are: `__marker__`
|
||||||
|
|
||||||
error[E0609]: no field `o3` on type `uart0Resources<'_>`
|
error[E0609]: no field `o3` on type `__rtic_internal_uart0Resources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:68:21
|
--> $DIR/resources-cfg.rs:68:21
|
||||||
|
|
|
|
||||||
68 | c.resources.o3;
|
68 | c.resources.o3;
|
||||||
|
@ -84,7 +84,7 @@ error[E0609]: no field `o3` on type `uart0Resources<'_>`
|
||||||
|
|
|
|
||||||
= note: available fields are: `__marker__`
|
= note: available fields are: `__marker__`
|
||||||
|
|
||||||
error[E0609]: no field `s1` on type `uart0Resources<'_>`
|
error[E0609]: no field `s1` on type `__rtic_internal_uart0Resources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:69:21
|
--> $DIR/resources-cfg.rs:69:21
|
||||||
|
|
|
|
||||||
69 | c.resources.s1;
|
69 | c.resources.s1;
|
||||||
|
@ -92,7 +92,7 @@ error[E0609]: no field `s1` on type `uart0Resources<'_>`
|
||||||
|
|
|
|
||||||
= note: available fields are: `__marker__`
|
= note: available fields are: `__marker__`
|
||||||
|
|
||||||
error[E0609]: no field `s2` on type `uart0Resources<'_>`
|
error[E0609]: no field `s2` on type `__rtic_internal_uart0Resources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:70:21
|
--> $DIR/resources-cfg.rs:70:21
|
||||||
|
|
|
|
||||||
70 | c.resources.s2;
|
70 | c.resources.s2;
|
||||||
|
@ -100,7 +100,7 @@ error[E0609]: no field `s2` on type `uart0Resources<'_>`
|
||||||
|
|
|
|
||||||
= note: available fields are: `__marker__`
|
= note: available fields are: `__marker__`
|
||||||
|
|
||||||
error[E0609]: no field `s3` on type `uart0Resources<'_>`
|
error[E0609]: no field `s3` on type `__rtic_internal_uart0Resources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:71:21
|
--> $DIR/resources-cfg.rs:71:21
|
||||||
|
|
|
|
||||||
71 | c.resources.s3;
|
71 | c.resources.s3;
|
||||||
|
@ -108,7 +108,7 @@ error[E0609]: no field `s3` on type `uart0Resources<'_>`
|
||||||
|
|
|
|
||||||
= note: available fields are: `__marker__`
|
= note: available fields are: `__marker__`
|
||||||
|
|
||||||
error[E0609]: no field `s2` on type `uart1Resources<'_>`
|
error[E0609]: no field `s2` on type `__rtic_internal_uart1Resources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:76:21
|
--> $DIR/resources-cfg.rs:76:21
|
||||||
|
|
|
|
||||||
76 | c.resources.s2;
|
76 | c.resources.s2;
|
||||||
|
@ -116,7 +116,7 @@ error[E0609]: no field `s2` on type `uart1Resources<'_>`
|
||||||
|
|
|
|
||||||
= note: available fields are: `__marker__`
|
= note: available fields are: `__marker__`
|
||||||
|
|
||||||
error[E0609]: no field `o5` on type `uart1Resources<'_>`
|
error[E0609]: no field `o5` on type `__rtic_internal_uart1Resources<'_>`
|
||||||
--> $DIR/resources-cfg.rs:77:21
|
--> $DIR/resources-cfg.rs:77:21
|
||||||
|
|
|
|
||||||
77 | c.resources.o5;
|
77 | c.resources.o5;
|
||||||
|
|
Loading…
Reference in a new issue