aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2022-10-25 15:46:13 -0400
committerBrian Cully <bjc@kublai.com>2022-10-25 15:46:45 -0400
commitd7f09b1e22ced7449dbe37b848a54bbc328e92d3 (patch)
tree7393d14827faeff5e2c5e251d3a170d877d1c4ca /src
parentcffe2c0b84345a720ece0dd07a84d1d113ba39c9 (diff)
downloadluchie-d7f09b1e22ced7449dbe37b848a54bbc328e92d3.tar.gz
luchie-d7f09b1e22ced7449dbe37b848a54bbc328e92d3.zip
cirque: fix ? operator
Diffstat (limited to 'src')
-rw-r--r--src/cirque.rs29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/cirque.rs b/src/cirque.rs
index c026ea4..5e48269 100644
--- a/src/cirque.rs
+++ b/src/cirque.rs
@@ -68,8 +68,8 @@ enum RAPAddress {
}
trait SPIWriter<Word>: spi::FullDuplex<Word> {
- fn write(&mut self, buf: &[Word]) -> Result<(), Self::Error>;
- fn transfer(&mut self, buf: &mut [Word]) -> Result<(), Self::Error>;
+ fn write(&mut self, buf: &[Word]) -> nb::Result<(), Self::Error>;
+ fn transfer(&mut self, buf: &mut [Word]) -> nb::Result<(), Self::Error>;
}
impl<T, Word> SPIWriter<Word> for T
@@ -77,21 +77,17 @@ where
T: spi::FullDuplex<Word>,
Word: Copy,
{
- fn write(&mut self, buf: &[Word]) -> Result<(), Self::Error> {
+ fn write(&mut self, buf: &[Word]) -> nb::Result<(), Self::Error> {
for i in buf {
- // TODO: figure out why the ? operator doesn't work here.
- self.send(*i);
+ self.send(*i)?;
}
Ok(())
}
- fn transfer(&mut self, buf: &mut [Word]) -> Result<(), Self::Error> {
+ fn transfer(&mut self, buf: &mut [Word]) -> nb::Result<(), Self::Error> {
for i in buf.iter_mut() {
- // TODO: figure out why the ? operator doesn't work here.
- self.send(*i);
- if let Ok(v) = self.read() {
- *i = v;
- }
+ self.send(*i)?;
+ *i = self.read()?;
}
Ok(())
}
@@ -141,12 +137,7 @@ where
C: OutputPin,
D: InputPin,
{
- pub fn new<S>(
- cs_pin: C,
- dr_pin: D,
- spi: &mut S,
- clocks: Clocks,
- ) -> nb::Result<Self, S::Error>
+ pub fn new<S>(cs_pin: C, dr_pin: D, spi: &mut S, clocks: Clocks) -> nb::Result<Self, S::Error>
where
S: embedded_hal::spi::FullDuplex<u8>,
{
@@ -227,7 +218,7 @@ where
})
}
- fn rd<S>(&mut self, spi: &mut S, cmd: u8, buf: &mut [u8]) -> Result<(), S::Error>
+ fn rd<S>(&mut self, spi: &mut S, cmd: u8, buf: &mut [u8]) -> nb::Result<(), S::Error>
where
S: embedded_hal::spi::FullDuplex<u8>,
{
@@ -241,7 +232,7 @@ where
res
}
- fn wr<S>(&mut self, spi: &mut S, addr: u8, data: u8) -> Result<(), S::Error>
+ fn wr<S>(&mut self, spi: &mut S, addr: u8, data: u8) -> nb::Result<(), S::Error>
where
S: embedded_hal::spi::FullDuplex<u8>,
{