Skip to content

Commit

Permalink
Update common.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
tobozo authored Jul 26, 2024
1 parent 239f056 commit 9729d62
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/lgfx/v1/platforms/esp32/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,10 +884,6 @@ namespace lgfx
gpio_set_direction(scl_io, GPIO_MODE_OUTPUT_OD);
delayMicroseconds(I2C_CLR_BUS_HALF_PERIOD_US);

auto mod = getPeriphModule(i2c_port);
// ESP-IDF環境でperiph_module_disableを使うと、後でenableできなくなる問題が起きたためコメントアウト;
//periph_module_disable(mod);

// SDAがHIGHになるまでSTOP送出を繰り返す。;
int i = 0;
do
Expand All @@ -901,9 +897,9 @@ namespace lgfx
gpio_set_level(sda_io, 1);
delayMicroseconds(I2C_CLR_BUS_HALF_PERIOD_US);
} while (!gpio_get_level(sda_io) && (i++ < I2C_CLR_BUS_SCL_NUM));
periph_module_enable(mod);
#if !defined (CONFIG_IDF_TARGET_ESP32C3)
/// ESP32C3で periph_module_reset を使用すると以後通信不能になる問題が起きたため分岐;
auto mod = getPeriphModule(i2c_port);
periph_module_reset(mod);
#endif
i2c_set_pin((i2c_port_t)i2c_port, sda_io, scl_io, gpio_pullup_t::GPIO_PULLUP_ENABLE, gpio_pullup_t::GPIO_PULLUP_ENABLE, I2C_MODE_MASTER);
Expand Down Expand Up @@ -1027,6 +1023,9 @@ namespace lgfx
#endif
#endif
#endif
#else
auto mod = getPeriphModule(i2c_port)
periph_module_disable(mod);
#endif
if ((int)i2c_context[i2c_port].pin_scl >= 0)
{
Expand Down Expand Up @@ -1096,6 +1095,9 @@ namespace lgfx
#else
twowire->begin((int)i2c_context[i2c_port].pin_sda, (int)i2c_context[i2c_port].pin_scl);
#endif
#else
auto mod = getPeriphModule(i2c_port)
periph_module_disable(mod);
#endif

i2c_context[i2c_port].initialized = true;
Expand Down

0 comments on commit 9729d62

Please sign in to comment.