mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-19 06:15:45 +01:00
Merge #396
396: Fix namespaces r=AfoHT a=korken89 Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
This commit is contained in:
commit
9fb5a223cb
50 changed files with 199 additions and 269 deletions
|
|
@ -22,35 +22,20 @@ mod util;
|
|||
// TODO document the syntax here or in `rtic-syntax`
|
||||
pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||
let mut mod_app = vec![];
|
||||
let mut mod_app_imports = vec![];
|
||||
let mut mains = vec![];
|
||||
let mut root = vec![];
|
||||
let mut user = vec![];
|
||||
let mut imports = vec![];
|
||||
|
||||
// Generate the `main` function
|
||||
let assertion_stmts = assertions::codegen(analysis);
|
||||
|
||||
let pre_init_stmts = pre_init::codegen(&app, analysis, extra);
|
||||
|
||||
let (mod_app_init, root_init, user_init, user_init_imports, call_init) =
|
||||
init::codegen(app, analysis, extra);
|
||||
let (mod_app_init, root_init, user_init, call_init) = init::codegen(app, analysis, extra);
|
||||
|
||||
let post_init_stmts = post_init::codegen(&app, analysis);
|
||||
|
||||
let (mod_app_idle, root_idle, user_idle, user_idle_imports, call_idle) =
|
||||
idle::codegen(app, analysis, extra);
|
||||
|
||||
if user_init.is_some() {
|
||||
mod_app_imports.push(quote!(
|
||||
use super::init;
|
||||
))
|
||||
}
|
||||
if user_idle.is_some() {
|
||||
mod_app_imports.push(quote!(
|
||||
use super::idle;
|
||||
))
|
||||
}
|
||||
let (mod_app_idle, root_idle, user_idle, call_idle) = idle::codegen(app, analysis, extra);
|
||||
|
||||
user.push(quote!(
|
||||
#user_init
|
||||
|
|
@ -58,11 +43,6 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
|||
#user_idle
|
||||
));
|
||||
|
||||
imports.push(quote!(
|
||||
#(#user_init_imports)*
|
||||
#(#user_idle_imports)*
|
||||
));
|
||||
|
||||
root.push(quote!(
|
||||
#(#root_init)*
|
||||
|
||||
|
|
@ -93,22 +73,13 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
|||
}
|
||||
));
|
||||
|
||||
let (mod_app_resources, mod_resources, mod_resources_imports) =
|
||||
resources::codegen(app, analysis, extra);
|
||||
let (mod_app_resources, mod_resources) = resources::codegen(app, analysis, extra);
|
||||
|
||||
let (
|
||||
mod_app_hardware_tasks,
|
||||
root_hardware_tasks,
|
||||
user_hardware_tasks,
|
||||
user_hardware_tasks_imports,
|
||||
) = hardware_tasks::codegen(app, analysis, extra);
|
||||
let (mod_app_hardware_tasks, root_hardware_tasks, user_hardware_tasks) =
|
||||
hardware_tasks::codegen(app, analysis, extra);
|
||||
|
||||
let (
|
||||
mod_app_software_tasks,
|
||||
root_software_tasks,
|
||||
user_software_tasks,
|
||||
user_software_tasks_imports,
|
||||
) = software_tasks::codegen(app, analysis, extra);
|
||||
let (mod_app_software_tasks, root_software_tasks, user_software_tasks) =
|
||||
software_tasks::codegen(app, analysis, extra);
|
||||
|
||||
let mod_app_dispatchers = dispatchers::codegen(app, analysis, extra);
|
||||
let mod_app_timer_queue = timer_queue::codegen(app, analysis, extra);
|
||||
|
|
@ -122,49 +93,44 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
|||
let task_list = analysis.tasks.clone();
|
||||
|
||||
let mut tasks = vec![];
|
||||
|
||||
if !task_list.is_empty() {
|
||||
tasks.push(quote!(
|
||||
enum Tasks {
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum Tasks {
|
||||
#(#task_list),*
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
quote!(
|
||||
#(#user)*
|
||||
|
||||
#(#user_hardware_tasks)*
|
||||
|
||||
#(#user_software_tasks)*
|
||||
|
||||
#(#root)*
|
||||
|
||||
#mod_resources
|
||||
|
||||
#(#root_hardware_tasks)*
|
||||
|
||||
#(#root_software_tasks)*
|
||||
|
||||
/// Unused
|
||||
#(#tasks)*
|
||||
|
||||
/// Implementation details
|
||||
mod #name {
|
||||
pub mod #name {
|
||||
/// Always include the device crate which contains the vector table
|
||||
use #device as you_must_enable_the_rt_feature_for_the_pac_in_your_cargo_toml;
|
||||
#(#imports)*
|
||||
|
||||
#(#user_imports)*
|
||||
|
||||
/// User code from within the module
|
||||
#(#user_code)*
|
||||
/// User code end
|
||||
|
||||
#(#user)*
|
||||
|
||||
#(#user_hardware_tasks_imports)*
|
||||
#(#user_hardware_tasks)*
|
||||
|
||||
#(#user_software_tasks_imports)*
|
||||
#(#user_software_tasks)*
|
||||
|
||||
#(#mod_resources_imports)*
|
||||
#(#root)*
|
||||
|
||||
#mod_resources
|
||||
|
||||
#(#root_hardware_tasks)*
|
||||
|
||||
#(#root_software_tasks)*
|
||||
|
||||
/// Unused
|
||||
#(#tasks)*
|
||||
|
||||
/// app module
|
||||
#(#mod_app)*
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
|||
);
|
||||
items.push(quote!(
|
||||
#[doc = #doc]
|
||||
pub static mut #rq: #rq_ty = #rq_expr;
|
||||
static mut #rq: #rq_ty = #rq_expr;
|
||||
));
|
||||
|
||||
let arms = channel
|
||||
|
|
@ -90,6 +90,8 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
|||
quote!(#name::Locals::new(),)
|
||||
};
|
||||
|
||||
let app_name = &app.name;
|
||||
let app_path = quote! {crate::#app_name};
|
||||
quote!(
|
||||
#(#cfgs)*
|
||||
#t::#name => {
|
||||
|
|
@ -98,7 +100,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
|||
#let_instant
|
||||
#fq.split().0.enqueue_unchecked(index);
|
||||
let priority = &rtic::export::Priority::new(PRIORITY);
|
||||
crate::#name(
|
||||
#app_path::#name(
|
||||
#locals_new
|
||||
#name::Context::new(priority #instant)
|
||||
#(,#pats)*
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::{format_ident, quote};
|
||||
use quote::quote;
|
||||
use rtic_syntax::{ast::App, Context};
|
||||
|
||||
use crate::{
|
||||
|
|
@ -23,13 +23,10 @@ pub fn codegen(
|
|||
Vec<TokenStream2>,
|
||||
// user_hardware_tasks -- the `#[task]` functions written by the user
|
||||
Vec<TokenStream2>,
|
||||
// user_hardware_tasks_imports -- the imports for `#[task]` functions written by the user
|
||||
Vec<TokenStream2>,
|
||||
) {
|
||||
let mut mod_app = vec![];
|
||||
let mut root = vec![];
|
||||
let mut user_tasks = vec![];
|
||||
let mut hardware_tasks_imports = vec![];
|
||||
|
||||
for (name, task) in &app.hardware_tasks {
|
||||
let (let_instant, instant) = if let Some(m) = extra.monotonic {
|
||||
|
|
@ -50,6 +47,8 @@ pub fn codegen(
|
|||
let symbol = task.args.binds.clone();
|
||||
let priority = task.args.priority;
|
||||
|
||||
let app_name = &app.name;
|
||||
let app_path = quote! {crate::#app_name};
|
||||
mod_app.push(quote!(
|
||||
#[allow(non_snake_case)]
|
||||
#[no_mangle]
|
||||
|
|
@ -59,7 +58,7 @@ pub fn codegen(
|
|||
#let_instant
|
||||
|
||||
rtic::export::run(PRIORITY, || {
|
||||
crate::#name(
|
||||
#app_path::#name(
|
||||
#locals_new
|
||||
#name::Context::new(&rtic::export::Priority::new(PRIORITY) #instant)
|
||||
)
|
||||
|
|
@ -79,13 +78,6 @@ pub fn codegen(
|
|||
analysis,
|
||||
);
|
||||
|
||||
// Add resources to imports
|
||||
let name_res = format_ident!("{}Resources", name);
|
||||
hardware_tasks_imports.push(quote!(
|
||||
#[allow(non_snake_case)]
|
||||
use super::#name_res;
|
||||
));
|
||||
|
||||
root.push(item);
|
||||
|
||||
mod_app.push(constructor);
|
||||
|
|
@ -121,13 +113,7 @@ pub fn codegen(
|
|||
#(#stmts)*
|
||||
}
|
||||
));
|
||||
|
||||
hardware_tasks_imports.push(quote!(
|
||||
#(#attrs)*
|
||||
#[allow(non_snake_case)]
|
||||
use super::#name;
|
||||
));
|
||||
}
|
||||
|
||||
(mod_app, root, user_tasks, hardware_tasks_imports)
|
||||
(mod_app, root, user_tasks)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::{format_ident, quote};
|
||||
use quote::quote;
|
||||
use rtic_syntax::{ast::App, Context};
|
||||
|
||||
use crate::{
|
||||
|
|
@ -23,8 +23,6 @@ pub fn codegen(
|
|||
Vec<TokenStream2>,
|
||||
// user_idle
|
||||
Option<TokenStream2>,
|
||||
// user_idle_imports
|
||||
Vec<TokenStream2>,
|
||||
// call_idle
|
||||
TokenStream2,
|
||||
) {
|
||||
|
|
@ -36,8 +34,6 @@ pub fn codegen(
|
|||
let mut locals_pat = None;
|
||||
let mut locals_new = None;
|
||||
|
||||
let mut user_idle_imports = vec![];
|
||||
|
||||
let name = &idle.name;
|
||||
|
||||
if !idle.args.resources.is_empty() {
|
||||
|
|
@ -46,12 +42,6 @@ pub fn codegen(
|
|||
|
||||
root_idle.push(item);
|
||||
mod_app = Some(constructor);
|
||||
|
||||
let name_resource = format_ident!("{}Resources", name);
|
||||
user_idle_imports.push(quote!(
|
||||
#[allow(non_snake_case)]
|
||||
use super::#name_resource;
|
||||
));
|
||||
}
|
||||
|
||||
if !idle.locals.is_empty() {
|
||||
|
|
@ -83,25 +73,21 @@ pub fn codegen(
|
|||
#(#stmts)*
|
||||
}
|
||||
));
|
||||
user_idle_imports.push(quote!(
|
||||
#(#attrs)*
|
||||
#[allow(non_snake_case)]
|
||||
use super::#name;
|
||||
));
|
||||
|
||||
let app_name = &app.name;
|
||||
let app_path = quote! {crate::#app_name};
|
||||
let locals_new = locals_new.iter();
|
||||
let call_idle = quote!(crate::#name(
|
||||
let call_idle = quote!(#app_path::#name(
|
||||
#(#locals_new,)*
|
||||
#name::Context::new(&rtic::export::Priority::new(0))
|
||||
));
|
||||
|
||||
(mod_app, root_idle, user_idle, user_idle_imports, call_idle)
|
||||
(mod_app, root_idle, user_idle, call_idle)
|
||||
} else {
|
||||
(
|
||||
None,
|
||||
vec![],
|
||||
None,
|
||||
vec![],
|
||||
quote!(loop {
|
||||
rtic::export::wfi()
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::{format_ident, quote};
|
||||
use quote::quote;
|
||||
use rtic_syntax::{ast::App, Context};
|
||||
|
||||
use crate::{
|
||||
|
|
@ -19,8 +19,6 @@ type CodegenResult = (
|
|||
Vec<TokenStream2>,
|
||||
// user_init -- the `#[init]` function written by the user
|
||||
Option<TokenStream2>,
|
||||
// user_init_imports -- the imports for `#[init]` functio written by the user
|
||||
Vec<TokenStream2>,
|
||||
// call_init -- the call to the user `#[init]` if there's one
|
||||
Option<TokenStream2>,
|
||||
);
|
||||
|
|
@ -50,7 +48,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult {
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let mut user_init_imports = vec![];
|
||||
let late_resources = util::late_resources_ident(&name);
|
||||
|
||||
root_init.push(quote!(
|
||||
|
|
@ -61,12 +58,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult {
|
|||
}
|
||||
));
|
||||
|
||||
let name_late = format_ident!("{}LateResources", name);
|
||||
user_init_imports.push(quote!(
|
||||
#[allow(non_snake_case)]
|
||||
use super::#name_late;
|
||||
));
|
||||
|
||||
let mut locals_pat = None;
|
||||
let mut locals_new = None;
|
||||
if !init.locals.is_empty() {
|
||||
|
|
@ -88,11 +79,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult {
|
|||
#(#stmts)*
|
||||
}
|
||||
));
|
||||
user_init_imports.push(quote!(
|
||||
#(#attrs)*
|
||||
#[allow(non_snake_case)]
|
||||
use super::#name;
|
||||
));
|
||||
|
||||
let mut mod_app = None;
|
||||
if !init.args.resources.is_empty() {
|
||||
|
|
@ -101,17 +87,13 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult {
|
|||
|
||||
root_init.push(item);
|
||||
mod_app = Some(constructor);
|
||||
|
||||
let name_late = format_ident!("{}Resources", name);
|
||||
user_init_imports.push(quote!(
|
||||
#[allow(non_snake_case)]
|
||||
use super::#name_late;
|
||||
));
|
||||
}
|
||||
|
||||
let app_name = &app.name;
|
||||
let app_path = quote! {crate::#app_name};
|
||||
let locals_new = locals_new.iter();
|
||||
let call_init = Some(
|
||||
quote!(let late = crate::#name(#(#locals_new,)* #name::Context::new(core.into()));),
|
||||
quote!(let late = #app_path::#name(#(#locals_new,)* #name::Context::new(core.into()));),
|
||||
);
|
||||
|
||||
root_init.push(module::codegen(
|
||||
|
|
@ -122,8 +104,8 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult {
|
|||
extra,
|
||||
));
|
||||
|
||||
(mod_app, root_init, user_init, user_init_imports, call_init)
|
||||
(mod_app, root_init, user_init, call_init)
|
||||
} else {
|
||||
(None, vec![], None, vec![], None)
|
||||
(None, vec![], None, None)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use proc_macro2::TokenStream as TokenStream2;
|
|||
use quote::quote;
|
||||
use rtic_syntax::ast::App;
|
||||
|
||||
use crate::analyze::Analysis;
|
||||
use crate::{analyze::Analysis, codegen::util};
|
||||
|
||||
/// Generates code that runs after `#[init]` returns
|
||||
pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
|
||||
|
|
@ -12,13 +12,14 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
|
|||
if !analysis.late_resources.is_empty() {
|
||||
// BTreeSet wrapped in a vector
|
||||
for name in analysis.late_resources.first().unwrap() {
|
||||
let mangled_name = util::mangle_ident(&name);
|
||||
// If it's live
|
||||
let cfgs = app.late_resources[name].cfgs.clone();
|
||||
if analysis.locations.get(name).is_some() {
|
||||
// Need to also include the cfgs
|
||||
stmts.push(quote!(
|
||||
#(#cfgs)*
|
||||
#name.as_mut_ptr().write(late.#name);
|
||||
#mangled_name.as_mut_ptr().write(late.#name);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,16 +14,14 @@ pub fn codegen(
|
|||
Vec<TokenStream2>,
|
||||
// mod_resources -- the `resources` module
|
||||
TokenStream2,
|
||||
// mod_resources_imports -- the `resources` module imports
|
||||
Vec<TokenStream2>,
|
||||
) {
|
||||
let mut mod_app = vec![];
|
||||
let mut mod_resources = vec![];
|
||||
let mut mod_resources_imports = vec![];
|
||||
|
||||
for (name, res, expr, _) in app.resources(analysis) {
|
||||
let cfgs = &res.cfgs;
|
||||
let ty = &res.ty;
|
||||
let mangled_name = util::mangle_ident(&name);
|
||||
|
||||
{
|
||||
let section = if expr.is_none() {
|
||||
|
|
@ -47,7 +45,7 @@ pub fn codegen(
|
|||
#(#attrs)*
|
||||
#(#cfgs)*
|
||||
#section
|
||||
static mut #name: #ty = #expr;
|
||||
static mut #mangled_name: #ty = #expr;
|
||||
));
|
||||
}
|
||||
|
||||
|
|
@ -76,21 +74,15 @@ pub fn codegen(
|
|||
let ptr = if expr.is_none() {
|
||||
quote!(
|
||||
#(#cfgs)*
|
||||
#name.as_mut_ptr()
|
||||
#mangled_name.as_mut_ptr()
|
||||
)
|
||||
} else {
|
||||
quote!(
|
||||
#(#cfgs)*
|
||||
&mut #name
|
||||
&mut #mangled_name
|
||||
)
|
||||
};
|
||||
|
||||
mod_resources_imports.push(quote!(
|
||||
#[allow(non_camel_case_types)]
|
||||
#(#cfgs)*
|
||||
use super::resources::#name;
|
||||
));
|
||||
|
||||
mod_app.push(util::impl_mutex(
|
||||
extra,
|
||||
cfgs,
|
||||
|
|
@ -106,11 +98,6 @@ pub fn codegen(
|
|||
let mod_resources = if mod_resources.is_empty() {
|
||||
quote!()
|
||||
} else {
|
||||
// Also import the resource module
|
||||
mod_resources_imports.push(quote!(
|
||||
use super::resources;
|
||||
));
|
||||
|
||||
quote!(mod resources {
|
||||
use rtic::export::Priority;
|
||||
|
||||
|
|
@ -118,5 +105,5 @@ pub fn codegen(
|
|||
})
|
||||
};
|
||||
|
||||
(mod_app, mod_resources, mod_resources_imports)
|
||||
(mod_app, mod_resources)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ pub fn codegen(
|
|||
None
|
||||
};
|
||||
let ty = &res.ty;
|
||||
let mangled_name = util::mangle_ident(&name);
|
||||
|
||||
if ctxt.is_init() {
|
||||
if !analysis.ownerships.contains_key(name) {
|
||||
|
|
@ -47,7 +48,7 @@ pub fn codegen(
|
|||
|
||||
values.push(quote!(
|
||||
#(#cfgs)*
|
||||
#name: &#mut_ #name
|
||||
#name: &#mut_ #mangled_name
|
||||
));
|
||||
} else {
|
||||
// Owned by someone else
|
||||
|
|
@ -60,7 +61,7 @@ pub fn codegen(
|
|||
|
||||
values.push(quote!(
|
||||
#(#cfgs)*
|
||||
#name: &mut #name
|
||||
#name: &mut #mangled_name
|
||||
));
|
||||
}
|
||||
} else {
|
||||
|
|
@ -115,9 +116,9 @@ pub fn codegen(
|
|||
let is_late = expr.is_none();
|
||||
if is_late {
|
||||
let expr = if mut_.is_some() {
|
||||
quote!(&mut *#name.as_mut_ptr())
|
||||
quote!(&mut *#mangled_name.as_mut_ptr())
|
||||
} else {
|
||||
quote!(&*#name.as_ptr())
|
||||
quote!(&*#mangled_name.as_ptr())
|
||||
};
|
||||
|
||||
values.push(quote!(
|
||||
|
|
@ -127,7 +128,7 @@ pub fn codegen(
|
|||
} else {
|
||||
values.push(quote!(
|
||||
#(#cfgs)*
|
||||
#name: &#mut_ #name
|
||||
#name: &#mut_ #mangled_name
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use proc_macro2::TokenStream as TokenStream2;
|
||||
use quote::{format_ident, quote};
|
||||
use quote::quote;
|
||||
use rtic_syntax::{ast::App, Context};
|
||||
|
||||
use crate::{
|
||||
|
|
@ -22,13 +22,10 @@ pub fn codegen(
|
|||
Vec<TokenStream2>,
|
||||
// user_software_tasks -- the `#[task]` functions written by the user
|
||||
Vec<TokenStream2>,
|
||||
// user_software_tasks_imports -- the imports for `#[task]` functions written by the user
|
||||
Vec<TokenStream2>,
|
||||
) {
|
||||
let mut mod_app = vec![];
|
||||
let mut root = vec![];
|
||||
let mut user_tasks = vec![];
|
||||
let mut software_tasks_imports = vec![];
|
||||
|
||||
for (name, task) in &app.software_tasks {
|
||||
let inputs = &task.inputs;
|
||||
|
|
@ -53,7 +50,7 @@ pub fn codegen(
|
|||
mod_app.push(quote!(
|
||||
/// Queue version of a free-list that keeps track of empty slots in
|
||||
/// the following buffers
|
||||
pub static mut #fq: #fq_ty = #fq_expr;
|
||||
static mut #fq: #fq_ty = #fq_expr;
|
||||
));
|
||||
|
||||
let elems = &(0..cap)
|
||||
|
|
@ -67,7 +64,7 @@ pub fn codegen(
|
|||
mod_app.push(quote!(
|
||||
#uninit
|
||||
/// Buffer that holds the instants associated to the inputs of a task
|
||||
pub static mut #instants:
|
||||
static mut #instants:
|
||||
[core::mem::MaybeUninit<<#m as rtic::Monotonic>::Instant>; #cap_lit] =
|
||||
[#(#elems,)*];
|
||||
));
|
||||
|
|
@ -78,7 +75,7 @@ pub fn codegen(
|
|||
mod_app.push(quote!(
|
||||
#uninit
|
||||
/// Buffer that holds the inputs of a task
|
||||
pub static mut #inputs_ident: [core::mem::MaybeUninit<#input_ty>; #cap_lit] =
|
||||
static mut #inputs_ident: [core::mem::MaybeUninit<#input_ty>; #cap_lit] =
|
||||
[#(#elems,)*];
|
||||
));
|
||||
|
||||
|
|
@ -93,13 +90,6 @@ pub fn codegen(
|
|||
analysis,
|
||||
);
|
||||
|
||||
// Add resources to imports
|
||||
let name_res = format_ident!("{}Resources", name);
|
||||
software_tasks_imports.push(quote!(
|
||||
#[allow(non_snake_case)]
|
||||
use super::#name_res;
|
||||
));
|
||||
|
||||
root.push(item);
|
||||
|
||||
mod_app.push(constructor);
|
||||
|
|
@ -123,17 +113,12 @@ pub fn codegen(
|
|||
#(#attrs)*
|
||||
#(#cfgs)*
|
||||
#[allow(non_snake_case)]
|
||||
pub fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) {
|
||||
fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) {
|
||||
use rtic::Mutex as _;
|
||||
|
||||
#(#stmts)*
|
||||
}
|
||||
));
|
||||
software_tasks_imports.push(quote!(
|
||||
#(#cfgs)*
|
||||
#[allow(non_snake_case)]
|
||||
use super::#name;
|
||||
));
|
||||
|
||||
root.push(module::codegen(
|
||||
Context::SoftwareTask(name),
|
||||
|
|
@ -144,5 +129,5 @@ pub fn codegen(
|
|||
));
|
||||
}
|
||||
|
||||
(mod_app, root, user_tasks, software_tasks_imports)
|
||||
(mod_app, root, user_tasks)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
|||
#[doc = #doc]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum #t {
|
||||
enum #t {
|
||||
#(#variants,)*
|
||||
}
|
||||
));
|
||||
|
|
@ -52,7 +52,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
|||
|
||||
items.push(quote!(
|
||||
#[doc = #doc]
|
||||
pub static mut #tq: #tq_ty = rtic::export::TimerQueue(
|
||||
static mut #tq: #tq_ty = rtic::export::TimerQueue(
|
||||
rtic::export::BinaryHeap(
|
||||
rtic::export::iBinaryHeap::new()
|
||||
)
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ pub fn impl_mutex(
|
|||
type T = #ty;
|
||||
|
||||
#[inline(always)]
|
||||
fn lock<R>(&mut self, f: impl FnOnce(&mut #ty) -> R) -> R {
|
||||
fn lock<RTIC_INTERNAL_R>(&mut self, f: impl FnOnce(&mut #ty) -> RTIC_INTERNAL_R) -> RTIC_INTERNAL_R {
|
||||
/// Priority ceiling
|
||||
const CEILING: u8 = #ceiling;
|
||||
|
||||
|
|
@ -111,6 +111,14 @@ pub fn late_resources_ident(init: &Ident) -> Ident {
|
|||
)
|
||||
}
|
||||
|
||||
/// Mangle an ident
|
||||
pub fn mangle_ident(ident: &Ident) -> Ident {
|
||||
Ident::new(
|
||||
&format!("__rtic_internal_{}", ident.to_string()),
|
||||
Span::call_site(),
|
||||
)
|
||||
}
|
||||
|
||||
fn link_section_index() -> usize {
|
||||
static INDEX: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue