Skip to content

Commit ee52795

Browse files
committed
fix automatic i2c enablement with rev C
1 parent b1161f5 commit ee52795

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

ports/espressif/boards/adafruit_feather_esp32s2/board.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,16 @@ bool board_requests_safe_mode(void) {
4141

4242
void reset_board(void) {
4343
// Turn on I2C power by default.
44+
45+
// set pin to input to find 'rest state'
46+
gpio_set_direction(7, GPIO_MODE_DEF_INPUT);
47+
// wait 1 millis for pull to activate
48+
mp_hal_delay_ms(1);
49+
// read rest state (off)
50+
bool restlevel = gpio_get_level(7);
4451
gpio_set_direction(7, GPIO_MODE_DEF_OUTPUT);
45-
gpio_set_level(7, false);
52+
// flip it!
53+
gpio_set_level(7, !restlevel);
4654
}
4755

4856
void board_deinit(void) {

ports/espressif/boards/adafruit_feather_esp32s2/pins.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
1717
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) },
1818

1919
{ MP_ROM_QSTR(MP_QSTR_I2C_POWER_INVERTED), MP_ROM_PTR(&pin_GPIO7) },
20+
{ MP_ROM_QSTR(MP_QSTR_I2C_POWER), MP_ROM_PTR(&pin_GPIO7) },
2021
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) },
2122

2223
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) },

0 commit comments

Comments
 (0)