Page 1 of 1

GPIO invert settings

Posted: Thu Sep 27, 2018 10:47 am
by michprev
Hi,
is there any case when GPIO_FUNCm_IN_INV_SEL, GPIO_FUNCn_OEN_INV_SEL and GPIO_FUNCn_OUT_INV_SEL can be useful?
See TRM V3.8 pages 68 and 69.

Re: GPIO invert settings

Posted: Fri Sep 28, 2018 2:21 am
by ESP_igrr
Input inverting is used, for example, in SDMMC driver for CD or WP pin, and in camera applications to match polarity of HSYNC/VSYNC signals to the ones expected by ESP32. I've seen one case where output inverting was used to flip the signal produced by LEDC, achieving some sort of phase modulation. Haven't seen uses of OE inverting yet.

Re: GPIO invert settings

Posted: Fri Sep 28, 2018 3:38 am
by ESP_Sprite
Output inversion is also used in some parallel I2S output things, if you want to change the polarity of e.g. the WS signal. I think I used OE inverting at some point as a shorthand to make a pin high-impedance with just one write, but I agree that I also struggle to come up with a specific use case for that.

Re: GPIO invert settings

Posted: Sat Oct 06, 2018 10:24 pm
by saden123
mmmm, it pays to browse: I must look into this. I am toggling gpio for steppers within an ISR, and motor controllers vary in signal polarity for en, step and direction. So I am using this all over the code:

Code: Select all

#define GPIO_ON(gpioreg, inverse) \
    if (inverse)                  \
        GPIO.out_w1tc = gpioreg;  \
    else                          \
        GPIO.out_w1ts = gpioreg;
[edit]
Yep, this works (for anyone interested):

Code: Select all

WRITE_PERI_REG(GPIO_FUNCnn_OUT_SEL_CFG_REG, READ_PERI_REG(GPIO_FUNCnn_OUT_SEL_CFG_REG) | GPIO_FUNCnn_OUT_INV_SEL);
// nn=gpio number