Add "context" pointer to owned interrupt handlers.
This commit is contained in:
@ -75,7 +75,7 @@ impl Gpiote {
|
||||
// Enable interrupts
|
||||
gpiote.events_port.write(|w| w);
|
||||
gpiote.intenset.write(|w| w.port().set());
|
||||
irq.set_handler(Self::on_irq);
|
||||
irq.set_handler(Self::on_irq, core::ptr::null_mut());
|
||||
irq.unpend();
|
||||
irq.enable();
|
||||
|
||||
@ -296,7 +296,7 @@ impl Gpiote {
|
||||
})
|
||||
}
|
||||
|
||||
unsafe fn on_irq() {
|
||||
unsafe fn on_irq(_ctx: *mut ()) {
|
||||
let s = &(*INSTANCE);
|
||||
|
||||
for i in 0..8 {
|
||||
|
@ -146,7 +146,7 @@ impl Qspi {
|
||||
SIGNAL.reset();
|
||||
qspi.intenset.write(|w| w.ready().set());
|
||||
|
||||
irq.set_handler(irq_handler);
|
||||
irq.set_handler(irq_handler, core::ptr::null_mut());
|
||||
irq.unpend();
|
||||
irq.enable();
|
||||
|
||||
@ -347,7 +347,7 @@ impl Flash for Qspi {
|
||||
|
||||
static SIGNAL: Signal<()> = Signal::new();
|
||||
|
||||
unsafe fn irq_handler() {
|
||||
unsafe fn irq_handler(_ctx: *mut ()) {
|
||||
let p = crate::pac::Peripherals::steal().QSPI;
|
||||
if p.events_ready.read().events_ready().bit_is_set() {
|
||||
p.events_ready.reset();
|
||||
|
@ -105,8 +105,10 @@ impl<T: Instance> RTC<T> {
|
||||
while self.rtc.counter.read().bits() != 0 {}
|
||||
|
||||
T::set_rtc_instance(self);
|
||||
self.irq
|
||||
.set_handler(|| T::get_rtc_instance().on_interrupt());
|
||||
self.irq.set_handler(
|
||||
|_| T::get_rtc_instance().on_interrupt(),
|
||||
core::ptr::null_mut(),
|
||||
);
|
||||
self.irq.unpend();
|
||||
self.irq.enable();
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ where
|
||||
.write(|w| w.endtx().set().txstopped().set().endrx().set().rxto().set());
|
||||
|
||||
// Register ISR
|
||||
irq.set_handler(Self::on_irq);
|
||||
irq.set_handler(Self::on_irq, core::ptr::null_mut());
|
||||
irq.unpend();
|
||||
irq.enable();
|
||||
|
||||
@ -147,7 +147,7 @@ where
|
||||
self.instance.events_rxstarted.read().bits() != 0
|
||||
}
|
||||
|
||||
unsafe fn on_irq() {
|
||||
unsafe fn on_irq(_ctx: *mut ()) {
|
||||
let uarte = &*pac::UARTE0::ptr();
|
||||
|
||||
let mut try_disable = false;
|
||||
|
@ -55,12 +55,15 @@ impl<P: State> Registration<P> {
|
||||
// - therefore it's safe to overwrite it without dropping the previous contents
|
||||
unsafe { P::store().write(state) }
|
||||
|
||||
irq.set_handler(|| {
|
||||
// safety:
|
||||
// - If a PeripheralRegistration instance exists, P::storage() is initialized.
|
||||
// - It's OK to get a &mut to it since the irq is disabled.
|
||||
unsafe { P::store().as_mut() }.on_interrupt();
|
||||
});
|
||||
irq.set_handler(
|
||||
|_| {
|
||||
// safety:
|
||||
// - If a PeripheralRegistration instance exists, P::storage() is initialized.
|
||||
// - It's OK to get a &mut to it since the irq is disabled.
|
||||
unsafe { P::store().as_mut() }.on_interrupt();
|
||||
},
|
||||
core::ptr::null_mut(),
|
||||
);
|
||||
|
||||
compiler_fence(Ordering::SeqCst);
|
||||
irq.enable();
|
||||
@ -89,7 +92,7 @@ impl<P: State> Registration<P> {
|
||||
pub fn free(self) -> (P::Interrupt, P) {
|
||||
let irq = unsafe { ptr::read(&self.irq) };
|
||||
irq.disable();
|
||||
irq.set_handler(|| ());
|
||||
irq.remove_handler();
|
||||
mem::forget(self);
|
||||
let storage = P::store();
|
||||
(irq, unsafe { storage.read() })
|
||||
@ -99,7 +102,7 @@ impl<P: State> Registration<P> {
|
||||
impl<P: State> Drop for Registration<P> {
|
||||
fn drop(&mut self) {
|
||||
self.irq.disable();
|
||||
self.irq.set_handler(|| ());
|
||||
self.irq.remove_handler();
|
||||
|
||||
let storage = P::store();
|
||||
unsafe { storage.drop_in_place() };
|
||||
|
Reference in New Issue
Block a user