Ensure interrupt::take works without embassy-executor
Add "rtos-trace-interrupt" feature flag on embassy-macros and enable it for embassy-executor, to ensure that the interrupt::take! macro can be used without depending on embassy-executor.
This commit is contained in:
parent
529535194d
commit
045ae2c29f
@ -31,7 +31,7 @@ nightly = []
|
|||||||
integrated-timers = ["dep:embassy-time"]
|
integrated-timers = ["dep:embassy-time"]
|
||||||
|
|
||||||
# Trace interrupt invocations with rtos-trace.
|
# Trace interrupt invocations with rtos-trace.
|
||||||
rtos-trace-interrupt = ["rtos-trace"]
|
rtos-trace-interrupt = ["rtos-trace", "embassy-macros/rtos-trace-interrupt"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
defmt = { version = "0.3", optional = true }
|
defmt = { version = "0.3", optional = true }
|
||||||
|
@ -15,3 +15,6 @@ proc-macro = true
|
|||||||
[features]
|
[features]
|
||||||
std = []
|
std = []
|
||||||
wasm = []
|
wasm = []
|
||||||
|
|
||||||
|
# Enabling this cause interrupt::take! to require embassy-executor
|
||||||
|
rtos-trace-interrupt = []
|
||||||
|
@ -6,6 +6,23 @@ pub fn run(name: syn::Ident) -> Result<TokenStream, TokenStream> {
|
|||||||
let name_interrupt = format_ident!("{}", name);
|
let name_interrupt = format_ident!("{}", name);
|
||||||
let name_handler = format!("__EMBASSY_{}_HANDLER", name);
|
let name_handler = format!("__EMBASSY_{}_HANDLER", name);
|
||||||
|
|
||||||
|
#[cfg(feature = "rtos-trace-interrupt")]
|
||||||
|
let (isr_enter, isr_exit) = (
|
||||||
|
quote! {
|
||||||
|
::embassy_executor::rtos_trace_interrupt! {
|
||||||
|
::embassy_executor::export::trace::isr_enter();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
quote! {
|
||||||
|
::embassy_executor::rtos_trace_interrupt! {
|
||||||
|
::embassy_executor::export::trace::isr_exit();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
#[cfg(not(feature = "rtos-trace-interrupt"))]
|
||||||
|
let (isr_enter, isr_exit) = (quote! {}, quote! {});
|
||||||
|
|
||||||
let result = quote! {
|
let result = quote! {
|
||||||
{
|
{
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
@ -19,13 +36,11 @@ pub fn run(name: syn::Ident) -> Result<TokenStream, TokenStream> {
|
|||||||
let func = HANDLER.func.load(interrupt::_export::atomic::Ordering::Relaxed);
|
let func = HANDLER.func.load(interrupt::_export::atomic::Ordering::Relaxed);
|
||||||
let ctx = HANDLER.ctx.load(interrupt::_export::atomic::Ordering::Relaxed);
|
let ctx = HANDLER.ctx.load(interrupt::_export::atomic::Ordering::Relaxed);
|
||||||
let func: fn(*mut ()) = ::core::mem::transmute(func);
|
let func: fn(*mut ()) = ::core::mem::transmute(func);
|
||||||
::embassy_executor::rtos_trace_interrupt! {
|
#isr_enter
|
||||||
::embassy_executor::export::trace::isr_enter();
|
|
||||||
}
|
|
||||||
func(ctx);
|
func(ctx);
|
||||||
::embassy_executor::rtos_trace_interrupt! {
|
#isr_exit
|
||||||
::embassy_executor::export::trace::isr_exit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static TAKEN: interrupt::_export::atomic::AtomicBool = interrupt::_export::atomic::AtomicBool::new(false);
|
static TAKEN: interrupt::_export::atomic::AtomicBool = interrupt::_export::atomic::AtomicBool::new(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user