From d857dd1b36cb3f0c0eb3f87baa76a132ea44ff74 Mon Sep 17 00:00:00 2001 From: Xiao Xufeng Date: Tue, 24 Oct 2023 02:52:51 +0800 Subject: [PATCH] fix(spi): fixed undesired touching to DMA Closes https://github.com/espressif/esp-idf/issues/12241 --- components/hal/spi_hal.c | 4 +++- components/hal/spi_slave_hal.c | 4 +++- components/hal/spi_slave_hd_hal.c | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/components/hal/spi_hal.c b/components/hal/spi_hal.c index be12d2065c4..6ec95d40fda 100644 --- a/components/hal/spi_hal.c +++ b/components/hal/spi_hal.c @@ -61,7 +61,9 @@ void spi_hal_init(spi_hal_context_t *hal, uint32_t host_id, const spi_hal_config hal->dmadesc_n = config->dmadesc_n; spi_ll_master_init(hw); - s_spi_hal_dma_init_config(hal); + if (config->dma_enabled) { + s_spi_hal_dma_init_config(hal); + } //Force a transaction done interrupt. This interrupt won't fire yet because //we initialized the SPI interrupt as disabled. This way, we can just diff --git a/components/hal/spi_slave_hal.c b/components/hal/spi_slave_hal.c index 04982f1a7e3..8ac605affd0 100644 --- a/components/hal/spi_slave_hal.c +++ b/components/hal/spi_slave_hal.c @@ -31,7 +31,9 @@ void spi_slave_hal_init(spi_slave_hal_context_t *hal, const spi_slave_hal_config hal->dma_in = hal_config->dma_in; hal->dma_out = hal_config->dma_out; - s_spi_slave_hal_dma_init_config(hal); + if (hal->use_dma) { + s_spi_slave_hal_dma_init_config(hal); + } spi_ll_slave_init(hal->hw); //Force a transaction done interrupt. This interrupt won't fire yet because we initialized the SPI interrupt as diff --git a/components/hal/spi_slave_hd_hal.c b/components/hal/spi_slave_hd_hal.c index 4662f676ddb..7378d4aa6cd 100644 --- a/components/hal/spi_slave_hd_hal.c +++ b/components/hal/spi_slave_hd_hal.c @@ -78,7 +78,9 @@ void spi_slave_hd_hal_init(spi_slave_hd_hal_context_t *hal, const spi_slave_hd_h hal->rx_dma_head = &hal->rx_dummy_head; //Configure slave - s_spi_slave_hd_hal_dma_init_config(hal); + if (hal_config->dma_enabled) { + s_spi_slave_hd_hal_dma_init_config(hal); + } spi_ll_slave_hd_init(hw); spi_ll_set_addr_bitlen(hw, hal_config->address_bits);