stm32: exti: update api
This commit is contained in:
		
							parent
							
								
									ccf2ea77f0
								
							
						
					
					
						commit
						81d99ff1a0
					
				@ -22,7 +22,7 @@ pub struct ExtiPin<T: gpio::ExtiPin + WithInterrupt> {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<T: gpio::ExtiPin + WithInterrupt> ExtiPin<T> {
 | 
					impl<T: gpio::ExtiPin + WithInterrupt> ExtiPin<T> {
 | 
				
			||||||
    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(()) };
 | 
					        let mut syscfg: SysCfg = unsafe { mem::transmute(()) };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cortex_m::interrupt::free(|_| {
 | 
					        cortex_m::interrupt::free(|_| {
 | 
				
			||||||
 | 
				
			|||||||
@ -13,34 +13,16 @@ use crate::hal::{
 | 
				
			|||||||
use crate::interrupt;
 | 
					use crate::interrupt;
 | 
				
			||||||
use crate::pac::EXTI;
 | 
					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<T>(&'static self, pin: T, interrupt: T::Interrupt) -> ExtiPin<T>
 | 
					 | 
				
			||||||
    where
 | 
					 | 
				
			||||||
        T: PinWithInterrupt,
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        ExtiPin {
 | 
					 | 
				
			||||||
            pin,
 | 
					 | 
				
			||||||
            interrupt,
 | 
					 | 
				
			||||||
            mgr: self,
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pub struct ExtiPin<T: PinWithInterrupt> {
 | 
					pub struct ExtiPin<T: PinWithInterrupt> {
 | 
				
			||||||
    pin: T,
 | 
					    pin: T,
 | 
				
			||||||
    interrupt: T::Interrupt,
 | 
					    interrupt: T::Interrupt,
 | 
				
			||||||
    mgr: &'static ExtiManager,
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl<T: PinWithInterrupt + 'static> ExtiPin<T> {
 | 
					impl<T: PinWithInterrupt + 'static> ExtiPin<T> {
 | 
				
			||||||
 | 
					    pub fn new(pin: T, interrupt: T::Interrupt) -> ExtiPin<T> {
 | 
				
			||||||
 | 
					        ExtiPin { pin, interrupt }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn wait_for_edge<'a>(
 | 
					    fn wait_for_edge<'a>(
 | 
				
			||||||
        self: Pin<&'a mut Self>,
 | 
					        self: Pin<&'a mut Self>,
 | 
				
			||||||
        edge: TriggerEdge,
 | 
					        edge: TriggerEdge,
 | 
				
			||||||
@ -57,10 +39,9 @@ impl<T: PinWithInterrupt + 'static> ExtiPin<T> {
 | 
				
			|||||||
            let fut = InterruptFuture::new(&mut s.interrupt);
 | 
					            let fut = InterruptFuture::new(&mut s.interrupt);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            let port = s.pin.port();
 | 
					            let port = s.pin.port();
 | 
				
			||||||
            let syscfg = &s.mgr.syscfg as *const _ as *mut SYSCFG;
 | 
					 | 
				
			||||||
            cortex_m::interrupt::free(|_| {
 | 
					            cortex_m::interrupt::free(|_| {
 | 
				
			||||||
                let syscfg = unsafe { &mut *syscfg };
 | 
					                let mut syscfg: SYSCFG = unsafe { mem::transmute(()) };
 | 
				
			||||||
                exti.listen_gpio(syscfg, port, line, edge);
 | 
					                exti.listen_gpio(&mut syscfg, port, line, edge);
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            fut.await;
 | 
					            fut.await;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user