Skip to content

Commit

Permalink
Only flush if we need to read
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Sep 14, 2024
1 parent 871e630 commit 17fbe10
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions esp-hal/src/spi/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2163,6 +2163,8 @@ mod ehal1 {
break;
}

// No need to flush here, `SpiBus::write` will do it for us

if write_to < read_to {
// Read more than we write, must pad writing part with zeros
let mut empty = [EMPTY_WRITE_PAD; FIFO_SIZE];
Expand All @@ -2172,9 +2174,8 @@ mod ehal1 {
SpiBus::write(self, &write[write_from..write_to])?;
}

SpiBus::flush(self)?;

if read_inc > 0 {
SpiBus::flush(self)?;
self.spi
.read_bytes_from_fifo(&mut read[read_from..read_to])?;
}
Expand Down

0 comments on commit 17fbe10

Please sign in to comment.