Skip to content

Commit ca4ff1e

Browse files
msmttchrjhedberg
authored andcommitted
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 <[email protected]>
1 parent ceff785 commit ca4ff1e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/spi/spi_ll_stm32.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,9 @@ static void spi_stm32_complete(const struct device *dev, int status)
448448
{
449449
const struct spi_stm32_config *cfg = dev->config;
450450
SPI_TypeDef *spi = cfg->spi;
451-
#ifdef CONFIG_SPI_STM32_INTERRUPT
452451
struct spi_stm32_data *data = dev->data;
453452

453+
#ifdef CONFIG_SPI_STM32_INTERRUPT
454454
ll_func_disable_int_tx_empty(spi);
455455
ll_func_disable_int_rx_not_empty(spi);
456456
ll_func_disable_int_errors(spi);
@@ -493,7 +493,9 @@ static void spi_stm32_complete(const struct device *dev, int status)
493493
}
494494
#endif /* DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_spi) */
495495

496-
ll_func_disable_spi(spi);
496+
if (!(data->ctx.config->operation & SPI_HOLD_ON_CS)) {
497+
ll_func_disable_spi(spi);
498+
}
497499

498500
#ifdef CONFIG_SPI_STM32_INTERRUPT
499501
spi_context_complete(&data->ctx, dev, status);
@@ -687,8 +689,10 @@ static int spi_stm32_release(const struct device *dev,
687689
const struct spi_config *config)
688690
{
689691
struct spi_stm32_data *data = dev->data;
692+
const struct spi_stm32_config *cfg = dev->config;
690693

691694
spi_context_unlock_unconditionally(&data->ctx);
695+
ll_func_disable_spi(cfg->spi);
692696

693697
return 0;
694698
}

0 commit comments

Comments
 (0)