diff --git a/drivers/spi/spi_ll_stm32.c b/drivers/spi/spi_ll_stm32.c index 8e1b55bbb50..b96a501a912 100644 --- a/drivers/spi/spi_ll_stm32.c +++ b/drivers/spi/spi_ll_stm32.c @@ -307,12 +307,6 @@ static int spi_stm32_configure(struct device *dev, LL_SPI_DisableCRC(spi); - if (config->operation & SPI_OP_MODE_SLAVE) { - LL_SPI_SetMode(spi, LL_SPI_MODE_SLAVE); - } else { - LL_SPI_SetMode(spi, LL_SPI_MODE_MASTER); - } - if (config->cs || !IS_ENABLED(CONFIG_SPI_STM32_USE_HW_SS)) { LL_SPI_SetNSSMode(spi, LL_SPI_NSS_SOFT); } else { @@ -323,6 +317,12 @@ static int spi_stm32_configure(struct device *dev, } } + if (config->operation & SPI_OP_MODE_SLAVE) { + LL_SPI_SetMode(spi, LL_SPI_MODE_SLAVE); + } else { + LL_SPI_SetMode(spi, LL_SPI_MODE_MASTER); + } + if (SPI_WORD_SIZE_GET(config->operation) == 8) { LL_SPI_SetDataWidth(spi, LL_SPI_DATAWIDTH_8BIT); } else {