From 2563c509f71c50767f6dfd9b73d5798a8a040409 Mon Sep 17 00:00:00 2001 From: lady ada Date: Tue, 1 Mar 2022 18:15:37 -0500 Subject: [PATCH 1/2] fix automatic i2c enablement with rev C --- .../espressif/boards/adafruit_feather_esp32s2/board.c | 10 +++++++++- ports/espressif/boards/adafruit_feather_esp32s2/pins.c | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/board.c b/ports/espressif/boards/adafruit_feather_esp32s2/board.c index 1be9000b3a..f9e88c097e 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2/board.c @@ -41,8 +41,16 @@ bool board_requests_safe_mode(void) { void reset_board(void) { // Turn on I2C power by default. + + // set pin to input to find 'rest state' + gpio_set_direction(7, GPIO_MODE_DEF_INPUT); + // wait 1 millis for pull to activate + mp_hal_delay_ms(1); + // read rest state (off) + bool restlevel = gpio_get_level(7); gpio_set_direction(7, GPIO_MODE_DEF_OUTPUT); - gpio_set_level(7, false); + // flip it! + gpio_set_level(7, !restlevel); } void board_deinit(void) { diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c index c9f0e870ed..6cad56eb19 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c @@ -17,6 +17,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, { MP_ROM_QSTR(MP_QSTR_I2C_POWER_INVERTED), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_I2C_POWER), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) }, From b032d42a71fa46eddcd6fa52ccc82aa7851e9e3c Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 1 Mar 2022 19:56:23 -0500 Subject: [PATCH 2/2] Update ports/espressif/boards/adafruit_feather_esp32s2/pins.c --- ports/espressif/boards/adafruit_feather_esp32s2/pins.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c index 6cad56eb19..cf4c915e7f 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c @@ -16,7 +16,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, - { MP_ROM_QSTR(MP_QSTR_I2C_POWER_INVERTED), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_I2C_POWER), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) },