drivers: spi_ll_stm32: initialize all cs gpios during init
In case when we have multiple devices connected to the
one SPI interface the initial state of CS gpios after
MCU reset is floating and it might be low that prevents us from
communicating between particular devices. Fix that by
initializing all provided cs gpios and setting them as inactive.
Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
diff --git a/drivers/spi/spi_ll_stm32.c b/drivers/spi/spi_ll_stm32.c
index 135eef2..e54096c 100644
--- a/drivers/spi/spi_ll_stm32.c
+++ b/drivers/spi/spi_ll_stm32.c
@@ -569,8 +569,6 @@
/* At this point, it's mandatory to set this on the context! */
data->ctx.config = config;
- spi_context_cs_configure(&data->ctx);
-
LOG_DBG("Installed config %p: freq %uHz (div = %u),"
" mode %u/%u/%u, slave %u",
config, clock >> br, 1 << br,
@@ -863,6 +861,12 @@
return -ENODEV;
}
#endif /* CONFIG_SPI_STM32_DMA */
+
+ err = spi_context_cs_configure_all(&data->ctx);
+ if (err < 0) {
+ return err;
+ }
+
spi_context_unlock_unconditionally(&data->ctx);
return 0;
@@ -960,6 +964,7 @@
SPI_DMA_CHANNEL(id, rx, RX, PERIPHERAL, MEMORY) \
SPI_DMA_CHANNEL(id, tx, TX, MEMORY, PERIPHERAL) \
SPI_DMA_STATUS_SEM(id) \
+ SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(id), ctx) \
}; \
\
DEVICE_DT_INST_DEFINE(id, &spi_stm32_init, NULL, \