From d54f8bb52f9d4f38544d448713f047a63ce5fb9c Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 24 Apr 2018 20:51:10 +0200 Subject: add macro to bind all interrupts to DefaultHandler --- cortex-m-rt/src/lib.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'cortex-m-rt/src') diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs index d4486e1..e0ddb76 100644 --- a/cortex-m-rt/src/lib.rs +++ b/cortex-m-rt/src/lib.rs @@ -215,3 +215,22 @@ macro_rules! exception { } }; } + +/// Macro to bind all the 240 interrupt handlers to the `DefaultHandler` exception handler. +/// +/// The use case for this macro is writing device agnostic programs +#[macro_export] +macro_rules! interrupts { + (DefaultHandler) => { + #[doc(hidden)] + #[link_section = ".vector_table.interrupts"] + #[no_mangle] + pub static __INTERRUPTS: [Option; 240] = [{ + extern "C" { + fn DefaultHandler(); + } + + Some(DefaultHandler) + }; 240]; + }; +} -- cgit v1.2.3