8000 ESP32_GENERIC_C3/mpconfigboard.h: Add defaults for I2C pins. by ricksorensen · Pull Request #17113 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

ESP32_GENERIC_C3/mpconfigboard.h: Add defaults for I2C pins. #17113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

ricksorensen
Copy link
Contributor

Summary

For the ESP32C3 (XIAO C3 for example) the default I2C pins conflicted with the
USB pins resulting in REPL hanging after using the new I2C initializer without
parameters.

Reference:
#17103
#16671

Testing

I tested on an XIAO ESP32C3 board, using the micropython master development branch.

Trade-offs and Alternatives

While the values I defaulted to should allow for safe construction of an I2C object,
they may not be correct for any particular wiring.
I would suggest the documentation be updated for board configurations to include the
necessary default pin parameters.

Another valid approach would be to require the parameters (port id, scl, sda) for every
I2C object creation - my favorite for consistency.

Signed-off-by: Rick Sorensen <rick.sorensen@gmail.com>
Signed-off-by: Rick Sorensen <rick.sorensen@gmail.com>
Signed-off-by: Rick Sorensen <rick.sorensen@gmail.com>
Signed-off-by: Rick Sorensen <rick.sorensen@gmail.com>
Signed-off-by: Rick Sorensen <rick.sorensen@gmail.com>
@dpgeorge
Copy link
Member

I suggest to fix it in machine_i2c.c in a more generic way. Similar to how the default pins for I2C1 are different for esp32 vs other MCUs.

Eg:

#ifndef MICROPY_HW_I2C0_SCL                                             
#if CONFIG_IDF_TARGET_ESP32C3                                      
#define MICROPY_HW_I2C0_SCL (GPIO_NUM_6) 
#define MICROPY_HW_I2C0_SDA (GPIO_NUM_7) 
#else
#define MICROPY_HW_I2C0_SCL (GPIO_NUM_18)
#define MICROPY_HW_I2C0_SDA (GPIO_NUM_19)
#endif
#endif                 

@ricksorensen ricksorensen deleted the esp32c3_board branch April 13, 2025 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0