aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkbleeke <[email protected]>2023-03-27 14:37:39 +0200
committerkbleeke <[email protected]>2023-03-27 15:29:01 +0200
commit8926397f4592f22a5ed54f772a979578ca36628f (patch)
tree44ea2747d84c57dc021e141f9ffe03bf4b911738
parentb58cc2aa239e4adba2c32462cc89133bb7d9f698 (diff)
address irq nits
-rw-r--r--examples/rpi-pico-w/src/main.rs6
-rw-r--r--examples/rpi-pico-w/src/pio.rs3
-rw-r--r--src/bus.rs12
-rw-r--r--src/runner.rs4
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 {
227 self.read(read).await; 227 self.read(read).await;
228 self.cs.set_high(); 228 self.cs.set_high();
229 } 229 }
230
231 async fn wait_for_event(&mut self) {}
232
233 fn clear_event(&mut self) {}
234
235
236} 230}
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
170 170
171 async fn wait_for_event(&mut self) { 171 async fn wait_for_event(&mut self) {
172 self.sm.wait_irq(0).await; 172 self.sm.wait_irq(0).await;
173 }
174
175 fn clear_event(&mut self) {
176 self.sm.clear_irq(0); 173 self.sm.clear_irq(0);
177 } 174 }
178} 175}
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 @@
1use core::slice; 1use core::slice;
2 2
3use embassy_futures::yield_now;
3use embassy_time::{Duration, Timer}; 4use embassy_time::{Duration, Timer};
4use embedded_hal_1::digital::OutputPin; 5use embedded_hal_1::digital::OutputPin;
5use futures::FutureExt; 6use futures::FutureExt;
@@ -20,8 +21,11 @@ pub trait SpiBusCyw43 {
20 /// Callers that want to read `n` word from the backplane, have to provide a slice that is `n+1` words long. 21 /// Callers that want to read `n` word from the backplane, have to provide a slice that is `n+1` words long.
21 async fn cmd_read(&mut self, write: u32, read: &mut [u32]); 22 async fn cmd_read(&mut self, write: u32, read: &mut [u32]);
22 23
23 async fn wait_for_event(&mut self); 24 /// Wait for events from the Device. A typical implementation would wait for the IRQ pin to be high.
24 fn clear_event(&mut self); 25 /// The default implementation always reports ready, resulting in active polling of the device.
26 async fn wait_for_event(&mut self) {
27 yield_now().await;
28 }
25} 29}
26 30
27pub(crate) struct Bus<PWR, SPI> { 31pub(crate) struct Bus<PWR, SPI> {
@@ -305,10 +309,6 @@ where
305 pub async fn wait_for_event(&mut self) { 309 pub async fn wait_for_event(&mut self) {
306 self.spi.wait_for_event().await; 310 self.spi.wait_for_event().await;
307 } 311 }
308
309 pub fn clear_event(&mut self) {
310 self.spi.clear_event();
311 }
312} 312}
313 313
314fn swap16(x: u32) -> u32 { 314fn 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 @@
1use core::slice; 1use core::slice;
2 2
3use embassy_futures::select::{select3, Either3}; 3use embassy_futures::select::{select3, Either3};
4use embassy_futures::yield_now;
5use embassy_net_driver_channel as ch; 4use embassy_net_driver_channel as ch;
6use embassy_sync::pubsub::PubSubBehavior; 5use embassy_sync::pubsub::PubSubBehavior;
7use embassy_time::{block_for, Duration, Timer}; 6use embassy_time::{block_for, Duration, Timer};
@@ -304,7 +303,6 @@ where
304 303
305 /// Wait for IRQ on F2 packet available 304 /// Wait for IRQ on F2 packet available
306 async fn handle_irq(&mut self, buf: &mut [u32; 512]) { 305 async fn handle_irq(&mut self, buf: &mut [u32; 512]) {
307 self.bus.clear_event();
308 // Receive stuff 306 // Receive stuff
309 let irq = self.bus.read16(FUNC_BUS, REG_BUS_INTERRUPT).await; 307 let irq = self.bus.read16(FUNC_BUS, REG_BUS_INTERRUPT).await;
310 trace!("irq{}", FormatInterrupt(irq)); 308 trace!("irq{}", FormatInterrupt(irq));
@@ -331,8 +329,6 @@ where
331 } else { 329 } else {
332 break; 330 break;
333 } 331 }
334
335 yield_now().await;
336 } 332 }
337 } 333 }
338 334