I can set a GPIO pin to be input or output using gpio_output_set(). My question is ... is there a way to determine the current input and output direction of a given pin?
For example, if I want to know whether GPIO0 is an input or an output pin ... is that possible?
Determine direction of GPIO pin
Re: Determine direction of GPIO pin
Postby kolban » Tue Sep 22, 2015 8:55 pm
Howdy Tve,
Thanks for the response. I looked at GPIO_PIN_CONFIG_GET(x) and it appears to be an expression evaluation. Do you know of any docs on how to use these functions? I have a feeling that the methods I have been using (such as gpio_output_set and gpio_input_get) are high level wrappers and the functions in eagle_soc.h are lower level. If I can learn how these work, I'll write them up for the community.
Neil
Thanks for the response. I looked at GPIO_PIN_CONFIG_GET(x) and it appears to be an expression evaluation. Do you know of any docs on how to use these functions? I have a feeling that the methods I have been using (such as gpio_output_set and gpio_input_get) are high level wrappers and the functions in eagle_soc.h are lower level. If I can learn how these work, I'll write them up for the community.
Neil
Re: Determine direction of GPIO pin
Postby dkinzer » Tue Sep 22, 2015 11:13 pm
The "direction" register is at offset 0x0c, given by GPIO_ENABLE_ADDRESS. The value resulting from GPIO_REG_READ(GPIO_ENABLE_ADDRESS) will have 1s in bit positions corresponding to pins that are outputs. This assumes, of course, that the IO MUX is set for the bit to be a GPIO.kolban wrote:[...]is there a way to determine the current input and output direction of a given pin?
Don Kinzer
Beaverton, OR, USA
Beaverton, OR, USA
Who is online
Users browsing this forum: No registered users and 27 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.