From 2b1e63838d452bc0b14f137b3a982cf03c190cc6 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 5 Apr 2024 14:19:25 -0700 Subject: [PATCH] actually that was slightly wrong --- drv/stm32h7-sprot-server/src/main.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drv/stm32h7-sprot-server/src/main.rs b/drv/stm32h7-sprot-server/src/main.rs index 61abacc0a..efcc639ea 100644 --- a/drv/stm32h7-sprot-server/src/main.rs +++ b/drv/stm32h7-sprot-server/src/main.rs @@ -426,10 +426,19 @@ impl Io { // If the timer notification was posted, and the GPIO IRQ // notification wasn't, we've waited for the timeout. Too bad! if notif & TIMER_MASK != 0 { + // Disable the IRQ, so that we don't get the notification later + // while in `recv`. + self.sys + .gpio_irq_control( + notifications::ROT_IRQ_MASK, + IrqControl::Disable, + ) + .unwrap_lite(); + // Record the timeout. self.stats.timeouts = self.stats.timeouts.wrapping_add(1); ringbuf_entry!(Trace::RotReadyTimeout); - break; + return false; } } @@ -441,11 +450,17 @@ impl Io { // doesn't go off later. if !irq_fired { self.sys - .gpio_irq_control(ROT_IRQ_MASK, IrqControl::Disable) + .gpio_irq_control( + notifications::ROT_IRQ_MASK, + IrqControl::Disable, + ) .unwrap_lite(); } - irq_fired + // We return `true` here regardless of `irq_fired`, because we may not + // have looped at all, if the line was asserted before we started + // waiting for the IRQ. The timeout case returns early, above. + true } }