summaryrefslogtreecommitdiff
path: root/embassy-macros
diff options
context:
space:
mode:
authorMatous Hybl <hyblmatous@gmail.com>2021-11-16 12:13:43 +0100
committerMatous Hybl <hyblmatous@gmail.com>2021-11-23 11:00:37 +0100
commit0ca6060bfdc3807567e3a22dd356c238745f6cdd (patch)
tree116657522b48a3beccc34c19dec225330b2b11ec /embassy-macros
parentd98d18d2ee5932580463a91bc9ac257e51d0ac46 (diff)
downloadembassy-0ca6060bfdc3807567e3a22dd356c238745f6cdd.zip
Fix interrupt_take macro by specifying path to panic macro.
Diffstat (limited to 'embassy-macros')
-rw-r--r--embassy-macros/src/lib.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/embassy-macros/src/lib.rs b/embassy-macros/src/lib.rs
index 8d8accfc..bcd3f2ad 100644
--- a/embassy-macros/src/lib.rs
+++ b/embassy-macros/src/lib.rs
@@ -223,7 +223,11 @@ pub fn interrupt_declare(item: TokenStream) -> TokenStream {
};
result.into()
}
-
+/// # interrupt_take procedural macro
+///
+/// core::panic! is used as a default way to panic in this macro as there is no sensible way of enabling/disabling defmt for macro generation.
+/// We are aware that this brings bloat in the form of core::fmt, but the bloat is already included with e.g. array indexing panics.
+/// To get rid of this bloat, use the compiler flags `-Zbuild-std=core -Zbuild-std-features=panic_immediate_abort`.
#[proc_macro]
pub fn interrupt_take(item: TokenStream) -> TokenStream {
let name = syn::parse_macro_input!(item as syn::Ident);
@@ -250,7 +254,7 @@ pub fn interrupt_take(item: TokenStream) -> TokenStream {
static TAKEN: ::embassy::export::atomic::AtomicBool = ::embassy::export::atomic::AtomicBool::new(false);
if TAKEN.compare_exchange(false, true, ::embassy::export::atomic::Ordering::AcqRel, ::embassy::export::atomic::Ordering::Acquire).is_err() {
- panic!("IRQ Already taken");
+ core::panic!("IRQ Already taken");
}
let irq: interrupt::#name_interrupt = unsafe { ::core::mem::transmute(()) };