From 73a4d7c8bdec1589992c51c3912a2abcd820d535 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 5 Jul 2021 20:04:55 +0200 Subject: [PATCH] improve the error message --- macros/src/codegen.rs | 3 ++- macros/src/codegen/pre_init.rs | 5 +++-- macros/src/codegen/spawn_body.rs | 8 ++++---- macros/src/codegen/timer_queue.rs | 6 +++--- macros/src/codegen/util.rs | 4 ++++ 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs index 2433684cfb..659ab1da0a 100644 --- a/macros/src/codegen.rs +++ b/macros/src/codegen.rs @@ -120,6 +120,7 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { let name = &app.name; let device = extra.device; + let rt_err = util::rt_err_ident(); quote!( #(#user)* @@ -139,7 +140,7 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { // the user can't access the items within this `const` item const #name: () = { /// Always include the device crate which contains the vector table - use #device as _; + use #device as #rt_err; #check_excess_cores diff --git a/macros/src/codegen/pre_init.rs b/macros/src/codegen/pre_init.rs index f89dec9667..2f085c20e3 100644 --- a/macros/src/codegen/pre_init.rs +++ b/macros/src/codegen/pre_init.rs @@ -52,6 +52,7 @@ pub fn codegen( } let device = extra.device; + let rt_err = util::rt_err_ident(); let nvic_prio_bits = quote!(#device::NVIC_PRIO_BITS); // unmask interrupts and set their priorities @@ -76,14 +77,14 @@ pub fn codegen( let interrupt = util::interrupt_ident(core, app.args.cores); stmts.push(quote!( core.NVIC.set_priority( - #device::#interrupt::#name, + #rt_err::#interrupt::#name, rtic::export::logical2hw(#priority, #nvic_prio_bits), ); )); // NOTE unmask the interrupt *after* setting its priority: changing the priority of a pended // interrupt is implementation defined - stmts.push(quote!(rtic::export::NVIC::unmask(#device::#interrupt::#name);)); + stmts.push(quote!(rtic::export::NVIC::unmask(#rt_err::#interrupt::#name);)); } // cross-spawn barriers: now that priorities have been set and the interrupts have been unmasked diff --git a/macros/src/codegen/spawn_body.rs b/macros/src/codegen/spawn_body.rs index 3433875e90..4991a741d8 100644 --- a/macros/src/codegen/spawn_body.rs +++ b/macros/src/codegen/spawn_body.rs @@ -10,7 +10,7 @@ pub fn codegen( name: &Ident, app: &App, analysis: &Analysis, - extra: &Extra, + _extra: &Extra, ) -> TokenStream2 { let sender = spawner.core(app); let spawnee = &app.software_tasks[name]; @@ -44,16 +44,16 @@ pub fn codegen( ) }; - let device = extra.device; + let rt_err = util::rt_err_ident(); let enum_ = util::interrupt_ident(receiver, app.args.cores); let interrupt = &analysis.interrupts[&receiver][&priority]; let pend = if sender != receiver { quote!( - #device::xpend(#receiver, #device::#enum_::#interrupt); + #rt_err::xpend(#receiver, #rt_err::#enum_::#interrupt); ) } else { quote!( - rtic::pend(#device::#enum_::#interrupt); + rtic::pend(#rt_err::#enum_::#interrupt); ) }; diff --git a/macros/src/codegen/timer_queue.rs b/macros/src/codegen/timer_queue.rs index 56304001e0..ba0de66f6b 100644 --- a/macros/src/codegen/timer_queue.rs +++ b/macros/src/codegen/timer_queue.rs @@ -79,7 +79,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec Vec Ident { pub fn tq_ident(core: Core) -> Ident { Ident::new(&format!("TQ{}", core), Span::call_site()) } + +pub fn rt_err_ident() -> Ident { + Ident::new("you_must_enable_the_rt_feature_for_the_pac_in_your_cargo_toml", Span::call_site()) +}