rp/gpio: fix wait_for_* when multiple pins are in use.

This commit is contained in:
Dario Nieuwenhuis 2022-08-08 00:22:08 +02:00
parent 89e2e25d6f
commit 6c10fa44d0

View File

@ -152,7 +152,8 @@ unsafe fn IO_IRQ_BANK0() {
let event = (intsx.read().0 >> pin_group * 4) & 0xf as u32; let event = (intsx.read().0 >> pin_group * 4) & 0xf as u32;
if let Some(trigger) = InterruptTrigger::from_u32(event) { if let Some(trigger) = InterruptTrigger::from_u32(event) {
proc_intx.inte(pin / 8).write(|w| match trigger { critical_section::with(|_| {
proc_intx.inte(pin / 8).modify(|w| match trigger {
InterruptTrigger::AnyEdge => { InterruptTrigger::AnyEdge => {
w.set_edge_high(pin_group, false); w.set_edge_high(pin_group, false);
w.set_edge_low(pin_group, false); w.set_edge_low(pin_group, false);
@ -171,6 +172,7 @@ unsafe fn IO_IRQ_BANK0() {
w.set_edge_low(pin_group, false); w.set_edge_low(pin_group, false);
} }
}); });
});
INTERRUPT_WAKERS[pin as usize].wake(); INTERRUPT_WAKERS[pin as usize].wake();
} }
} }
@ -193,7 +195,8 @@ impl<'d, T: Pin> InputFuture<'d, T> {
// pin, and each group consists of LEVEL_LOW, LEVEL_HIGH, EDGE_LOW, // pin, and each group consists of LEVEL_LOW, LEVEL_HIGH, EDGE_LOW,
// and EGDE_HIGH. // and EGDE_HIGH.
let pin_group = (pin.pin() % 8) as usize; let pin_group = (pin.pin() % 8) as usize;
pin.int_proc().inte((pin.pin() / 8) as usize).write(|w| match level { critical_section::with(|_| {
pin.int_proc().inte((pin.pin() / 8) as usize).modify(|w| match level {
InterruptTrigger::LevelHigh => { InterruptTrigger::LevelHigh => {
debug!("InputFuture::new enable LevelHigh for pin {} \n", pin.pin()); debug!("InputFuture::new enable LevelHigh for pin {} \n", pin.pin());
w.set_level_high(pin_group, true); w.set_level_high(pin_group, true);
@ -211,6 +214,7 @@ impl<'d, T: Pin> InputFuture<'d, T> {
// noop // noop
} }
}); });
});
irq.enable(); irq.enable();
} }