diff options
| author | kbleeke <[email protected]> | 2023-03-27 14:37:39 +0200 |
|---|---|---|
| committer | kbleeke <[email protected]> | 2023-03-27 15:29:01 +0200 |
| commit | 8926397f4592f22a5ed54f772a979578ca36628f (patch) | |
| tree | 44ea2747d84c57dc021e141f9ffe03bf4b911738 /src | |
| parent | b58cc2aa239e4adba2c32462cc89133bb7d9f698 (diff) | |
address irq nits
Diffstat (limited to 'src')
| -rw-r--r-- | src/bus.rs | 12 | ||||
| -rw-r--r-- | src/runner.rs | 4 |
2 files changed, 6 insertions, 10 deletions
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 @@ | |||
| 1 | use core::slice; | 1 | use core::slice; |
| 2 | 2 | ||
| 3 | use embassy_futures::yield_now; | ||
| 3 | use embassy_time::{Duration, Timer}; | 4 | use embassy_time::{Duration, Timer}; |
| 4 | use embedded_hal_1::digital::OutputPin; | 5 | use embedded_hal_1::digital::OutputPin; |
| 5 | use futures::FutureExt; | 6 | use 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 | ||
| 27 | pub(crate) struct Bus<PWR, SPI> { | 31 | pub(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 | ||
| 314 | fn swap16(x: u32) -> u32 { | 314 | 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 @@ | |||
| 1 | use core::slice; | 1 | use core::slice; |
| 2 | 2 | ||
| 3 | use embassy_futures::select::{select3, Either3}; | 3 | use embassy_futures::select::{select3, Either3}; |
| 4 | use embassy_futures::yield_now; | ||
| 5 | use embassy_net_driver_channel as ch; | 4 | use embassy_net_driver_channel as ch; |
| 6 | use embassy_sync::pubsub::PubSubBehavior; | 5 | use embassy_sync::pubsub::PubSubBehavior; |
| 7 | use embassy_time::{block_for, Duration, Timer}; | 6 | use 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 | ||
