drivers: spi_b91: 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
388a33c188
commit
b370fb8fad
1 changed files with 7 additions and 5 deletions
|
@ -349,19 +349,20 @@ static int spi_b91_config(const struct device *dev,
|
|||
/* save context config */
|
||||
b91_data->ctx.config = config;
|
||||
|
||||
/* config software CS control if enabled */
|
||||
if (config->cs != NULL) {
|
||||
spi_context_cs_configure(&b91_data->ctx);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* API implementation: init */
|
||||
static int spi_b91_init(const struct device *dev)
|
||||
{
|
||||
int err;
|
||||
struct spi_b91_data *data = SPI_DATA(dev);
|
||||
|
||||
err = spi_context_cs_configure_all(&data->ctx);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
spi_context_unlock_unconditionally(&data->ctx);
|
||||
|
||||
return 0;
|
||||
|
@ -458,6 +459,7 @@ static struct spi_driver_api spi_b91_api = {
|
|||
static struct spi_b91_data spi_b91_data_##inst = { \
|
||||
SPI_CONTEXT_INIT_LOCK(spi_b91_data_##inst, ctx), \
|
||||
SPI_CONTEXT_INIT_SYNC(spi_b91_data_##inst, ctx), \
|
||||
SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(inst), ctx) \
|
||||
}; \
|
||||
\
|
||||
static struct spi_b91_cfg spi_b91_cfg_##inst = { \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue