clippy fixes
This commit is contained in:
parent
db80221815
commit
f396c793ea
31
src/lib.rs
31
src/lib.rs
@ -213,9 +213,9 @@ where
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn send_wrapper(&mut self, byte: u8) -> Result<(), Error<SpiE, PinE>> {
|
fn send_wrapper(&mut self, byte: u8) -> Result<(), Error<SpiE, PinE>> {
|
||||||
self.cs.set_low().map_err(|e| Error::Pin(e))?;
|
self.cs.set_low().map_err(Error::Pin)?;
|
||||||
nb::block!(self.spi.send(byte)).map_err(|e| Error::Spi(e))?;
|
nb::block!(self.spi.send(byte)).map_err(Error::Spi)?;
|
||||||
self.cs.set_high().map_err(|e| Error::Pin(e))?;
|
self.cs.set_high().map_err(Error::Pin)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,8 +276,7 @@ where
|
|||||||
if self.pending_op != PendingOp::None {
|
if self.pending_op != PendingOp::None {
|
||||||
return Err(Error::Adc(AdcError::PendingOperation));
|
return Err(Error::Adc(AdcError::PendingOperation));
|
||||||
}
|
}
|
||||||
let conv_byte =
|
let conv_byte = Self::get_conversion_byte(scan_mode, channel_num).map_err(Error::Adc)?;
|
||||||
Self::get_conversion_byte(scan_mode, channel_num).map_err(|e| Error::Adc(e))?;
|
|
||||||
self.send_wrapper(conv_byte)?;
|
self.send_wrapper(conv_byte)?;
|
||||||
self.pending_op = op_type;
|
self.pending_op = op_type;
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -317,9 +316,9 @@ where
|
|||||||
};
|
};
|
||||||
if is_low {
|
if is_low {
|
||||||
let mut dummy_cmd: [u8; 2] = [0; 2];
|
let mut dummy_cmd: [u8; 2] = [0; 2];
|
||||||
self.cs.set_low().map_err(|e| Error::Pin(e))?;
|
self.cs.set_low().map_err(Error::Pin)?;
|
||||||
let transfer_result = self.spi.transfer(&mut dummy_cmd);
|
let transfer_result = self.spi.transfer(&mut dummy_cmd);
|
||||||
self.cs.set_high().map_err(|e| Error::Pin(e))?;
|
self.cs.set_high().map_err(Error::Pin)?;
|
||||||
match transfer_result {
|
match transfer_result {
|
||||||
Ok(reply) => {
|
Ok(reply) => {
|
||||||
self.pending_op = PendingOp::None;
|
self.pending_op = PendingOp::None;
|
||||||
@ -356,9 +355,9 @@ where
|
|||||||
};
|
};
|
||||||
buf[1] = 0x00;
|
buf[1] = 0x00;
|
||||||
buf[2] = 0x00;
|
buf[2] = 0x00;
|
||||||
self.cs.set_low().map_err(|e| Error::Pin(e))?;
|
self.cs.set_low().map_err(Error::Pin)?;
|
||||||
let reply = self.spi.transfer(&mut buf[0..3]).ok().unwrap();
|
let reply = self.spi.transfer(&mut buf[0..3]).ok().unwrap();
|
||||||
self.cs.set_high().map_err(|e| Error::Pin(e))?;
|
self.cs.set_high().map_err(Error::Pin)?;
|
||||||
Ok(((reply[1] as u16) << 6) | (reply[2] as u16 >> 2))
|
Ok(((reply[1] as u16) << 6) | (reply[2] as u16 >> 2))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,12 +377,12 @@ where
|
|||||||
}
|
}
|
||||||
next_byte = iter.next().ok_or(Error::Adc(AdcError::CmdBufTooSmall))?;
|
next_byte = iter.next().ok_or(Error::Adc(AdcError::CmdBufTooSmall))?;
|
||||||
*next_byte = 0x00;
|
*next_byte = 0x00;
|
||||||
self.cs.set_low().map_err(|e| Error::Pin(e))?;
|
self.cs.set_low().map_err(Error::Pin)?;
|
||||||
let reply = self
|
let reply = self
|
||||||
.spi
|
.spi
|
||||||
.transfer(&mut buf[0..((n + 1) * 2 + 1) as usize])
|
.transfer(&mut buf[0..((n + 1) * 2 + 1) as usize])
|
||||||
.map_err(|e| Error::Spi(e))?;
|
.map_err(Error::Spi)?;
|
||||||
self.cs.set_high().map_err(|e| Error::Pin(e))?;
|
self.cs.set_high().map_err(Error::Pin)?;
|
||||||
let mut reply_iter = reply.iter();
|
let mut reply_iter = reply.iter();
|
||||||
// Skip first reply byte
|
// Skip first reply byte
|
||||||
reply_iter.next().unwrap();
|
reply_iter.next().unwrap();
|
||||||
@ -417,12 +416,12 @@ where
|
|||||||
}
|
}
|
||||||
next_byte = iter.next().ok_or(Error::Adc(AdcError::CmdBufTooSmall))?;
|
next_byte = iter.next().ok_or(Error::Adc(AdcError::CmdBufTooSmall))?;
|
||||||
*next_byte = 0x00;
|
*next_byte = 0x00;
|
||||||
self.cs.set_low().map_err(|e| Error::Pin(e))?;
|
self.cs.set_low().map_err(Error::Pin)?;
|
||||||
let reply = self
|
let reply = self
|
||||||
.spi
|
.spi
|
||||||
.transfer(&mut buf[0..(conversions * 2 + 1) as usize])
|
.transfer(&mut buf[0..(conversions * 2 + 1) as usize])
|
||||||
.map_err(|e| Error::Spi(e))?;
|
.map_err(Error::Spi)?;
|
||||||
self.cs.set_high().map_err(|e| Error::Pin(e))?;
|
self.cs.set_high().map_err(Error::Pin)?;
|
||||||
let mut reply_iter = reply.iter();
|
let mut reply_iter = reply.iter();
|
||||||
// Skip first reply byte
|
// Skip first reply byte
|
||||||
reply_iter.next().unwrap();
|
reply_iter.next().unwrap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user