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(()) }; diff --git a/examples/nrf/src/bin/buffered_uart.rs b/examples/nrf/src/bin/buffered_uart.rs index 69c7de93..90d28878 100644 --- a/examples/nrf/src/bin/buffered_uart.rs +++ b/examples/nrf/src/bin/buffered_uart.rs @@ -5,7 +5,6 @@ #[path = "../example_common.rs"] mod example_common; -use defmt::panic; use embassy::executor::Spawner; use embassy::io::{AsyncBufReadExt, AsyncWriteExt}; use embassy_nrf::buffered_uarte::State; diff --git a/examples/nrf/src/bin/multiprio.rs b/examples/nrf/src/bin/multiprio.rs index 78ea5bc0..85e12690 100644 --- a/examples/nrf/src/bin/multiprio.rs +++ b/examples/nrf/src/bin/multiprio.rs @@ -62,7 +62,6 @@ mod example_common; use example_common::*; use cortex_m_rt::entry; -use defmt::panic; use embassy::executor::{Executor, InterruptExecutor}; use embassy::interrupt::InterruptExt; use embassy::time::{Duration, Instant, Timer}; diff --git a/examples/nrf/src/bin/qspi.rs b/examples/nrf/src/bin/qspi.rs index e5560cea..c7f9503b 100644 --- a/examples/nrf/src/bin/qspi.rs +++ b/examples/nrf/src/bin/qspi.rs @@ -5,7 +5,7 @@ #[path = "../example_common.rs"] mod example_common; -use defmt::{assert_eq, panic}; +use defmt::assert_eq; use embassy::executor::Spawner; use embassy::traits::flash::Flash; use embassy_nrf::Peripherals; diff --git a/examples/nrf/src/bin/qspi_lowpower.rs b/examples/nrf/src/bin/qspi_lowpower.rs index 7a3c68ee..e9e1bac4 100644 --- a/examples/nrf/src/bin/qspi_lowpower.rs +++ b/examples/nrf/src/bin/qspi_lowpower.rs @@ -6,7 +6,6 @@ mod example_common; use core::mem; -use defmt::panic; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy::traits::flash::Flash; diff --git a/examples/nrf/src/bin/rng.rs b/examples/nrf/src/bin/rng.rs index 5f575897..d12684e3 100644 --- a/examples/nrf/src/bin/rng.rs +++ b/examples/nrf/src/bin/rng.rs @@ -5,7 +5,7 @@ #[path = "../example_common.rs"] mod example_common; -use defmt::{panic, unwrap}; +use defmt::unwrap; use embassy::executor::Spawner; use embassy::traits::rng::Rng as _; use embassy_nrf::interrupt; diff --git a/examples/nrf/src/bin/saadc.rs b/examples/nrf/src/bin/saadc.rs index c6eac555..bc6b2b52 100644 --- a/examples/nrf/src/bin/saadc.rs +++ b/examples/nrf/src/bin/saadc.rs @@ -4,7 +4,6 @@ #[path = "../example_common.rs"] mod example_common; -use defmt::panic; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::saadc::{ChannelConfig, Config, Saadc}; diff --git a/examples/nrf/src/bin/saadc_continuous.rs b/examples/nrf/src/bin/saadc_continuous.rs index a06a01e9..81559237 100644 --- a/examples/nrf/src/bin/saadc_continuous.rs +++ b/examples/nrf/src/bin/saadc_continuous.rs @@ -4,7 +4,6 @@ #[path = "../example_common.rs"] mod example_common; -use defmt::panic; use embassy::executor::Spawner; use embassy_nrf::ppi::Ppi; use embassy_nrf::saadc::{ChannelConfig, Config, Saadc, SamplerState}; diff --git a/examples/nrf/src/bin/spim.rs b/examples/nrf/src/bin/spim.rs index 9afd17ef..d34ca0b8 100644 --- a/examples/nrf/src/bin/spim.rs +++ b/examples/nrf/src/bin/spim.rs @@ -5,7 +5,6 @@ #[path = "../example_common.rs"] mod example_common; -use defmt::panic; use embassy::executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; use embassy_nrf::Peripherals; diff --git a/examples/nrf/src/bin/temp.rs b/examples/nrf/src/bin/temp.rs index af9775f5..4b30b6ea 100644 --- a/examples/nrf/src/bin/temp.rs +++ b/examples/nrf/src/bin/temp.rs @@ -6,7 +6,6 @@ mod example_common; use example_common::*; -use defmt::panic; use embassy::{ executor::Spawner, time::{Duration, Timer}, diff --git a/examples/nrf/src/bin/twim.rs b/examples/nrf/src/bin/twim.rs index c0a2aab5..4c2f2bf2 100644 --- a/examples/nrf/src/bin/twim.rs +++ b/examples/nrf/src/bin/twim.rs @@ -9,7 +9,7 @@ #[path = "../example_common.rs"] mod example_common; -use defmt::{panic, *}; +use defmt::*; use embassy::executor::Spawner; use embassy_nrf::twim::{self, Twim}; use embassy_nrf::{interrupt, Peripherals}; diff --git a/examples/nrf/src/bin/twim_lowpower.rs b/examples/nrf/src/bin/twim_lowpower.rs index e25ecb57..62a5f0c9 100644 --- a/examples/nrf/src/bin/twim_lowpower.rs +++ b/examples/nrf/src/bin/twim_lowpower.rs @@ -13,7 +13,7 @@ mod example_common; use core::mem; -use defmt::{panic, *}; +use defmt::*; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; use embassy_nrf::twim::{self, Twim}; diff --git a/examples/nrf/src/bin/uart.rs b/examples/nrf/src/bin/uart.rs index df7a4e78..6b89e083 100644 --- a/examples/nrf/src/bin/uart.rs +++ b/examples/nrf/src/bin/uart.rs @@ -6,7 +6,6 @@ mod example_common; use example_common::*; -use defmt::panic; use embassy::executor::Spawner; use embassy::traits::uart::{Read, Write}; use embassy_nrf::gpio::NoPin; diff --git a/examples/nrf/src/bin/uart_idle.rs b/examples/nrf/src/bin/uart_idle.rs index e9f4a285..ec9a3602 100644 --- a/examples/nrf/src/bin/uart_idle.rs +++ b/examples/nrf/src/bin/uart_idle.rs @@ -7,7 +7,6 @@ mod example_common; use embassy_traits::uart::ReadUntilIdle; use example_common::*; -use defmt::panic; use embassy::executor::Spawner; use embassy::traits::uart::Write; use embassy_nrf::gpio::NoPin; diff --git a/examples/stm32l0/src/bin/usart_irq.rs b/examples/stm32l0/src/bin/usart_irq.rs index 8dc047cf..58807390 100644 --- a/examples/stm32l0/src/bin/usart_irq.rs +++ b/examples/stm32l0/src/bin/usart_irq.rs @@ -7,7 +7,6 @@ mod example_common; use example_common::*; -use defmt::panic; use embassy::executor::Spawner; use embassy::io::{AsyncBufReadExt, AsyncWriteExt}; use embassy_stm32::dma::NoDma;