Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Should be possible to digitalRead() a pin that's not GPIO #10370

Closed
Assignees
Labels
@egnor

Description

Board

All

Device Description

Any device

Hardware Configuration

Any configuration

Version

latest master (checkout manually)

IDE Name

any IDE

Operating System

any OS

Flash frequency

any frequency

PSRAM enabled

yes

Upload speed

any

Description

in arduino-esp32 3.x, if you attempt to digitalRead() from a pin that's been configured as another peripheral (e.g. I2C or UART), an error message comes back like

[4629150][E][esp32-hal-gpio.c:190] __digitalRead(): IO 16 is not set as GPIO.

and the function always returns 0. in previous versions it was possible to see the state of the pin regardless of what peripheral is driving it (which is perfectly well supported by hardware). there are a number of use cases for this, for monitoring what a peripheral is actually doing, for seeing if something externally is overriding it, etc..

the code in question is here:

if (perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) != NULL) {

(as far as I know, gpio_get_level() will always work even if the pin is driven by another peripheral, so I think the check can just be skipped?) if the change is intentional, it should probably be put in the migration document??

Sketch

void setup() {
 Serial.begin(115200);
 I2C.begin();
}
void loop() {
 delay(500);
 Serial.println(digitalRead(SDA));
}

Debug Message

[5220153][E][esp32-hal-gpio.c:190] __digitalRead(): IO 16 is not set as GPIO.
(actual pin number may vary of course)

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /