Apply suggestions from code review

Co-authored-by: Jacob Gonzalez <jacobgonzalez5252@gmail.com>
This commit is contained in:
Mathias Koch 2022-09-15 05:38:55 +02:00 committed by Dario Nieuwenhuis
parent 53c34ccc39
commit b0d91e9f31

View File

@ -144,7 +144,7 @@ impl<'d, T: Instance> I2c<'d, T, Async> {
let len = buffer.len(); let len = buffer.len();
self.read_blocking_internal(&mut buffer[..1], true, len == 1)?; self.read_blocking_internal(&mut buffer[..1], true, len == 1)?;
if len > 2 { if len >= 2 {
// Note(safety): Unwrap should be safe, as this can only be called // Note(safety): Unwrap should be safe, as this can only be called
// when `Mode == Async`, where we have dma channels. // when `Mode == Async`, where we have dma channels.
let ch = self.rx_dma.as_mut().unwrap(); let ch = self.rx_dma.as_mut().unwrap();
@ -168,7 +168,7 @@ impl<'d, T: Instance> I2c<'d, T, Async> {
transfer.await; transfer.await;
} }
if len > 2 { if len >= 2 {
self.read_blocking_internal(&mut buffer[len - 1..], false, true)?; self.read_blocking_internal(&mut buffer[len - 1..], false, true)?;
} }
@ -202,7 +202,7 @@ impl<'d, T: Instance> I2c<'d, T, Async> {
if bytes.is_empty() { if bytes.is_empty() {
self.write_blocking_internal(bytes, false)?; self.write_blocking_internal(bytes, false)?;
} else { } else {
self.write_internal(bytes, false).await?; self.write_internal(bytes, true).await?;
} }
if buffer.is_empty() { if buffer.is_empty() {