macros/interrupt_take: do not assume embassy-executor is a dependency of the user crate.

This commit is contained in:
Dario Nieuwenhuis 2022-08-17 14:49:42 +02:00
parent 2649f13dc7
commit ef9e373ec4
2 changed files with 10 additions and 4 deletions

View File

@ -6,6 +6,12 @@ use cortex_m::peripheral::NVIC;
use embassy_hal_common::Peripheral;
pub use embassy_macros::cortex_m_interrupt_take as take;
/// Do not use. Used for macros only. Not covered by semver guarantees.
#[doc(hidden)]
pub mod _export {
pub use atomic_polyfill as atomic;
}
/// Implementation detail, do not use outside embassy crates.
#[doc(hidden)]
pub struct Handler {

View File

@ -16,15 +16,15 @@ pub fn run(name: syn::Ident) -> Result<TokenStream, TokenStream> {
static HANDLER: interrupt::Handler;
}
let func = HANDLER.func.load(::embassy_executor::export::atomic::Ordering::Relaxed);
let ctx = HANDLER.ctx.load(::embassy_executor::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 func: fn(*mut ()) = ::core::mem::transmute(func);
func(ctx)
}
static TAKEN: ::embassy_executor::export::atomic::AtomicBool = ::embassy_executor::export::atomic::AtomicBool::new(false);
static TAKEN: interrupt::_export::atomic::AtomicBool = interrupt::_export::atomic::AtomicBool::new(false);
if TAKEN.compare_exchange(false, true, ::embassy_executor::export::atomic::Ordering::AcqRel, ::embassy_executor::export::atomic::Ordering::Acquire).is_err() {
if TAKEN.compare_exchange(false, true, interrupt::_export::atomic::Ordering::AcqRel, interrupt::_export::atomic::Ordering::Acquire).is_err() {
core::panic!("IRQ Already taken");
}