Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/utility/Power_Class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/utility/Power_Class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading