From 35da5ccac9eb6df4ae2c0bfc674247a5d2f40c8c Mon Sep 17 00:00:00 2001 From: Dominic Fischer Date: Fri, 2 Aug 2024 22:38:14 +0100 Subject: [PATCH] Add delay between starting DMA TX and SPI driver --- esp-hal/src/spi/master.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/esp-hal/src/spi/master.rs b/esp-hal/src/spi/master.rs index 2f3c400070f..b62739c7ba3 100644 --- a/esp-hal/src/spi/master.rs +++ b/esp-hal/src/spi/master.rs @@ -2074,6 +2074,13 @@ pub trait InstanceDma: Instance { tx.start_transfer()?; reset_dma_before_usr_cmd(reg_block); + // Wait for at least one clock cycle for the DMA to fill the SPI async FIFO, before + // starting the SPI + #[cfg(riscv)] + riscv::asm::delay(1); + #[cfg(xtensa)] + xtensa_lx::timer::delay(1); + reg_block.cmd().modify(|_, w| w.usr().set_bit()); Ok(())