drivers: spi_nrfx_spi: 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_nrfx_spi.c b/drivers/spi/spi_nrfx_spi.c
index b07d69e..2fc769c 100644
--- a/drivers/spi/spi_nrfx_spi.c
+++ b/drivers/spi/spi_nrfx_spi.c
@@ -146,7 +146,6 @@
dev_data->initialized = true;
ctx->config = spi_cfg;
- spi_context_cs_configure(ctx);
return 0;
}
@@ -327,14 +326,20 @@
": cannot enable both pull-up and pull-down on MISO line"); \
static int spi_##idx##_init(const struct device *dev) \
{ \
+ int err; \
IRQ_CONNECT(DT_IRQN(SPI(idx)), DT_IRQ(SPI(idx), priority), \
nrfx_isr, nrfx_spi_##idx##_irq_handler, 0); \
+ err = spi_context_cs_configure_all(&get_dev_data(dev)->ctx); \
+ if (err < 0) { \
+ return err; \
+ } \
spi_context_unlock_unconditionally(&get_dev_data(dev)->ctx); \
return 0; \
} \
static struct spi_nrfx_data spi_##idx##_data = { \
SPI_CONTEXT_INIT_LOCK(spi_##idx##_data, ctx), \
SPI_CONTEXT_INIT_SYNC(spi_##idx##_data, ctx), \
+ SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(idx), ctx) \
.dev = DEVICE_DT_GET(SPI(idx)), \
.busy = false, \
}; \