Skip to content

Commit

Permalink
Explain cancel code
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Sep 26, 2024
1 parent b00e6ed commit be8fdd9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions esp-hal/src/spi/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1643,13 +1643,16 @@ mod dma {
}

fn do_cancel(&mut self) {
// The SPI peripheral is controlling how much data we transfer, so let's
// update its counter.
// 0 doesn't take effect on ESP32 and cuts the currently transmitted byte
// immediately.
// 1 seems to stop after transmitting the current byte which is somewhat less
// impolite.
self.spi_dma.spi_mut().configure_datalen(1, 1);
self.spi_dma.spi_mut().update();

// We need to stop the DMA transfer, too.
if self.spi_dma.is_tx_in_progress() {
self.spi_dma.channel_mut().tx.stop_transfer();
self.spi_dma.set_tx_in_progress(false);
Expand Down

0 comments on commit be8fdd9

Please sign in to comment.