Page 1 of 1

Use of GPIO34 - 39 for I2C?

Posted: Wed Apr 12, 2017 3:46 pm
by steeldecor
Hi

I know that GPIO 34 to 39 are meany for input only, however I was wondering if it's possible to map an SPi or I2C periperal to them? My projects has few inputs and many outputs so ideally so as not to run out it would be nice to use the SENSOR_VP / SENSOR_VN as SDA / SCL

Regards
John

Re: Use of GPIO34 - 39 for I2C?

Posted: Thu Apr 13, 2017 6:24 am
by ESP_Sprite
These pins are always inputs, independent if they're driven from a peripheral or as GPIOs. So for example mapping I2C to them isn't going to work, because both scl as well as sda are inputs as well as outputs. Mapping e.g. the MISO pin of SPI to them would work, because (unless you use quad-IO SPI mode) that always is an input.

Re: Use of GPIO34 - 39 for I2C?

Posted: Fri Apr 14, 2017 10:11 am
by steeldecor
Thank for the info. Guess I will have to live with that :)

Re: Use of GPIO34 - 39 for I2C?

Posted: Tue Sep 19, 2017 6:44 am
by hfc108
IO34-IO39 without SPI funtion in IO_MUX table. Is true for IO34-IO39 can map to SPI MISO funtion? :?:

Re: Use of GPIO34 - 39 for I2C?

Posted: Tue Sep 19, 2017 6:51 am
by WiFive
Yes via gpio matrix not io_mux

Re: Use of GPIO34 - 39 for I2C?

Posted: Sun Feb 11, 2018 4:48 pm
by JB2050
ESP_Sprite wrote:Mapping e.g. the MISO pin of SPI to them would work because (unless you use quad-IO SPI mode) that always is an input.
With the current ESP-IDF V3.0, I'm finding that this doesn't work. I'm trying to use GPI34 as a SPI MISO input.

If I understand correctly what is going on, the reason it doesn't work is because in file esp-idf/components/driver/spi_common.c, an attempt is made to configure the port specified for use as SPI MISO as Input+Output rather than just Input. See the gpio_set_direction() call here:

Code: Select all

        if (bus_config->miso_io_num >= 0) {
            PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[bus_config->miso_io_num], PIN_FUNC_GPIO);
            gpio_set_direction(bus_config->miso_io_num, GPIO_MODE_INPUT_OUTPUT);
            gpio_matrix_out(bus_config->miso_io_num, io_signal[host].spiq_out, false, false);
            gpio_matrix_in(bus_config->miso_io_num, io_signal[host].spiq_in, false);
        }
I think this line should be:

Code: Select all

gpio_set_direction(bus_config->miso_io_num, GPIO_MODE_INPUT);
Is this correct?

If so, where can I report the bug? At http://bbs.esp32.com/viewforum.php?f=14 ... de9c05b564?

Cheers,
JB.

Re: Use of GPIO34 - 39 for I2C?

Posted: Mon Feb 12, 2018 11:54 am
by JB2050
I confirm that with this change:
  • The spi_bus_initialize() call completes without error.
  • The SPI port works correctly, including inputing data from input-only (GPI) ports.
JB.