From d0f33add0a354da612a1543bdcd74418feedbaf2 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sat, 23 Feb 2019 21:48:47 +0100 Subject: add `binds` argument to the `interrupt` and `exception` attributes --- macros/src/codegen.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'macros/src/codegen.rs') diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs index 83e50266..117bce8c 100644 --- a/macros/src/codegen.rs +++ b/macros/src/codegen.rs @@ -469,6 +469,11 @@ fn post_init(ctxt: &Context, app: &App, analysis: &Analysis) -> proc_macro2::Tok let device = &app.args.device; let nvic_prio_bits = quote!(#device::NVIC_PRIO_BITS); for (name, exception) in &app.exceptions { + let name = if let Some(ref binds) = exception.args.binds { + binds + } else { + name + }; let priority = exception.args.priority; exprs.push(quote!(assert!(#priority <= (1 << #nvic_prio_bits)))); exprs.push(quote!(p.SCB.set_priority( @@ -1082,9 +1087,10 @@ fn exceptions(ctxt: &mut Context, app: &App, analysis: &Analysis) -> Vec Vec proc_macro2::Toke let device = &app.args.device; let nvic_prio_bits = quote!(#device::NVIC_PRIO_BITS); for (name, interrupt) in &app.interrupts { + let name = if let Some(ref binds) = interrupt.args.binds { + binds + } else { + name + }; let priority = interrupt.args.priority; exprs.push(quote!(p.NVIC.enable(#device::Interrupt::#name);)); exprs.push(quote!(assert!(#priority <= (1 << #nvic_prio_bits));)); -- cgit v1.2.3