diff --git a/components/driver/spi_common.c b/components/driver/spi_common.c index 759be5cd9..ba6618589 100644 --- a/components/driver/spi_common.c +++ b/components/driver/spi_common.c @@ -329,6 +329,7 @@ void spicommon_cs_initialize(spi_host_device_t host, int cs_io_num, int cs_num, PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[cs_io_num], 1); } else { //Use GPIO matrix + gpio_set_direction(cs_io_num, GPIO_MODE_INPUT_OUTPUT); PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[cs_io_num], PIN_FUNC_GPIO); gpio_matrix_out(cs_io_num, io_signal[host].spics_out[cs_num], false, false); if (cs_num == 0) gpio_matrix_in(cs_io_num, io_signal[host].spics_in, false); diff --git a/components/driver/spi_master.c b/components/driver/spi_master.c index 1fdbefb12..7f63a46f0 100644 --- a/components/driver/spi_master.c +++ b/components/driver/spi_master.c @@ -271,7 +271,6 @@ esp_err_t spi_bus_add_device(spi_host_device_t host, spi_device_interface_config //Set CS pin, CS options if (dev_config->spics_io_num >= 0) { - gpio_set_direction(dev_config->spics_io_num, GPIO_MODE_OUTPUT); spicommon_cs_initialize(host, dev_config->spics_io_num, freecs, spihost[host]->no_gpio_matrix == false); } if (dev_config->flags&SPI_DEVICE_CLK_AS_CS) { diff --git a/components/driver/spi_slave.c b/components/driver/spi_slave.c index 8ed509446..e3e437c05 100644 --- a/components/driver/spi_slave.c +++ b/components/driver/spi_slave.c @@ -96,7 +96,6 @@ esp_err_t spi_slave_initialize(spi_host_device_t host, const spi_bus_config_t *b spihost[host]->id = host; spicommon_bus_initialize_io(host, bus_config, dma_chan, SPICOMMON_BUSFLAG_SLAVE, &native); - gpio_set_direction(slave_config->spics_io_num, GPIO_MODE_INPUT); spicommon_cs_initialize(host, slave_config->spics_io_num, 0, native==false); // The slave DMA suffers from unexpected transactions. Forbid reading if DMA is enabled by disabling the CS line. if (dma_chan != 0) spicommon_freeze_cs(host);