From ef5307d83a1d62df0569d78db75d4006147c927d Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Tue, 6 Jul 2021 22:47:48 +0200 Subject: Minimal app now compiles --- macros/src/codegen/module.rs | 69 ++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 37 deletions(-) (limited to 'macros/src/codegen/module.rs') diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index a3d3fab2..adf64d5b 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -56,16 +56,39 @@ pub fn codegen( Context::SoftwareTask(_) => {} } - if ctxt.has_locals(app) { - let ident = util::locals_ident(ctxt, app); + // if ctxt.has_locals(app) { + // let ident = util::locals_ident(ctxt, app); + // module_items.push(quote!( + // #[doc(inline)] + // pub use super::#ident as Locals; + // )); + // } + + if ctxt.has_local_resources(app) { + let ident = util::local_resources_ident(ctxt, app); + let ident = util::mark_internal_ident(&ident); + let lt = if resources_tick { + lt = Some(quote!('a)); + Some(quote!('a)) + } else { + None + }; + module_items.push(quote!( #[doc(inline)] - pub use super::#ident as Locals; + pub use super::#ident as LocalResources; + )); + + fields.push(quote!( + /// Local Resources this task has access to + pub local: #name::LocalResources<#lt> )); + + values.push(quote!(local: #name::LocalResources::new())); } - if ctxt.has_resources(app) { - let ident = util::resources_ident(ctxt, app); + if ctxt.has_shared_resources(app) { + let ident = util::shared_resources_ident(ctxt, app); let ident = util::mark_internal_ident(&ident); let lt = if resources_tick { lt = Some(quote!('a)); @@ -76,12 +99,12 @@ pub fn codegen( module_items.push(quote!( #[doc(inline)] - pub use super::#ident as Resources; + pub use super::#ident as SharedResources; )); fields.push(quote!( - /// Resources this task has access to - pub resources: #name::Resources<#lt> + /// Shared Resources this task has access to + pub shared: #name::SharedResources<#lt> )); let priority = if ctxt.is_init() { @@ -89,38 +112,10 @@ pub fn codegen( } else { Some(quote!(priority)) }; - values.push(quote!(resources: #name::Resources::new(#priority))); + values.push(quote!(shared: #name::SharedResources::new(#priority))); } if let Context::Init = ctxt { - let late_fields = analysis - .late_resources - .iter() - .flat_map(|resources| { - resources.iter().map(|name| { - let ty = &app.late_resources[name].ty; - let cfgs = &app.late_resources[name].cfgs; - - quote!( - #(#cfgs)* - pub #name: #ty - ) - }) - }) - .collect::>(); - - let internal_late_ident = util::mark_internal_name("LateResources"); - items.push(quote!( - /// Resources initialized at runtime - #[allow(non_snake_case)] - pub struct #internal_late_ident { - #(#late_fields),* - } - )); - module_items.push(quote!( - pub use super::#internal_late_ident as LateResources; - )); - let monotonic_types: Vec<_> = app .monotonics .iter() -- cgit v1.2.3 From d7393c5b27fc95f3569d12137ee0c4d03ff7e2ba Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Wed, 7 Jul 2021 21:03:56 +0200 Subject: Full local resource syntax working --- macros/src/codegen.rs | 12 ++++++----- macros/src/codegen/hardware_tasks.rs | 31 +++++++++++++--------------- macros/src/codegen/idle.rs | 31 +++++++++++++++------------- macros/src/codegen/init.rs | 15 ++++++++++++-- macros/src/codegen/local_resources.rs | 31 +++++++++++++++++++++------- macros/src/codegen/local_resources_struct.rs | 24 ++++++++++++++++----- macros/src/codegen/module.rs | 7 ++++--- macros/src/codegen/software_tasks.rs | 22 +++++++++++++------- macros/src/codegen/util.rs | 13 ------------ 9 files changed, 112 insertions(+), 74 deletions(-) (limited to 'macros/src/codegen/module.rs') diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs index 081c37fa..9c1ae88c 100644 --- a/macros/src/codegen.rs +++ b/macros/src/codegen.rs @@ -10,12 +10,12 @@ mod hardware_tasks; mod idle; mod init; mod local_resources; -mod shared_resources; mod local_resources_struct; -mod shared_resources_struct; mod module; mod post_init; mod pre_init; +mod shared_resources; +mod shared_resources_struct; mod software_tasks; mod timer_queue; mod util; @@ -53,7 +53,7 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { mod_app.push(quote!( #mod_app_init - #mod_app_idle + #(#mod_app_idle)* )); let main = util::suffixed("main"); @@ -84,8 +84,10 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { } )); - let (mod_app_shared_resources, mod_shared_resources) = shared_resources::codegen(app, analysis, extra); - let (mod_app_local_resources, mod_local_resources) = local_resources::codegen(app, analysis, extra); + let (mod_app_shared_resources, mod_shared_resources) = + shared_resources::codegen(app, analysis, extra); + let (mod_app_local_resources, mod_local_resources) = + local_resources::codegen(app, analysis, extra); let (mod_app_hardware_tasks, root_hardware_tasks, user_hardware_tasks) = hardware_tasks::codegen(app, analysis, extra); diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs index a69f9c9b..c7f3e7d9 100644 --- a/macros/src/codegen/hardware_tasks.rs +++ b/macros/src/codegen/hardware_tasks.rs @@ -57,13 +57,17 @@ pub fn codegen( } )); - let mut needs_lt = false; + let mut shared_needs_lt = false; + let mut local_needs_lt = false; // TODO: Fix locals // `${task}Locals` if !task.args.local_resources.is_empty() { - let (item, constructor) = - local_resources_struct::codegen(Context::HardwareTask(name), &mut needs_lt, app); + let (item, constructor) = local_resources_struct::codegen( + Context::HardwareTask(name), + &mut local_needs_lt, + app, + ); root.push(item); @@ -72,8 +76,11 @@ pub fn codegen( // `${task}Resources` if !task.args.shared_resources.is_empty() { - let (item, constructor) = - shared_resources_struct::codegen(Context::HardwareTask(name), &mut needs_lt, app); + let (item, constructor) = shared_resources_struct::codegen( + Context::HardwareTask(name), + &mut shared_needs_lt, + app, + ); root.push(item); @@ -82,23 +89,13 @@ pub fn codegen( root.push(module::codegen( Context::HardwareTask(name), - needs_lt, + shared_needs_lt, + local_needs_lt, app, analysis, extra, )); - // TODO: Fix locals - // // `${task}Locals` - // let mut locals_pat = None; - // if !task.locals.is_empty() { - // let (struct_, pat) = - // local_resources_struct::codegen(Context::HardwareTask(name), &task.locals, app); - - // root.push(struct_); - // locals_pat = Some(pat); - // } - if !task.is_extern { let attrs = &task.attrs; let context = &task.context; diff --git a/macros/src/codegen/idle.rs b/macros/src/codegen/idle.rs index 9c8a5f76..d6539316 100644 --- a/macros/src/codegen/idle.rs +++ b/macros/src/codegen/idle.rs @@ -15,7 +15,7 @@ pub fn codegen( extra: &Extra, ) -> ( // mod_app_idle -- the `${idle}Resources` constructor - Option, + Vec, // root_idle -- items that must be placed in the root of the crate: // - the `${idle}Locals` struct // - the `${idle}Resources` struct @@ -27,31 +27,34 @@ pub fn codegen( TokenStream2, ) { if let Some(idle) = &app.idle { - let mut needs_lt = false; - let mut mod_app = None; + let mut shared_needs_lt = false; + let mut local_needs_lt = false; + let mut mod_app = vec![]; let mut root_idle = vec![]; let name = &idle.name; if !idle.args.shared_resources.is_empty() { - let (item, constructor) = shared_resources_struct::codegen(Context::Idle, &mut needs_lt, app); + let (item, constructor) = + shared_resources_struct::codegen(Context::Idle, &mut shared_needs_lt, app); root_idle.push(item); - mod_app = Some(constructor); + mod_app.push(constructor); } - // TODO: Fix locals - // if !idle.locals.is_empty() { - // let (locals, pat) = locals::codegen(Context::Idle, &idle.locals, app); + if !idle.args.local_resources.is_empty() { + let (item, constructor) = + local_resources_struct::codegen(Context::Idle, &mut local_needs_lt, app); - // locals_new = Some(quote!(#name::Locals::new())); - // locals_pat = Some(pat); - // root_idle.push(locals); - // } + root_idle.push(item); + + mod_app.push(constructor); + } root_idle.push(module::codegen( Context::Idle, - needs_lt, + shared_needs_lt, + local_needs_lt, app, analysis, extra, @@ -78,7 +81,7 @@ pub fn codegen( (mod_app, root_idle, user_idle, call_idle) } else { ( - None, + vec![], vec![], None, quote!(loop { diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs index e3f74086..1bea7b7e 100644 --- a/macros/src/codegen/init.rs +++ b/macros/src/codegen/init.rs @@ -26,7 +26,7 @@ type CodegenResult = ( /// Generates support code for `#[init]` functions pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult { let init = &app.init; - let mut needs_lt = false; + let mut local_needs_lt = false; let name = &init.name; let mut root_init = vec![]; @@ -96,6 +96,16 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult { let mut mod_app = None; + // `${task}Locals` + if !init.args.local_resources.is_empty() { + let (item, constructor) = + local_resources_struct::codegen(Context::Init, &mut local_needs_lt, app); + + root_init.push(item); + + mod_app = Some(constructor); + } + // let locals_new = locals_new.iter(); let call_init = quote! { let (shared_resources, local_resources, mut monotonics) = #name(#name::Context::new(core.into())); @@ -103,7 +113,8 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult { root_init.push(module::codegen( Context::Init, - needs_lt, + false, + local_needs_lt, app, analysis, extra, diff --git a/macros/src/codegen/local_resources.rs b/macros/src/codegen/local_resources.rs index 13891f93..70f75809 100644 --- a/macros/src/codegen/local_resources.rs +++ b/macros/src/codegen/local_resources.rs @@ -9,8 +9,8 @@ use crate::{analyze::Analysis, check::Extra, codegen::util}; /// I.e. the `static` variables and theirs proxies. pub fn codegen( app: &App, - analysis: &Analysis, - extra: &Extra, + _analysis: &Analysis, + _extra: &Extra, ) -> ( // mod_app -- the `static` variables behind the proxies Vec, @@ -22,14 +22,10 @@ pub fn codegen( // All local resources declared in the `#[local]' struct for (name, res) in &app.local_resources { - // let expr = &res.expr; // TODO: Extract from tasks???... let cfgs = &res.cfgs; let ty = &res.ty; let mangled_name = util::mark_internal_ident(&util::static_local_resource_ident(name)); - let ty = quote!(rtic::RacyCell>); - let expr = quote!(rtic::RacyCell::new(core::mem::MaybeUninit::uninit())); - let attrs = &res.attrs; // late resources in `util::link_section_uninit` let section = util::link_section_uninit(true); @@ -43,7 +39,28 @@ pub fn codegen( #(#attrs)* #(#cfgs)* #section - static #mangled_name: #ty = #expr; + static #mangled_name: rtic::RacyCell> = rtic::RacyCell::new(core::mem::MaybeUninit::uninit()); + )); + } + + // All declared `local = [NAME: TY = EXPR]` local resources + for (name, task_local) in app.declared_local_resources() { + let cfgs = &task_local.cfgs; + let ty = &task_local.ty; + let expr = &task_local.expr; + let attrs = &task_local.attrs; + + let mangled_name = util::mark_internal_ident(&util::static_local_resource_ident(name)); + + // For future use + // let doc = format!(" RTIC internal: {}:{}", file!(), line!()); + mod_app.push(quote!( + #[allow(non_upper_case_globals)] + // #[doc = #doc] + #[doc(hidden)] + #(#attrs)* + #(#cfgs)* + static #mangled_name: rtic::RacyCell<#ty> = rtic::RacyCell::new(#expr); )); } diff --git a/macros/src/codegen/local_resources_struct.rs b/macros/src/codegen/local_resources_struct.rs index 14706a5b..0283d526 100644 --- a/macros/src/codegen/local_resources_struct.rs +++ b/macros/src/codegen/local_resources_struct.rs @@ -1,6 +1,9 @@ use proc_macro2::TokenStream as TokenStream2; use quote::quote; -use rtic_syntax::{ast::App, Context}; +use rtic_syntax::{ + ast::{App, TaskLocal}, + Context, +}; use crate::codegen::util; @@ -20,9 +23,15 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2, let mut has_cfgs = false; for (name, task_local) in resources { - let res = app.local_resources.get(name).expect("UNREACHABLE"); + let (cfgs, ty, is_declared) = match task_local { + TaskLocal::External => { + let r = app.local_resources.get(name).expect("UNREACHABLE"); + (&r.cfgs, &r.ty, false) + } + TaskLocal::Declared(r) => (&r.cfgs, &r.ty, true), + _ => unreachable!(), + }; - let cfgs = &res.cfgs; has_cfgs |= !cfgs.is_empty(); let lt = if ctxt.runs_once() { @@ -32,7 +41,6 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2, quote!('a) }; - let ty = &res.ty; let mangled_name = util::mark_internal_ident(&util::static_local_resource_ident(name)); fields.push(quote!( @@ -40,7 +48,13 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2, pub #name: &#lt mut #ty )); - let expr = quote!(&mut *#mangled_name.get_mut_unchecked().as_mut_ptr()); + let expr = if is_declared { + // If the local resources is already initialized, we only need to access its value and + // not go through an `MaybeUninit` + quote!(#mangled_name.get_mut_unchecked()) + } else { + quote!(&mut *#mangled_name.get_mut_unchecked().as_mut_ptr()) + }; values.push(quote!( #(#cfgs)* diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index adf64d5b..4fba2f38 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -5,7 +5,8 @@ use rtic_syntax::{ast::App, Context}; pub fn codegen( ctxt: Context, - resources_tick: bool, + shared_resources_tick: bool, + local_resources_tick: bool, app: &App, analysis: &Analysis, extra: &Extra, @@ -67,7 +68,7 @@ pub fn codegen( if ctxt.has_local_resources(app) { let ident = util::local_resources_ident(ctxt, app); let ident = util::mark_internal_ident(&ident); - let lt = if resources_tick { + let lt = if local_resources_tick { lt = Some(quote!('a)); Some(quote!('a)) } else { @@ -90,7 +91,7 @@ pub fn codegen( if ctxt.has_shared_resources(app) { let ident = util::shared_resources_ident(ctxt, app); let ident = util::mark_internal_ident(&ident); - let lt = if resources_tick { + let lt = if shared_resources_tick { lt = Some(quote!('a)); Some(quote!('a)) } else { diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index da594e7d..6941d9a0 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -90,13 +90,16 @@ pub fn codegen( )); // `${task}Resources` - let mut needs_lt = false; + let mut shared_needs_lt = false; + let mut local_needs_lt = false; - // TODO: Fix locals // `${task}Locals` if !task.args.local_resources.is_empty() { - let (item, constructor) = - local_resources_struct::codegen(Context::SoftwareTask(name), &mut needs_lt, app); + let (item, constructor) = local_resources_struct::codegen( + Context::SoftwareTask(name), + &mut local_needs_lt, + app, + ); root.push(item); @@ -104,15 +107,17 @@ pub fn codegen( } if !task.args.shared_resources.is_empty() { - let (item, constructor) = - shared_resources_struct::codegen(Context::SoftwareTask(name), &mut needs_lt, app); + let (item, constructor) = shared_resources_struct::codegen( + Context::SoftwareTask(name), + &mut shared_needs_lt, + app, + ); root.push(item); mod_app.push(constructor); } - if !&task.is_extern { let context = &task.context; let attrs = &task.attrs; @@ -133,7 +138,8 @@ pub fn codegen( root.push(module::codegen( Context::SoftwareTask(name), - needs_lt, + shared_needs_lt, + local_needs_lt, app, analysis, extra, diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs index dd0fb6d9..e3df2076 100644 --- a/macros/src/codegen/util.rs +++ b/macros/src/codegen/util.rs @@ -163,19 +163,6 @@ pub fn link_section_uninit(empty_expr: bool) -> Option { Some(quote!(#[link_section = #section])) } -/// Generates a pre-reexport identifier for the "locals" struct -pub fn locals_ident(ctxt: Context, app: &App) -> Ident { - let mut s = match ctxt { - Context::Init => app.init.name.to_string(), - Context::Idle => app.idle.as_ref().unwrap().name.to_string(), - Context::HardwareTask(ident) | Context::SoftwareTask(ident) => ident.to_string(), - }; - - s.push_str("Locals"); - - Ident::new(&s, Span::call_site()) -} - // Regroups the inputs of a task // // `inputs` could be &[`input: Foo`] OR &[`mut x: i32`, `ref y: i64`] -- cgit v1.2.3 From 8f3704378295fe8007290dbddbc1f4946ac599f9 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Thu, 8 Jul 2021 23:18:44 +0200 Subject: Cleanup from review (needs releases to compile) --- .github/workflows/build.yml | 2 +- Cargo.toml | 11 ++--- examples/t-init-main.rs | 24 ---------- examples/t-resource.rs | 85 ---------------------------------- examples/t-stask-main.rs | 29 ------------ examples/task_named_main.rs | 32 ------------- examples/type-usage.rs | 26 ----------- macros/Cargo.toml | 2 +- macros/src/codegen/local_resources.rs | 2 +- macros/src/codegen/module.rs | 3 -- macros/src/codegen/shared_resources.rs | 2 +- macros/src/codegen/software_tasks.rs | 2 +- macros/src/codegen/util.rs | 9 +--- 13 files changed, 11 insertions(+), 218 deletions(-) delete mode 100644 examples/t-init-main.rs delete mode 100644 examples/t-resource.rs delete mode 100644 examples/t-stask-main.rs delete mode 100644 examples/task_named_main.rs delete mode 100644 examples/type-usage.rs (limited to 'macros/src/codegen/module.rs') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5f9ad1ff..4d7ed950 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -138,7 +138,7 @@ jobs: with: use-cross: false command: check - args: --examples --target=${{ matrix.target }} --features __min_r1_43,${{ env.V7 }} + args: --examples --target=${{ matrix.target }} --features ${{ env.V7 }} # Verify the example output with run-pass tests testexamples: diff --git a/Cargo.toml b/Cargo.toml index a8903307..cfeb6208 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,10 +31,6 @@ required-features = ["__v7"] name = "schedule" required-features = ["__v7"] -[[example]] -name = "t-cfg-resources" -required-features = ["__min_r1_43"] - [[example]] name = "t-schedule" required-features = ["__v7"] @@ -46,14 +42,16 @@ required-features = ["__v7"] [dependencies] cortex-m = "0.7.0" cortex-m-rtic-macros = { path = "macros", version = "0.6.0-alpha.4" } -rtic-monotonic = "0.1.0-alpha.1" +# rtic-monotonic = "0.1.0-alpha.2" +rtic-monotonic = { path = "../rtic-monotonic" } rtic-core = "0.3.1" heapless = "0.6.1" bare-metal = "1.0.0" generic-array = "0.14" [dependencies.dwt-systick-monotonic] -version = "0.1.0-alpha.2" +# version = "0.1.0-alpha.3" +path = "../dwt-systick-monotonic" optional = true [build-dependencies] @@ -73,7 +71,6 @@ trybuild = "1" [features] # used for testing this crate; do not use in applications __v7 = ["dwt-systick-monotonic"] -__min_r1_43 = [] [profile.release] codegen-units = 1 diff --git a/examples/t-init-main.rs b/examples/t-init-main.rs deleted file mode 100644 index 92717887..00000000 --- a/examples/t-init-main.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965)] -mod app { - use cortex_m_semihosting::debug; - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - debug::exit(debug::EXIT_SUCCESS); - - (Shared {}, Local {}, init::Monotonics()) - } -} diff --git a/examples/t-resource.rs b/examples/t-resource.rs deleted file mode 100644 index 27324910..00000000 --- a/examples/t-resource.rs +++ /dev/null @@ -1,85 +0,0 @@ -//! [compile-pass] Check code generation of shared resources - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965)] -mod app { - #[shared] - struct Shared { - o2: u32, // idle - o3: u32, // EXTI0 - o4: u32, // idle - o5: u32, // EXTI1 - s1: u32, // idle & uart0 - s2: u32, // uart0 & uart1 - s3: u32, // idle & uart0 - } - - #[local] - struct Local {} - - #[init] - fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - ( - Shared { - o2: 0, - o3: 0, - o4: 0, - o5: 0, - s1: 0, - s2: 0, - s3: 0, - }, - Local {}, - init::Monotonics(), - ) - } - - #[idle(shared = [o2, &o4, s1, &s3])] - fn idle(mut c: idle::Context) -> ! { - // owned by `idle` == `&'static mut` - let _: shared_resources::o2 = c.shared.o2; - - // owned by `idle` == `&'static` if read-only - let _: &u32 = c.shared.o4; - - // shared with `idle` == `Mutex` - c.shared.s1.lock(|_| {}); - - // `&` if read-only - let _: &u32 = c.shared.s3; - - loop { - cortex_m::asm::nop(); - } - } - - #[task(binds = UART0, shared = [o3, s1, s2, &s3])] - fn uart0(c: uart0::Context) { - // owned by interrupt == `&mut` - let _: shared_resources::o3 = c.shared.o3; - - // no `Mutex` proxy when access from highest priority task - let _: shared_resources::s1 = c.shared.s1; - - // no `Mutex` proxy when co-owned by cooperative (same priority) tasks - let _: shared_resources::s2 = c.shared.s2; - - // `&` if read-only - let _: &u32 = c.shared.s3; - } - - #[task(binds = UART1, shared = [s2, &o5])] - fn uart1(c: uart1::Context) { - // owned by interrupt == `&` if read-only - let _: &u32 = c.shared.o5; - - // no `Mutex` proxy when co-owned by cooperative (same priority) tasks - let _: shared_resources::s2 = c.shared.s2; - } -} diff --git a/examples/t-stask-main.rs b/examples/t-stask-main.rs deleted file mode 100644 index ee5959de..00000000 --- a/examples/t-stask-main.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] -mod app { - use cortex_m_semihosting::debug; - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - taskmain::spawn().ok(); - - (Shared {}, Local {}, init::Monotonics()) - } - - #[task] - fn taskmain(_: taskmain::Context) { - debug::exit(debug::EXIT_SUCCESS); - } -} diff --git a/examples/task_named_main.rs b/examples/task_named_main.rs deleted file mode 100644 index b030b5e7..00000000 --- a/examples/task_named_main.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! examples/task_named_main.rs - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] -mod app { - use cortex_m_semihosting::{debug, hprintln}; - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - main::spawn().unwrap(); - - (Shared {}, Local {}, init::Monotonics()) - } - - #[task] - fn main(_: main::Context) { - hprintln!("This task is named main, useful for rust-analyzer").unwrap(); - debug::exit(debug::EXIT_SUCCESS); - } -} diff --git a/examples/type-usage.rs b/examples/type-usage.rs deleted file mode 100644 index e5a088f0..00000000 --- a/examples/type-usage.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! examples/type-usage.rs - -#![no_main] -#![no_std] - -use panic_semihosting as _; // panic handler -use rtic::app; - -#[app(device = lm3s6965, dispatchers = [SSI0])] -mod app { - type Test = u32; - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - (Shared {}, Local {}, init::Monotonics {}) - } - - #[task] - fn t1(_: t1::Context, _val: Test) {} -} diff --git a/macros/Cargo.toml b/macros/Cargo.toml index d1038658..3ae66cd2 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -23,4 +23,4 @@ proc-macro-error = "1" quote = "1" syn = "1" # rtic-syntax = "0.5.0-alpha.3" -rtic-syntax = { git = "https://github.com/rtic-rs/rtic-syntax.git", branch = "resources_take_2" } +rtic-syntax = { git = "https://github.com/rtic-rs/rtic-syntax.git" } diff --git a/macros/src/codegen/local_resources.rs b/macros/src/codegen/local_resources.rs index c5cddfb3..a9ffa925 100644 --- a/macros/src/codegen/local_resources.rs +++ b/macros/src/codegen/local_resources.rs @@ -28,7 +28,7 @@ pub fn codegen( let attrs = &res.attrs; // late resources in `util::link_section_uninit` - let section = util::link_section_uninit(true); + let section = util::link_section_uninit(); // For future use // let doc = format!(" RTIC internal: {}:{}", file!(), line!()); diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index 4fba2f38..a59d6628 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -198,9 +198,6 @@ pub fn codegen( pub use super::#internal_context_name as Context; )); - // not sure if this is the right way, maybe its backwards, - // that spawn_module should put in in root - if let Context::SoftwareTask(..) = ctxt { let spawnee = &app.software_tasks[name]; let priority = spawnee.args.priority; diff --git a/macros/src/codegen/shared_resources.rs b/macros/src/codegen/shared_resources.rs index d6336b32..181832fd 100644 --- a/macros/src/codegen/shared_resources.rs +++ b/macros/src/codegen/shared_resources.rs @@ -24,7 +24,7 @@ pub fn codegen( let mangled_name = util::mark_internal_ident(&util::static_shared_resource_ident(&name)); // late resources in `util::link_section_uninit` - let section = util::link_section_uninit(true); + let section = util::link_section_uninit(); let attrs = &res.attrs; // For future use diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index 6941d9a0..cfd21e40 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -45,7 +45,7 @@ pub fn codegen( quote!(rtic::export::Queue(unsafe { rtic::export::iQueue::u8_sc() })), - Box::new(|| util::link_section_uninit(true)), + Box::new(|| util::link_section_uninit()), ) }; mod_app.push(quote!( diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs index 3b0b9e4f..86bd6955 100644 --- a/macros/src/codegen/util.rs +++ b/macros/src/codegen/util.rs @@ -152,13 +152,8 @@ fn link_section_index() -> usize { } // NOTE `None` means in shared memory -pub fn link_section_uninit(empty_expr: bool) -> Option { - let section = if empty_expr { - let index = link_section_index(); - format!(".uninit.rtic{}", index) - } else { - format!(".uninit.rtic{}", link_section_index()) - }; +pub fn link_section_uninit() -> Option { + let section = format!(".uninit.rtic{}", link_section_index()); Some(quote!(#[link_section = #section])) } -- cgit v1.2.3