diff --git a/src/utility/Power_Class.cpp b/src/utility/Power_Class.cpp index d6dbce8..f63a3b2 100644 --- a/src/utility/Power_Class.cpp +++ b/src/utility/Power_Class.cpp @@ -2391,6 +2391,21 @@ namespace m5 M5pm1.setGPIOOutput(M5PM1_Class::gpio3, true); } break; +#elif defined (CONFIG_IDF_TARGET_ESP32C5) + case pmic_t::pmic_m5pm1: + if (M5.getBoard() == board_t::board_M5ToughC5) + { + // ToughC5 CHG_PROG is IOE1 G1: low selects 830 mA, high selects 180 mA. + // Set the latch before enabling push-pull output to avoid a transient + // selection of the opposite current during the mode transition. + auto& ioe1 = M5.getIOExpander(0); + const bool select_180mA = max_mA < 830; + ioe1.setPullMode(M5IOE1_Class::gpio1, IOExpander_Base::pull_none); + ioe1.digitalWrite(M5IOE1_Class::gpio1, select_180mA); + ioe1.setHighImpedance(M5IOE1_Class::gpio1, false); + ioe1.setDirection(M5IOE1_Class::gpio1, true); + } + return; #endif #endif diff --git a/src/utility/Power_Class.hpp b/src/utility/Power_Class.hpp index 294294c..b02dfd9 100644 --- a/src/utility/Power_Class.hpp +++ b/src/utility/Power_Class.hpp @@ -161,7 +161,8 @@ namespace m5 /// set battery charge current /// @param max_mA milli ampere. - /// @note CoreMatrix selects the nearest supported maximum: 180 mA below 650 mA, otherwise 650 mA. + /// @note CoreMatrix selects 180 mA below 650 mA, otherwise 650 mA. + /// @note ToughC5 selects 180 mA below 830 mA, otherwise 830 mA. /// @attention Non-functioning models : CoreInk , M5Paper , M5Stack(with non I2C IP5306) void setChargeCurrent(std::uint16_t max_mA);