From ca4ff1e6fe97dc00e316d6833ac4ee5c01da43e2 Mon Sep 17 00:00:00 2001 From: Michele Sardo Date: Fri, 1 Mar 2024 16:32:20 +0100 Subject: [PATCH] drivers: spi: keep SPI enabled if SPI_HOLD_ON_CS is used Keep the SPI enabled when performing multiple transaction with SPI_HOLD_ON_CS. In such case, the end of transaction is marked by application calling spi_release. Signed-off-by: Michele Sardo --- drivers/spi/spi_ll_stm32.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi_ll_stm32.c b/drivers/spi/spi_ll_stm32.c index 7f444f664ba9d3..e24b9722d06bb3 100644 --- a/drivers/spi/spi_ll_stm32.c +++ b/drivers/spi/spi_ll_stm32.c @@ -448,9 +448,9 @@ static void spi_stm32_complete(const struct device *dev, int status) { const struct spi_stm32_config *cfg = dev->config; SPI_TypeDef *spi = cfg->spi; -#ifdef CONFIG_SPI_STM32_INTERRUPT struct spi_stm32_data *data = dev->data; +#ifdef CONFIG_SPI_STM32_INTERRUPT ll_func_disable_int_tx_empty(spi); ll_func_disable_int_rx_not_empty(spi); ll_func_disable_int_errors(spi); @@ -493,7 +493,9 @@ static void spi_stm32_complete(const struct device *dev, int status) } #endif /* DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_spi) */ - ll_func_disable_spi(spi); + if (!(data->ctx.config->operation & SPI_HOLD_ON_CS)) { + ll_func_disable_spi(spi); + } #ifdef CONFIG_SPI_STM32_INTERRUPT spi_context_complete(&data->ctx, dev, status); @@ -687,8 +689,10 @@ static int spi_stm32_release(const struct device *dev, const struct spi_config *config) { struct spi_stm32_data *data = dev->data; + const struct spi_stm32_config *cfg = dev->config; spi_context_unlock_unconditionally(&data->ctx); + ll_func_disable_spi(cfg->spi); return 0; }