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>
This commit is contained in:
parent
54907c7014
commit
388a33c188
1 changed files with 7 additions and 2 deletions
|
@ -569,8 +569,6 @@ static int spi_stm32_configure(const struct device *dev,
|
|||
/* 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 @@ static int spi_stm32_init(const struct device *dev)
|
|||
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 @@ static struct spi_stm32_data spi_stm32_dev_data_##id = { \
|
|||
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, \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue