- sys-clk-OC: Charging current limit

This commit is contained in:
KazushiM
2023-01-02 16:12:13 +08:00
parent 139c7dfcad
commit 277f8d48e5
14 changed files with 270 additions and 135 deletions

View File

@@ -209,9 +209,9 @@ void ClockManager::WaitForNextTick()
bool ClockManager::RefreshContext()
{
bool fastChargingEnabled = !(this->GetConfig()->GetConfigValue(SysClkConfigValue_DisableFastCharging));
uint32_t chargingCurrent = this->GetConfig()->GetConfigValue(SysClkConfigValue_ChargingCurrentLimit);
uint32_t chargingLimit = this->GetConfig()->GetConfigValue(SysClkConfigValue_ChargingLimitPercentage);
PsmExt::ChargingHandler(fastChargingEnabled, chargingLimit);
PsmExt::ChargingHandler(chargingCurrent, chargingLimit);
bool hasChanged = this->config->Refresh();
if (hasChanged) {

View File

@@ -69,10 +69,15 @@ extern "C"
hosversionSet(MAKEHOSVERSION(fw.major, fw.minor, fw.micro));
setsysExit();
}
rc = i2cInitialize();
if (R_FAILED(rc))
fatalThrow(rc);
}
void __appExit(void)
{
i2cExit();
smExit();
}
}

View File

@@ -105,14 +105,19 @@ ReverseNXMode ReverseNXSync::RecheckToolMode() {
}
void PsmExt::ChargingHandler(bool fastChargingEnabled, uint32_t chargingLimit) {
void PsmExt::ChargingHandler(uint32_t chargingCurrent, uint32_t chargingLimit) {
u32 current;
Result res = I2c_Bq24193_GetFastChargeCurrentLimit(&current);
if (R_SUCCEEDED(res)) {
current -= current % 100;
if (current != chargingCurrent)
I2c_Bq24193_SetFastChargeCurrentLimit(chargingCurrent);
}
PsmChargeInfo* info = new PsmChargeInfo;
Service* session = psmGetServiceSession();
serviceDispatchOut(session, Psm_GetBatteryChargeInfoFields, *info);
if (PsmIsFastChargingEnabled(info) != fastChargingEnabled)
serviceDispatch(session, fastChargingEnabled ? Psm_EnableFastBatteryCharging : Psm_DisableFastBatteryCharging);
if (PsmIsChargerConnected(info)) {
u32 chargeNow = 0;
if (R_SUCCEEDED(psmGetBatteryChargePercentage(&chargeNow))) {

View File

@@ -58,7 +58,7 @@ protected:
};
namespace PsmExt {
void ChargingHandler(bool fastChargingEnabled, uint32_t chargingLimit);
void ChargingHandler(uint32_t chargingCurrent, uint32_t chargingLimit);
};
class Governor {