Use of GPIO34 - 39 for I2C?

steeldecor
Posts: 3
Joined: Wed Apr 12, 2017 3:42 pm

Use of GPIO34 - 39 for I2C?

Postby steeldecor » Wed Apr 12, 2017 3:46 pm

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

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Use of GPIO34 - 39 for I2C?

Postby ESP_Sprite » Thu Apr 13, 2017 6:24 am

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.

steeldecor
Posts: 3
Joined: Wed Apr 12, 2017 3:42 pm

Re: Use of GPIO34 - 39 for I2C?

Postby steeldecor » Fri Apr 14, 2017 10:11 am

Thank for the info. Guess I will have to live with that :)

hfc108
Posts: 13
Joined: Sat Sep 03, 2016 3:23 pm

Re: Use of GPIO34 - 39 for I2C?

Postby hfc108 » Tue Sep 19, 2017 6:44 am

IO34-IO39 without SPI funtion in IO_MUX table. Is true for IO34-IO39 can map to SPI MISO funtion? :?:

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Use of GPIO34 - 39 for I2C?

Postby WiFive » Tue Sep 19, 2017 6:51 am

Yes via gpio matrix not io_mux

JB2050
Posts: 9
Joined: Sun Feb 11, 2018 4:23 pm

Re: Use of GPIO34 - 39 for I2C?

Postby JB2050 » Sun Feb 11, 2018 4:48 pm

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.

JB2050
Posts: 9
Joined: Sun Feb 11, 2018 4:23 pm

Re: Use of GPIO34 - 39 for I2C?

Postby JB2050 » Mon Feb 12, 2018 11:54 am

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.

Who is online

Users browsing this forum: thetitaniumtitan and 199 guests