| // Works, but I have multiple ports.../pins
let mut sw1 = gpioc.pc4.into_pull_up_input(&mut gpioc.moder, &mut gpioc.pupdr);
let mut sw2 = gpiod.pd0.into_pull_up_input(&mut gpiod.moder, &mut gpiod.pupdr);
let mut sw3 = gpiod.pd1.into_pull_up_input(&mut gpiod.moder, &mut gpiod.pupdr);
sw1.make_interrupt_source(&mut dp.SYSCFG);
sw1.enable_interrupt(&mut dp.EXTI);
sw1.trigger_on_edge(&mut dp.EXTI, Edge::Falling);
sw2.make_interrupt_source(&mut dp.SYSCFG);
sw2.enable_interrupt(&mut dp.EXTI);
sw2.trigger_on_edge(&mut dp.EXTI, Edge::Falling);
sw3.make_interrupt_source(&mut dp.SYSCFG);
sw3.enable_interrupt(&mut dp.EXTI);
sw3.trigger_on_edge(&mut dp.EXTI, Edge::Falling);
unsafe {
NVIC::unmask(pac::Interrupt::EXTI0);
NVIC::unmask(pac::Interrupt::EXTI1);
NVIC::unmask(pac::Interrupt::EXTI4);
}
// Can't work, because I the GpioExt:: Parts is a type within the _port_ not gpio as a top level?
let sw1 = setup_button(gpioc, gpioc.pc4, stm32::Interrupt::EXTI4, &mut dp.SYSCFG, &mut dp.EXTI);
let sw2 = setup_button(gpiod, gpiod.pd0, stm32::Interrupt::EXTI0, &mut dp.SYSCFG, &mut dp.EXTI);
let sw3 = setup_button(gpiod, gpiod.pd1, stm32::Interrupt::EXTI1, &mut dp.SYSCFG, &mut dp.EXTI);
// Can't even use a function per port, because we can't pass the right type for the ping?
fn setup_button_C<E>(port: &mut hal::gpio::gpioc::Parts, &mut pin: hal::gpio::gpioc::PCx<InputPin<Error=E>>, nvic: stm32::Interrupt, syscfg: &mut SYSCFG, exti: &mut EXTI) {
let mut sw = pin.into_pull_up_input(&mut port.moder, &mut port.pupdr);
sw.make_interrupt_source(syscfg);
sw.enable_interrupt(exti);
sw.trigger_on_edge(exti, Edge::Falling);
unsafe {
NVIC::unmask(nvic);
}
sw
}
|