Unable to use pin 20 as SCL for I2C on ESP32.
I submitted the fix to #8393 to expose pin 20 on ESP32. On the Adafruit Feather ESP32 V2, SCL is pin 20. I loaded the latest nightly build onto my board. I am running into the following issues.
When trying to initalise I2C, it is not accepting pin 20 as a viable option for SCL.
>>> from machine import Pin, I2C
>>> i2c = I2C(0, scl=Pin(20), sda=Pin(22))
E (2540280) i2c: /home/micropython/esp-idf-v4.2/components/driver/i2c.c:767 (i2c_set_pin):scl gpio number error
I2C set up works with pin 14 as SCL.
If I try to simply init pin 20 as an output, it also fails.
>>> from machine import Pin
>>> p20 = Pin(20, Pin.OUT)
E (19500) gpio: gpio_set_direction(263): GPIO number error
@jepler suggested that perhaps the issue is resolved in the ESP IDF v4.4, but an attempt to build MicroPython with that version resulted in a failure to fit in flash. So, I have not tested this possibility.
esp32/machine_i2c: Fix default I2C pins for C3 and S3 variants.
This addresses issue #17103.
The new default I2C init does not require setting SCL or SDA but the default pins for C3 (and S3?) conflict with the espressif GPIO usage.
For the C3, pins 18/19 are for USB/JTAG. If used for I2C() they will cause the REPL to hang on initialization of the I2C. For the S3 pin 19 is allocated for USB/JTAG also but the defaults do not seem to affect the REPL.
See PR #16956
Closes #17103
<!-- Thanks for submitting a Pull Request! We appreciate you spending the
time to improve MicroPython. Please provide enough information so that
others can review your Pull Request.
Before submitting, please read:
https://github.com/micropython/micropython/blob/master/CODEOFCONDUCT.md
https://github.com/micropython/micropython/wiki/ContributorGuidelines
Please check any CI failures that appear after your Pull Request is opened.
-->
Summary
<!-- Explain the reason for making this change. What problem does the pull request
solve, or what improvement does it add? Add links if relevant. -->
Testing
<!-- Explain what testing you did, and on which boards/ports. If there are
boards or ports that you couldn't test, please mention this here as well.
If you leave this empty then your Pull Request may be closed. -->
Trade-offs and Alternatives
<!-- If the Pull Request has some negative impact (i.e. increased code size)
then please explain why you think the trade-off improvement is worth it.
If you can think of alternative ways to do this, please explain that here too.
Delete this heading if not relevant (i.e. small fixes) -->