Removed nb from areas where it's not necessary
This commit is contained in:
parent
3dbb2d4e64
commit
074e01e3a0
9 changed files with 47 additions and 48 deletions
|
|
@ -40,7 +40,7 @@ impl<Spi: FullDuplex<u8>, ChipSelect: OutputPin> ActiveBus for ActiveFourWire<Sp
|
|||
address: u16,
|
||||
is_write: bool,
|
||||
data: &'a mut [u8],
|
||||
) -> Result<&'a mut [u8], nb::Error<Self::Error>> {
|
||||
) -> Result<&'a mut [u8], Self::Error> {
|
||||
let mut control_phase = block << 3;
|
||||
if is_write {
|
||||
control_phase |= WRITE_MODE_MASK;
|
||||
|
|
@ -52,9 +52,9 @@ impl<Spi: FullDuplex<u8>, ChipSelect: OutputPin> ActiveBus for ActiveFourWire<Sp
|
|||
self.cs
|
||||
.set_low()
|
||||
.map_err(|e| FourWireError::ChipSelectError(e))?;
|
||||
block!(Self::transfer_bytes(&mut self.spi, &mut address_phase)
|
||||
Self::transfer_bytes(&mut self.spi, &mut address_phase)
|
||||
.and_then(|_| Self::transfer_byte(&mut self.spi, &mut control_phase))
|
||||
.and_then(|_| Self::transfer_bytes(&mut self.spi, data_phase)))
|
||||
.and_then(|_| Self::transfer_bytes(&mut self.spi, data_phase))
|
||||
.map_err(|e| FourWireError::SpiError(e))?;
|
||||
self.cs
|
||||
.set_high()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use embedded_hal::spi::FullDuplex;
|
||||
use nb::Result;
|
||||
|
||||
mod four_wire;
|
||||
mod three_wire;
|
||||
|
|
@ -36,7 +35,7 @@ pub trait ActiveBus {
|
|||
spi: &mut Spi,
|
||||
byte: &'a mut u8,
|
||||
) -> Result<&'a mut u8, Spi::Error> {
|
||||
*byte = spi.send(*byte).and_then(|_| spi.read())?;
|
||||
*byte = block!(spi.send(*byte)).and_then(|_| block!(spi.read()))?;
|
||||
Ok(byte)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ impl<Spi: FullDuplex<u8>> ActiveBus for ActiveThreeWire<Spi> {
|
|||
mut address: u16,
|
||||
is_write: bool,
|
||||
data: &'a mut [u8],
|
||||
) -> Result<&'a mut [u8], nb::Error<Self::Error>> {
|
||||
) -> Result<&'a mut [u8], Self::Error> {
|
||||
let mut control_phase = block << 3;
|
||||
if is_write {
|
||||
control_phase |= WRITE_MODE_MASK;
|
||||
|
|
@ -71,12 +71,12 @@ impl<Spi: FullDuplex<u8>> ActiveBus for ActiveThreeWire<Spi> {
|
|||
|
||||
let mut address_phase = [0u8; 2];
|
||||
BigEndian::write_u16(&mut address_phase, address);
|
||||
block!(Self::transfer_bytes(&mut self.spi, &mut address_phase)
|
||||
Self::transfer_bytes(&mut self.spi, &mut address_phase)
|
||||
.and_then(|_| Self::transfer_byte(&mut self.spi, &mut control_phase))
|
||||
.and_then(|_| Self::transfer_bytes(
|
||||
&mut self.spi,
|
||||
&mut data_phase[..last_length_written as usize]
|
||||
)))?;
|
||||
))?;
|
||||
|
||||
address += last_length_written;
|
||||
data_phase = &mut data_phase[last_length_written as usize..];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue