From 8926397f4592f22a5ed54f772a979578ca36628f Mon Sep 17 00:00:00 2001
From: kbleeke <pluth@0t.re>
Date: Mon, 27 Mar 2023 14:37:39 +0200
Subject: [PATCH] address irq nits

---
 examples/rpi-pico-w/src/main.rs |  6 ------
 examples/rpi-pico-w/src/pio.rs  |  3 ---
 src/bus.rs                      | 12 ++++++------
 src/runner.rs                   |  4 ----
 4 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/examples/rpi-pico-w/src/main.rs b/examples/rpi-pico-w/src/main.rs
index 97e2d6a60..434851378 100644
--- a/examples/rpi-pico-w/src/main.rs
+++ b/examples/rpi-pico-w/src/main.rs
@@ -227,10 +227,4 @@ impl cyw43::SpiBusCyw43 for MySpi {
         self.read(read).await;
         self.cs.set_high();
     }
-
-    async fn wait_for_event(&mut self) {}
-
-    fn clear_event(&mut self) {}
-
-    
 }
diff --git a/examples/rpi-pico-w/src/pio.rs b/examples/rpi-pico-w/src/pio.rs
index 6df227468..1cefb1734 100644
--- a/examples/rpi-pico-w/src/pio.rs
+++ b/examples/rpi-pico-w/src/pio.rs
@@ -170,9 +170,6 @@ where
 
     async fn wait_for_event(&mut self) {
         self.sm.wait_irq(0).await;
-    }
-
-    fn clear_event(&mut self) {
         self.sm.clear_irq(0);
     }
 }
diff --git a/src/bus.rs b/src/bus.rs
index 6ec5d0bd6..d2a249f97 100644
--- a/src/bus.rs
+++ b/src/bus.rs
@@ -1,5 +1,6 @@
 use core::slice;
 
+use embassy_futures::yield_now;
 use embassy_time::{Duration, Timer};
 use embedded_hal_1::digital::OutputPin;
 use futures::FutureExt;
@@ -20,8 +21,11 @@ pub trait SpiBusCyw43 {
     /// Callers that want to read `n` word from the backplane, have to provide a slice that is `n+1` words long.
     async fn cmd_read(&mut self, write: u32, read: &mut [u32]);
 
-    async fn wait_for_event(&mut self);
-    fn clear_event(&mut self);
+    /// Wait for events from the Device. A typical implementation would wait for the IRQ pin to be high.
+    /// The default implementation always reports ready, resulting in active polling of the device.
+    async fn wait_for_event(&mut self) {
+        yield_now().await;
+    }
 }
 
 pub(crate) struct Bus<PWR, SPI> {
@@ -305,10 +309,6 @@ where
     pub async fn wait_for_event(&mut self) {
         self.spi.wait_for_event().await;
     }
-
-    pub fn clear_event(&mut self) {
-        self.spi.clear_event();
-    }
 }
 
 fn swap16(x: u32) -> u32 {
diff --git a/src/runner.rs b/src/runner.rs
index a1de0770e..abfac3ae3 100644
--- a/src/runner.rs
+++ b/src/runner.rs
@@ -1,7 +1,6 @@
 use core::slice;
 
 use embassy_futures::select::{select3, Either3};
-use embassy_futures::yield_now;
 use embassy_net_driver_channel as ch;
 use embassy_sync::pubsub::PubSubBehavior;
 use embassy_time::{block_for, Duration, Timer};
@@ -304,7 +303,6 @@ where
 
     /// Wait for IRQ on F2 packet available
     async fn handle_irq(&mut self, buf: &mut [u32; 512]) {
-        self.bus.clear_event();
         // Receive stuff
         let irq = self.bus.read16(FUNC_BUS, REG_BUS_INTERRUPT).await;
         trace!("irq{}", FormatInterrupt(irq));
@@ -331,8 +329,6 @@ where
             } else {
                 break;
             }
-
-            yield_now().await;
         }
     }