aboutsummaryrefslogtreecommitdiff
path: root/src/bus.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bus.rs')
-rw-r--r--src/bus.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/bus.rs b/src/bus.rs
index 7700a832a..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;
@@ -19,6 +20,12 @@ pub trait SpiBusCyw43 {
19 /// Backplane reads have a response delay that produces one extra unspecified word at the beginning of `read`. 20 /// Backplane reads have a response delay that produces one extra unspecified word at the beginning of `read`.
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]);
23
24 /// Wait for events from the Device. A typical implementation would wait for the IRQ pin to be high.
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 }
22} 29}
23 30
24pub(crate) struct Bus<PWR, SPI> { 31pub(crate) struct Bus<PWR, SPI> {
@@ -63,7 +70,8 @@ where
63 trace!("{:#010b}", (val & 0xff)); 70 trace!("{:#010b}", (val & 0xff));
64 71
65 // 32-bit word length, little endian (which is the default endianess). 72 // 32-bit word length, little endian (which is the default endianess).
66 self.write32_swapped(REG_BUS_CTRL, WORD_LENGTH_32 | HIGH_SPEED).await; 73 self.write32_swapped(REG_BUS_CTRL, WORD_LENGTH_32 | HIGH_SPEED | INTERRUPT_HIGH | WAKE_UP)
74 .await;
67 75
68 let val = self.read8(FUNC_BUS, REG_BUS_CTRL).await; 76 let val = self.read8(FUNC_BUS, REG_BUS_CTRL).await;
69 trace!("{:#b}", val); 77 trace!("{:#b}", val);
@@ -297,6 +305,10 @@ where
297 305
298 self.spi.cmd_write(&buf).await; 306 self.spi.cmd_write(&buf).await;
299 } 307 }
308
309 pub async fn wait_for_event(&mut self) {
310 self.spi.wait_for_event().await;
311 }
300} 312}
301 313
302fn swap16(x: u32) -> u32 { 314fn swap16(x: u32) -> u32 {