drivers: spi_rv32m1_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
97d3de2349
commit
05f326c96e
1 changed files with 7 additions and 1 deletions
|
@ -189,7 +189,6 @@ static int spi_mcux_configure(const struct device *dev,
|
||||||
LPSPI_SetDummyData(base, 0);
|
LPSPI_SetDummyData(base, 0);
|
||||||
|
|
||||||
data->ctx.config = spi_cfg;
|
data->ctx.config = spi_cfg;
|
||||||
spi_context_cs_configure(&data->ctx);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -255,6 +254,7 @@ static int spi_mcux_release(const struct device *dev,
|
||||||
|
|
||||||
static int spi_mcux_init(const struct device *dev)
|
static int spi_mcux_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
|
int err;
|
||||||
const struct spi_mcux_config *config = dev->config;
|
const struct spi_mcux_config *config = dev->config;
|
||||||
struct spi_mcux_data *data = dev->data;
|
struct spi_mcux_data *data = dev->data;
|
||||||
|
|
||||||
|
@ -264,6 +264,11 @@ static int spi_mcux_init(const struct device *dev)
|
||||||
|
|
||||||
data->dev = dev;
|
data->dev = dev;
|
||||||
|
|
||||||
|
err = spi_context_cs_configure_all(&data->ctx);
|
||||||
|
if (err < 0) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
spi_context_unlock_unconditionally(&data->ctx);
|
spi_context_unlock_unconditionally(&data->ctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -293,6 +298,7 @@ static const struct spi_driver_api spi_mcux_driver_api = {
|
||||||
static struct spi_mcux_data spi_mcux_data_##n = { \
|
static struct spi_mcux_data spi_mcux_data_##n = { \
|
||||||
SPI_CONTEXT_INIT_LOCK(spi_mcux_data_##n, ctx), \
|
SPI_CONTEXT_INIT_LOCK(spi_mcux_data_##n, ctx), \
|
||||||
SPI_CONTEXT_INIT_SYNC(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, \
|
DEVICE_DT_INST_DEFINE(n, &spi_mcux_init, NULL, \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue