mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
Merge #692
692: CFG: Support HW tasks, cleanup for SW tasks r=korken89 a=AfoHT Fixes #665 Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
This commit is contained in:
commit
d43c2b64cc
8 changed files with 39 additions and 6 deletions
|
@ -9,6 +9,7 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!
|
|||
|
||||
### Added
|
||||
|
||||
- CFG: Support #[cfg] on HW task, cleanup for SW tasks
|
||||
- CFG: Slightly improved support for #[cfg] on Monotonics
|
||||
- CI: Check examples also for thumbv8.{base,main}
|
||||
- Allow custom `link_section` attributes for late resources
|
||||
|
|
|
@ -82,6 +82,19 @@ mod app {
|
|||
// ..
|
||||
}
|
||||
|
||||
// The whole task should disappear,
|
||||
// currently still present in the Tasks enum
|
||||
#[cfg(never)]
|
||||
#[task(binds = UART1, shared = [count])]
|
||||
fn foo3(mut _cx: foo3::Context) {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
_cx.shared.count.lock(|count| *count += 10);
|
||||
|
||||
log::spawn(_cx.shared.count.lock(|count| *count)).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
#[task(capacity = 2)]
|
||||
fn log(_: log::Context, n: u32) {
|
||||
|
|
|
@ -29,7 +29,9 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
|||
.filter_map(|(_, task)| {
|
||||
if !util::is_exception(&task.args.binds) {
|
||||
let interrupt_name = &task.args.binds;
|
||||
let cfgs = &task.cfgs;
|
||||
Some(quote!(
|
||||
#(#cfgs)*
|
||||
if (#device::Interrupt::#interrupt_name as usize) >= (#chunks_name * 32) {
|
||||
::core::panic!("An interrupt out of range is used while in armv6 or armv8m.base");
|
||||
}
|
||||
|
|
|
@ -93,11 +93,13 @@ pub fn codegen(
|
|||
let user_hardware_task_doc = &format!(" User HW task: {name}");
|
||||
if !task.is_extern {
|
||||
let attrs = &task.attrs;
|
||||
let cfgs = &task.cfgs;
|
||||
let context = &task.context;
|
||||
let stmts = &task.stmts;
|
||||
user_tasks.push(quote!(
|
||||
#[doc = #user_hardware_task_doc]
|
||||
#(#attrs)*
|
||||
#(#cfgs)*
|
||||
#[allow(non_snake_case)]
|
||||
fn #name(#context: #name::Context) {
|
||||
use rtic::Mutex as _;
|
||||
|
|
|
@ -16,8 +16,6 @@ pub fn codegen(
|
|||
let mut module_items = vec![];
|
||||
let mut fields = vec![];
|
||||
let mut values = vec![];
|
||||
// Used to copy task cfgs to the whole module
|
||||
let mut task_cfgs = vec![];
|
||||
|
||||
let name = ctxt.ident(app);
|
||||
|
||||
|
@ -208,8 +206,6 @@ pub fn codegen(
|
|||
let priority = spawnee.args.priority;
|
||||
let t = util::spawn_t_ident(priority);
|
||||
let cfgs = &spawnee.cfgs;
|
||||
// Store a copy of the task cfgs
|
||||
task_cfgs = cfgs.clone();
|
||||
let (args, tupled, untupled, ty) = util::regroup_inputs(&spawnee.inputs);
|
||||
let args = &args;
|
||||
let tupled = &tupled;
|
||||
|
@ -461,9 +457,8 @@ pub fn codegen(
|
|||
} else {
|
||||
quote!(
|
||||
#(#items)*
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#(#task_cfgs)*
|
||||
#(#cfgs)*
|
||||
#[doc = #doc]
|
||||
pub mod #name {
|
||||
#(#module_items)*
|
||||
|
|
|
@ -16,9 +16,11 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
|||
// Populate the FreeQueue
|
||||
for (name, task) in &app.software_tasks {
|
||||
let cap = task.args.capacity;
|
||||
let cfgs = &task.cfgs;
|
||||
let fq_ident = util::fq_ident(name);
|
||||
|
||||
stmts.push(quote!(
|
||||
#(#cfgs)*
|
||||
(0..#cap).for_each(|i| (&mut *#fq_ident.get_mut()).enqueue_unchecked(i));
|
||||
));
|
||||
}
|
||||
|
|
|
@ -15,6 +15,19 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
|||
Context::SoftwareTask(name) => &app.software_tasks[name].args.shared_resources,
|
||||
};
|
||||
|
||||
let v = Vec::new();
|
||||
let task_cfgs = match ctxt {
|
||||
Context::HardwareTask(t) => {
|
||||
&app.hardware_tasks[t].cfgs
|
||||
// ...
|
||||
}
|
||||
Context::SoftwareTask(t) => {
|
||||
&app.software_tasks[t].cfgs
|
||||
// ...
|
||||
}
|
||||
_ => &v,
|
||||
};
|
||||
|
||||
let mut fields = vec![];
|
||||
let mut values = vec![];
|
||||
let mut has_cfgs = false;
|
||||
|
@ -118,6 +131,7 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
|||
#[allow(non_snake_case)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc = #doc]
|
||||
#(#task_cfgs)*
|
||||
pub struct #ident<#lt> {
|
||||
#(#fields,)*
|
||||
}
|
||||
|
@ -129,6 +143,7 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
|||
Some(quote!(priority: &#lt rtic::export::Priority))
|
||||
};
|
||||
let constructor = quote!(
|
||||
#(#task_cfgs)*
|
||||
impl<#lt> #ident<#lt> {
|
||||
#[doc(hidden)]
|
||||
#[inline(always)]
|
||||
|
|
|
@ -29,6 +29,7 @@ pub fn codegen(
|
|||
|
||||
for (name, task) in &app.software_tasks {
|
||||
let inputs = &task.inputs;
|
||||
let cfgs = &task.cfgs;
|
||||
let (_, _, _, input_ty) = util::regroup_inputs(inputs);
|
||||
|
||||
let cap = task.args.capacity;
|
||||
|
@ -49,6 +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
|
||||
#(#cfgs)*
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[doc(hidden)]
|
||||
|
@ -89,6 +91,7 @@ pub fn codegen(
|
|||
#[allow(non_camel_case_types)]
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[doc(hidden)]
|
||||
#(#cfgs)*
|
||||
static #inputs_ident: rtic::RacyCell<[core::mem::MaybeUninit<#input_ty>; #cap_lit]> =
|
||||
rtic::RacyCell::new([#(#elems,)*]);
|
||||
));
|
||||
|
|
Loading…
Reference in a new issue