Skip to content

Commit

Permalink
drivers: spi: keep SPI enabled if SPI_HOLD_ON_CS is used
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
msmttchr authored and jhedberg committed Mar 15, 2024
1 parent ceff785 commit ca4ff1e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/spi/spi_ll_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit ca4ff1e

Please sign in to comment.