diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-03-04 21:10:24 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-04 21:10:24 +0000 |
| commit | 7c7d6558f6d9c50fbb4d2487c98c9a5be15f2f7b (patch) | |
| tree | 80a47f0dc40059014e9448c4c2eb34c54dff45fe /macros/src/codegen/hardware_tasks.rs | |
| parent | 1c5db277e4161470136dbd2a11e914ff1d383581 (diff) | |
| parent | 98c5490d94950608d31cd5ad9dd260f2f853735c (diff) | |
Merge #694
694: RTIC 2 r=AfoHT a=korken89
Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
Co-authored-by: Per Lindgren <per.lindgren@ltu.se>
Diffstat (limited to 'macros/src/codegen/hardware_tasks.rs')
| -rw-r--r-- | macros/src/codegen/hardware_tasks.rs | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs deleted file mode 100644 index b3f05d2..0000000 --- a/macros/src/codegen/hardware_tasks.rs +++ /dev/null @@ -1,115 +0,0 @@ -use proc_macro2::TokenStream as TokenStream2; -use quote::quote; -use rtic_syntax::{ast::App, Context}; - -use crate::{ - analyze::Analysis, - check::Extra, - codegen::{local_resources_struct, module, shared_resources_struct}, -}; - -/// Generate support code for hardware tasks (`#[exception]`s and `#[interrupt]`s) -pub fn codegen( - app: &App, - analysis: &Analysis, - extra: &Extra, -) -> ( - // mod_app_hardware_tasks -- interrupt handlers and `${task}Resources` constructors - Vec<TokenStream2>, - // root_hardware_tasks -- items that must be placed in the root of the crate: - // - `${task}Locals` structs - // - `${task}Resources` structs - // - `${task}` modules - Vec<TokenStream2>, - // user_hardware_tasks -- the `#[task]` functions written by the user - Vec<TokenStream2>, -) { - let mut mod_app = vec![]; - let mut root = vec![]; - let mut user_tasks = vec![]; - - for (name, task) in &app.hardware_tasks { - let symbol = task.args.binds.clone(); - let priority = task.args.priority; - let cfgs = &task.cfgs; - let attrs = &task.attrs; - let user_hardware_task_isr_doc = &format!(" User HW task ISR trampoline for {name}"); - - mod_app.push(quote!( - #[allow(non_snake_case)] - #[no_mangle] - #[doc = #user_hardware_task_isr_doc] - #(#attrs)* - #(#cfgs)* - unsafe fn #symbol() { - const PRIORITY: u8 = #priority; - - rtic::export::run(PRIORITY, || { - #name( - #name::Context::new(&rtic::export::Priority::new(PRIORITY)) - ) - }); - } - )); - - let mut shared_needs_lt = false; - let mut local_needs_lt = false; - - // `${task}Locals` - if !task.args.local_resources.is_empty() { - let (item, constructor) = local_resources_struct::codegen( - Context::HardwareTask(name), - &mut local_needs_lt, - app, - ); - - root.push(item); - - mod_app.push(constructor); - } - - // `${task}Resources` - if !task.args.shared_resources.is_empty() { - let (item, constructor) = shared_resources_struct::codegen( - Context::HardwareTask(name), - &mut shared_needs_lt, - app, - ); - - root.push(item); - - mod_app.push(constructor); - } - - root.push(module::codegen( - Context::HardwareTask(name), - shared_needs_lt, - local_needs_lt, - app, - analysis, - extra, - )); - - 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 _; - use rtic::mutex::prelude::*; - - #(#stmts)* - } - )); - } - } - - (mod_app, root, user_tasks) -} |
