From 81d99ff1a0ccf8a8f22c93429c6ac30b8de43fe8 Mon Sep 17 00:00:00 2001 From: xoviat Date: Wed, 17 Mar 2021 20:56:48 -0500 Subject: [PATCH] stm32: exti: update api --- embassy-stm32f4/src/exti.rs | 2 +- embassy-stm32l0/src/exti.rs | 31 ++++++------------------------- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/embassy-stm32f4/src/exti.rs b/embassy-stm32f4/src/exti.rs index 140b6330..5c1a89f7 100644 --- a/embassy-stm32f4/src/exti.rs +++ b/embassy-stm32f4/src/exti.rs @@ -22,7 +22,7 @@ pub struct ExtiPin { } impl ExtiPin { - fn new(mut pin: T, interrupt: T::Interrupt) -> Self { + pub fn new(mut pin: T, interrupt: T::Interrupt) -> Self { let mut syscfg: SysCfg = unsafe { mem::transmute(()) }; cortex_m::interrupt::free(|_| { diff --git a/embassy-stm32l0/src/exti.rs b/embassy-stm32l0/src/exti.rs index 831fcb2a..32c56c49 100644 --- a/embassy-stm32l0/src/exti.rs +++ b/embassy-stm32l0/src/exti.rs @@ -13,34 +13,16 @@ use crate::hal::{ use crate::interrupt; use crate::pac::EXTI; -pub struct ExtiManager { - syscfg: SYSCFG, -} - -impl<'a> ExtiManager { - pub fn new(_exti: Exti, syscfg: SYSCFG) -> Self { - Self { syscfg } - } - - pub fn new_pin(&'static self, pin: T, interrupt: T::Interrupt) -> ExtiPin - where - T: PinWithInterrupt, - { - ExtiPin { - pin, - interrupt, - mgr: self, - } - } -} - pub struct ExtiPin { pin: T, interrupt: T::Interrupt, - mgr: &'static ExtiManager, } impl ExtiPin { + pub fn new(pin: T, interrupt: T::Interrupt) -> ExtiPin { + ExtiPin { pin, interrupt } + } + fn wait_for_edge<'a>( self: Pin<&'a mut Self>, edge: TriggerEdge, @@ -57,10 +39,9 @@ impl ExtiPin { let fut = InterruptFuture::new(&mut s.interrupt); let port = s.pin.port(); - let syscfg = &s.mgr.syscfg as *const _ as *mut SYSCFG; cortex_m::interrupt::free(|_| { - let syscfg = unsafe { &mut *syscfg }; - exti.listen_gpio(syscfg, port, line, edge); + let mut syscfg: SYSCFG = unsafe { mem::transmute(()) }; + exti.listen_gpio(&mut syscfg, port, line, edge); }); fut.await;