drivers: spi_mcux_lpspi: 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
ab2d23c5f4
commit
054fb71bf0
1 changed files with 7 additions and 1 deletions
|
@ -192,7 +192,6 @@ static int spi_mcux_configure(const struct device *dev,
|
|||
LPSPI_SetDummyData(base, 0);
|
||||
|
||||
data->ctx.config = spi_cfg;
|
||||
spi_context_cs_configure(&data->ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -258,11 +257,17 @@ static int spi_mcux_release(const struct device *dev,
|
|||
|
||||
static int spi_mcux_init(const struct device *dev)
|
||||
{
|
||||
int err;
|
||||
const struct spi_mcux_config *config = dev->config;
|
||||
struct spi_mcux_data *data = dev->data;
|
||||
|
||||
config->irq_config_func(dev);
|
||||
|
||||
err = spi_context_cs_configure_all(&data->ctx);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
spi_context_unlock_unconditionally(&data->ctx);
|
||||
|
||||
data->dev = dev;
|
||||
|
@ -301,6 +306,7 @@ static const struct spi_driver_api spi_mcux_driver_api = {
|
|||
static struct spi_mcux_data spi_mcux_data_##n = { \
|
||||
SPI_CONTEXT_INIT_LOCK(spi_mcux_data_##n, ctx), \
|
||||
SPI_CONTEXT_INIT_SYNC(spi_mcux_data_##n, ctx), \
|
||||
SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(n), ctx) \
|
||||
}; \
|
||||
\
|
||||
DEVICE_DT_INST_DEFINE(n, &spi_mcux_init, NULL, \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue