Code size optimizations.
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
use core::cell::UnsafeCell;
|
||||
use core::marker::{PhantomData, PhantomPinned};
|
||||
use core::pin::Pin;
|
||||
use core::sync::atomic::{compiler_fence, Ordering};
|
||||
|
||||
use embassy::interrupt::{Interrupt, InterruptExt};
|
||||
|
||||
@ -39,8 +38,6 @@ impl<S: PeripheralState> PeripheralMutex<S> {
|
||||
}
|
||||
|
||||
this.irq.disable();
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
|
||||
this.irq.set_handler(|p| {
|
||||
// Safety: it's OK to get a &mut to the state, since
|
||||
// - We're in the IRQ, no one else can't preempt us
|
||||
@ -50,8 +47,6 @@ impl<S: PeripheralState> PeripheralMutex<S> {
|
||||
});
|
||||
this.irq
|
||||
.set_handler_context((&mut this.state) as *mut _ as *mut ());
|
||||
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
this.irq.enable();
|
||||
|
||||
this.irq_setup_done = true;
|
||||
@ -61,14 +56,11 @@ impl<S: PeripheralState> PeripheralMutex<S> {
|
||||
let this = unsafe { self.get_unchecked_mut() };
|
||||
|
||||
this.irq.disable();
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
|
||||
// Safety: it's OK to get a &mut to the state, since the irq is disabled.
|
||||
let state = unsafe { &mut *this.state.get() };
|
||||
|
||||
let r = f(state, &mut this.irq);
|
||||
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
this.irq.enable();
|
||||
|
||||
r
|
||||
|
@ -1,7 +1,6 @@
|
||||
use core::cell::UnsafeCell;
|
||||
use core::marker::{PhantomData, PhantomPinned};
|
||||
use core::pin::Pin;
|
||||
use core::sync::atomic::{compiler_fence, Ordering};
|
||||
|
||||
use embassy::interrupt::{Interrupt, InterruptExt};
|
||||
|
||||
@ -39,16 +38,12 @@ impl<S: PeripheralState> Peripheral<S> {
|
||||
}
|
||||
|
||||
this.irq.disable();
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
|
||||
this.irq.set_handler(|p| {
|
||||
let state = unsafe { &*(p as *const S) };
|
||||
state.on_interrupt();
|
||||
});
|
||||
this.irq
|
||||
.set_handler_context((&this.state) as *const _ as *mut ());
|
||||
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
this.irq.enable();
|
||||
|
||||
this.irq_setup_done = true;
|
||||
|
Reference in New Issue
Block a user