aboutsummaryrefslogtreecommitdiff
path: root/src/bus.rs
diff options
context:
space:
mode:
authorkbleeke <[email protected]>2023-03-02 19:02:32 +0100
committerkbleeke <[email protected]>2023-03-27 13:18:59 +0200
commitb58cc2aa239e4adba2c32462cc89133bb7d9f698 (patch)
tree236352d7335f0f81cea03a6e9c4646d643acceae /src/bus.rs
parenta2272dda08a2d1625eef0b79fcd80afc8a1e174a (diff)
use irqs to wait for events
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..6ec5d0bd6 100644
--- a/src/bus.rs
+++ b/src/bus.rs
@@ -19,6 +19,9 @@ pub trait SpiBusCyw43 {
19 /// Backplane reads have a response delay that produces one extra unspecified word at the beginning of `read`. 19 /// 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. 20 /// 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]); 21 async fn cmd_read(&mut self, write: u32, read: &mut [u32]);
22
23 async fn wait_for_event(&mut self);
24 fn clear_event(&mut self);
22} 25}
23 26
24pub(crate) struct Bus<PWR, SPI> { 27pub(crate) struct Bus<PWR, SPI> {
@@ -63,7 +66,8 @@ where
63 trace!("{:#010b}", (val & 0xff)); 66 trace!("{:#010b}", (val & 0xff));
64 67
65 // 32-bit word length, little endian (which is the default endianess). 68 // 32-bit word length, little endian (which is the default endianess).
66 self.write32_swapped(REG_BUS_CTRL, WORD_LENGTH_32 | HIGH_SPEED).await; 69 self.write32_swapped(REG_BUS_CTRL, WORD_LENGTH_32 | HIGH_SPEED | INTERRUPT_HIGH | WAKE_UP)
70 .await;
67 71
68 let val = self.read8(FUNC_BUS, REG_BUS_CTRL).await; 72 let val = self.read8(FUNC_BUS, REG_BUS_CTRL).await;
69 trace!("{:#b}", val); 73 trace!("{:#b}", val);
@@ -297,6 +301,14 @@ where
297 301
298 self.spi.cmd_write(&buf).await; 302 self.spi.cmd_write(&buf).await;
299 } 303 }
304
305 pub async fn wait_for_event(&mut self) {
306 self.spi.wait_for_event().await;
307 }
308
309 pub fn clear_event(&mut self) {
310 self.spi.clear_event();
311 }
300} 312}
301 313
302fn swap16(x: u32) -> u32 { 314fn swap16(x: u32) -> u32 {