drivers: spi_esp32_spim: 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
70a65b229b
commit
f40be1f17f
|
@ -131,6 +131,7 @@ static void IRAM_ATTR spi_esp32_isr(void *arg)
|
|||
|
||||
static int spi_esp32_init(const struct device *dev)
|
||||
{
|
||||
int err;
|
||||
const struct spi_esp32_config *cfg = dev->config;
|
||||
struct spi_esp32_data *data = dev->data;
|
||||
|
||||
|
@ -146,6 +147,11 @@ static int spi_esp32_init(const struct device *dev)
|
|||
NULL);
|
||||
#endif
|
||||
|
||||
err = spi_context_cs_configure_all(&data->ctx);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
spi_context_unlock_unconditionally(&data->ctx);
|
||||
|
||||
return 0;
|
||||
|
@ -261,8 +267,6 @@ static int IRAM_ATTR spi_esp32_configure(const struct device *dev,
|
|||
GPIO_OUTPUT | GPIO_ACTIVE_LOW);
|
||||
}
|
||||
|
||||
spi_context_cs_configure(&data->ctx);
|
||||
|
||||
/* input parameters to calculate timing configuration */
|
||||
spi_hal_timing_param_t timing_param = {
|
||||
.half_duplex = hal_dev->half_duplex,
|
||||
|
@ -411,6 +415,7 @@ static const struct spi_driver_api spi_api = {
|
|||
static struct spi_esp32_data spi_data_##idx = { \
|
||||
SPI_CONTEXT_INIT_LOCK(spi_data_##idx, ctx), \
|
||||
SPI_CONTEXT_INIT_SYNC(spi_data_##idx, ctx), \
|
||||
SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(idx), ctx) \
|
||||
.hal = { \
|
||||
.hw = (spi_dev_t *)DT_REG_ADDR(DT_NODELABEL(spi##idx)), \
|
||||
}, \
|
||||
|
|
Loading…
Reference in a new issue