strat: use m_ for member variables

This commit is contained in:
Michael Scire
2021-10-10 00:14:06 -07:00
parent ce28591ab2
commit a595c232b9
425 changed files with 8531 additions and 8484 deletions

View File

@@ -20,54 +20,54 @@ namespace ams::boot {
class BatteryDriver {
private:
powctl::Session battery_session;
powctl::Session m_battery_session;
public:
BatteryDriver() : battery_session() {
R_ABORT_UNLESS(powctl::OpenSession(std::addressof(this->battery_session), powctl::DeviceCode_Max17050, ddsf::AccessMode_ReadWrite));
BatteryDriver() : m_battery_session() {
R_ABORT_UNLESS(powctl::OpenSession(std::addressof(m_battery_session), powctl::DeviceCode_Max17050, ddsf::AccessMode_ReadWrite));
}
~BatteryDriver() {
powctl::CloseSession(this->battery_session);
powctl::CloseSession(m_battery_session);
}
public:
Result IsBatteryRemoved(bool *out) {
bool present;
R_TRY(powctl::IsBatteryPresent(std::addressof(present), this->battery_session));
R_TRY(powctl::IsBatteryPresent(std::addressof(present), m_battery_session));
*out = !present;
return ResultSuccess();
}
Result GetSocRep(float *out) {
return powctl::GetBatterySocRep(out, this->battery_session);
return powctl::GetBatterySocRep(out, m_battery_session);
}
Result GetAverageVCell(int *out) {
return powctl::GetBatteryAverageVCell(out, this->battery_session);
return powctl::GetBatteryAverageVCell(out, m_battery_session);
}
Result GetOpenCircuitVoltage(int *out) {
return powctl::GetBatteryOpenCircuitVoltage(out, this->battery_session);
return powctl::GetBatteryOpenCircuitVoltage(out, m_battery_session);
}
Result GetAverageCurrent(int *out) {
return powctl::GetBatteryAverageCurrent(out, this->battery_session);
return powctl::GetBatteryAverageCurrent(out, m_battery_session);
}
Result GetCurrent(int *out) {
return powctl::GetBatteryCurrent(out, this->battery_session);
return powctl::GetBatteryCurrent(out, m_battery_session);
}
Result GetTemperature(float *out) {
return powctl::GetBatteryTemperature(out, this->battery_session);
return powctl::GetBatteryTemperature(out, m_battery_session);
}
Result IsI2cShutdownEnabled(bool *out) {
return powctl::IsBatteryI2cShutdownEnabled(out, this->battery_session);
return powctl::IsBatteryI2cShutdownEnabled(out, m_battery_session);
}
Result SetI2cShutdownEnabled(bool en) {
return powctl::SetBatteryI2cShutdownEnabled(this->battery_session, en);
return powctl::SetBatteryI2cShutdownEnabled(m_battery_session, en);
}
};

View File

@@ -27,14 +27,14 @@ namespace ams::boot {
class ChargerDriver {
private:
powctl::Session charger_session;
powctl::Session m_charger_session;
public:
ChargerDriver() : charger_session() {
R_ABORT_UNLESS(powctl::OpenSession(std::addressof(this->charger_session), powctl::DeviceCode_Bq24193, ddsf::AccessMode_ReadWrite));
ChargerDriver() : m_charger_session() {
R_ABORT_UNLESS(powctl::OpenSession(std::addressof(m_charger_session), powctl::DeviceCode_Bq24193, ddsf::AccessMode_ReadWrite));
}
~ChargerDriver() {
powctl::CloseSession(this->charger_session);
powctl::CloseSession(m_charger_session);
}
Result Initialize(bool set_input_current_limit) {
@@ -46,51 +46,51 @@ namespace ams::boot {
/* Set input current limit to 500 ma. */
if (set_input_current_limit) {
R_TRY(powctl::SetChargerInputCurrentLimit(this->charger_session, 500));
R_TRY(powctl::SetChargerInputCurrentLimit(m_charger_session, 500));
}
/* Set input voltage limit to 500 mv. */
R_TRY(powctl::SetChargerInputVoltageLimit(this->charger_session, 500));
R_TRY(powctl::SetChargerInputVoltageLimit(m_charger_session, 500));
/* Disable hi-z mode. */
R_TRY(powctl::SetChargerHiZEnabled(this->charger_session, false));
R_TRY(powctl::SetChargerHiZEnabled(m_charger_session, false));
/* Set configuration to charge battery. */
R_TRY(powctl::SetChargerChargerConfiguration(this->charger_session, powctl::ChargerConfiguration_ChargeBattery));
R_TRY(powctl::SetChargerChargerConfiguration(m_charger_session, powctl::ChargerConfiguration_ChargeBattery));
return ResultSuccess();
}
Result GetChargeCurrentState(powctl::ChargeCurrentState *out) {
return powctl::GetChargerChargeCurrentState(out, this->charger_session);
return powctl::GetChargerChargeCurrentState(out, m_charger_session);
}
Result SetChargeCurrentState(powctl::ChargeCurrentState state) {
return powctl::SetChargerChargeCurrentState(this->charger_session, state);
return powctl::SetChargerChargeCurrentState(m_charger_session, state);
}
Result GetInputCurrentLimit(int *out) {
return powctl::GetChargerInputCurrentLimit(out, this->charger_session);
return powctl::GetChargerInputCurrentLimit(out, m_charger_session);
}
Result SetChargerConfiguration(powctl::ChargerConfiguration cfg) {
return powctl::SetChargerChargerConfiguration(this->charger_session, cfg);
return powctl::SetChargerChargerConfiguration(m_charger_session, cfg);
}
Result GetFastChargeCurrentLimit(int *out) {
return powctl::GetChargerFastChargeCurrentLimit(out, this->charger_session);
return powctl::GetChargerFastChargeCurrentLimit(out, m_charger_session);
}
Result SetFastChargeCurrentLimit(int limit) {
return powctl::SetChargerFastChargeCurrentLimit(this->charger_session, limit);
return powctl::SetChargerFastChargeCurrentLimit(m_charger_session, limit);
}
Result GetChargeVoltageLimit(int *out) {
return powctl::GetChargerChargeVoltageLimit(out, this->charger_session);
return powctl::GetChargerChargeVoltageLimit(out, m_charger_session);
}
Result SetChargeVoltageLimit(int limit) {
return powctl::SetChargerChargeVoltageLimit(this->charger_session, limit);
return powctl::SetChargerChargeVoltageLimit(m_charger_session, limit);
}
Result GetChargerStatus(boot::ChargerStatus *out) {
@@ -99,7 +99,7 @@ namespace ams::boot {
/* Get the powctl status. */
powctl::ChargerStatus powctl_status;
R_TRY(powctl::GetChargerChargerStatus(std::addressof(powctl_status), this->charger_session));
R_TRY(powctl::GetChargerChargerStatus(std::addressof(powctl_status), m_charger_session));
switch (powctl_status) {
case powctl::ChargerStatus_Charging: *out = boot::ChargerStatus_Charging; break;
@@ -111,19 +111,19 @@ namespace ams::boot {
}
Result GetBatteryCompensation(int *out) {
return powctl::GetChargerBatteryCompensation(out, this->charger_session);
return powctl::GetChargerBatteryCompensation(out, m_charger_session);
}
Result SetBatteryCompensation(int v) {
return powctl::SetChargerBatteryCompensation(this->charger_session, v);
return powctl::SetChargerBatteryCompensation(m_charger_session, v);
}
Result GetVoltageClamp(int *out) {
return powctl::GetChargerVoltageClamp(out, this->charger_session);
return powctl::GetChargerVoltageClamp(out, m_charger_session);
}
Result SetVoltageClamp(int v) {
return powctl::SetChargerVoltageClamp(this->charger_session, v);
return powctl::SetChargerVoltageClamp(m_charger_session, v);
}
};

View File

@@ -42,18 +42,18 @@ namespace ams::boot {
class BatteryChecker {
private:
boot::ChargerDriver &charger_driver;
boot::BatteryDriver &battery_driver;
const powctl::driver::impl::ChargeParameters &charge_parameters;
powctl::driver::impl::ChargeArbiter charge_arbiter;
powctl::ChargeCurrentState charge_current_state;
int fast_charge_current_limit;
int charge_voltage_limit;
int battery_compensation;
int voltage_clamp;
TimeSpan charging_done_interval;
bool has_start_time;
TimeSpan start_time;
boot::ChargerDriver &m_charger_driver;
boot::BatteryDriver &m_battery_driver;
const powctl::driver::impl::ChargeParameters &m_charge_parameters;
powctl::driver::impl::ChargeArbiter m_charge_arbiter;
powctl::ChargeCurrentState m_charge_current_state;
int m_fast_charge_current_limit;
int m_charge_voltage_limit;
int m_battery_compensation;
int m_voltage_clamp;
TimeSpan m_charging_done_interval;
bool m_has_start_time;
TimeSpan m_start_time;
private:
bool IsChargeDone();
void UpdateChargeDoneCurrent();
@@ -63,25 +63,25 @@ namespace ams::boot {
void UpdateStartTime() {
/* Update start time. */
this->start_time = os::ConvertToTimeSpan(os::GetSystemTick());
this->has_start_time = true;
m_start_time = os::ConvertToTimeSpan(os::GetSystemTick());
m_has_start_time = true;
}
public:
BatteryChecker(boot::ChargerDriver &cd, boot::BatteryDriver &bd, const powctl::driver::impl::ChargeParameters &cp, int cvl) : charger_driver(cd), battery_driver(bd), charge_parameters(cp), charge_arbiter(cp.rules, cp.num_rules, cvl), charging_done_interval(TimeSpan::FromSeconds(2)), has_start_time(false) {
BatteryChecker(boot::ChargerDriver &cd, boot::BatteryDriver &bd, const powctl::driver::impl::ChargeParameters &cp, int cvl) : m_charger_driver(cd), m_battery_driver(bd), m_charge_parameters(cp), m_charge_arbiter(cp.rules, cp.num_rules, cvl), m_charging_done_interval(TimeSpan::FromSeconds(2)), m_has_start_time(false) {
/* Get parameters from charger. */
if (R_FAILED(this->charger_driver.GetChargeCurrentState(std::addressof(this->charge_current_state)))) {
if (R_FAILED(m_charger_driver.GetChargeCurrentState(std::addressof(m_charge_current_state)))) {
boot::ShutdownSystem();
}
if (R_FAILED(this->charger_driver.GetFastChargeCurrentLimit(std::addressof(this->fast_charge_current_limit)))) {
if (R_FAILED(m_charger_driver.GetFastChargeCurrentLimit(std::addressof(m_fast_charge_current_limit)))) {
boot::ShutdownSystem();
}
if (R_FAILED(this->charger_driver.GetChargeVoltageLimit(std::addressof(this->charge_voltage_limit)))) {
if (R_FAILED(m_charger_driver.GetChargeVoltageLimit(std::addressof(m_charge_voltage_limit)))) {
boot::ShutdownSystem();
}
if (R_FAILED(this->charger_driver.GetBatteryCompensation(std::addressof(this->battery_compensation)))) {
if (R_FAILED(m_charger_driver.GetBatteryCompensation(std::addressof(m_battery_compensation)))) {
boot::ShutdownSystem();
}
if (R_FAILED(this->charger_driver.GetVoltageClamp(std::addressof(this->voltage_clamp)))) {
if (R_FAILED(m_charger_driver.GetVoltageClamp(std::addressof(m_voltage_clamp)))) {
boot::ShutdownSystem();
}
@@ -112,16 +112,16 @@ namespace ams::boot {
/* Get various battery metrics. */
int avg_current, current, open_circuit_voltage;
float temp;
if (R_FAILED(this->battery_driver.GetAverageCurrent(std::addressof(avg_current)))) {
if (R_FAILED(m_battery_driver.GetAverageCurrent(std::addressof(avg_current)))) {
return;
}
if (R_FAILED(this->battery_driver.GetCurrent(std::addressof(current)))) {
if (R_FAILED(m_battery_driver.GetCurrent(std::addressof(current)))) {
return;
}
if (R_FAILED(this->battery_driver.GetTemperature(std::addressof(temp)))) {
if (R_FAILED(m_battery_driver.GetTemperature(std::addressof(temp)))) {
return;
}
if (R_FAILED(this->battery_driver.GetOpenCircuitVoltage(std::addressof(open_circuit_voltage)))) {
if (R_FAILED(m_battery_driver.GetOpenCircuitVoltage(std::addressof(open_circuit_voltage)))) {
return;
}
@@ -132,7 +132,7 @@ namespace ams::boot {
bool BatteryChecker::IsChargeDone() {
/* Get the charger status. */
boot::ChargerStatus charger_status;
if (R_FAILED(this->charger_driver.GetChargerStatus(std::addressof(charger_status)))) {
if (R_FAILED(m_charger_driver.GetChargerStatus(std::addressof(charger_status)))) {
boot::ShutdownSystem();
}
@@ -142,20 +142,20 @@ namespace ams::boot {
}
/* Return whether a done current of zero is acceptable. */
return this->charge_arbiter.IsBatteryDoneCurrentAcceptable(0);
return m_charge_arbiter.IsBatteryDoneCurrentAcceptable(0);
}
void BatteryChecker::UpdateChargeDoneCurrent() {
int done_current = 0;
if (this->has_start_time && (os::ConvertToTimeSpan(os::GetSystemTick()) - this->start_time) >= this->charging_done_interval) {
if (m_has_start_time && (os::ConvertToTimeSpan(os::GetSystemTick()) - m_start_time) >= m_charging_done_interval) {
/* Get the current. */
if (R_FAILED(this->battery_driver.GetCurrent(std::addressof(done_current)))) {
if (R_FAILED(m_battery_driver.GetCurrent(std::addressof(done_current)))) {
boot::ShutdownSystem();
}
} else {
/* Get the charger status. */
boot::ChargerStatus charger_status;
if (R_FAILED(this->charger_driver.GetChargerStatus(std::addressof(charger_status)))) {
if (R_FAILED(m_charger_driver.GetChargerStatus(std::addressof(charger_status)))) {
boot::ShutdownSystem();
}
@@ -166,50 +166,50 @@ namespace ams::boot {
}
/* Update done current. */
this->charge_arbiter.SetBatteryDoneCurrent(done_current);
m_charge_arbiter.SetBatteryDoneCurrent(done_current);
}
void BatteryChecker::UpdateCharger() {
/* Get the battery temperature. */
float temp;
if (R_FAILED(this->battery_driver.GetTemperature(std::addressof(temp)))) {
if (R_FAILED(m_battery_driver.GetTemperature(std::addressof(temp)))) {
boot::ShutdownSystem();
}
/* Update the temperature level. */
powctl::BatteryTemperatureLevel temp_level;
if (temp < static_cast<float>(this->charge_parameters.temp_min)) {
if (temp < static_cast<float>(m_charge_parameters.temp_min)) {
temp_level = powctl::BatteryTemperatureLevel::TooLow;
} else if (temp < static_cast<float>(this->charge_parameters.temp_low)) {
} else if (temp < static_cast<float>(m_charge_parameters.temp_low)) {
temp_level = powctl::BatteryTemperatureLevel::Low;
} else if (temp < static_cast<float>(this->charge_parameters.temp_high)) {
} else if (temp < static_cast<float>(m_charge_parameters.temp_high)) {
temp_level = powctl::BatteryTemperatureLevel::Medium;
} else if (temp < static_cast<float>(this->charge_parameters.temp_max)) {
} else if (temp < static_cast<float>(m_charge_parameters.temp_max)) {
temp_level = powctl::BatteryTemperatureLevel::High;
} else {
temp_level = powctl::BatteryTemperatureLevel::TooHigh;
}
this->charge_arbiter.SetBatteryTemperatureLevel(temp_level);
m_charge_arbiter.SetBatteryTemperatureLevel(temp_level);
/* Update average voltage. */
int avg_v_cell;
if (R_FAILED(this->battery_driver.GetAverageVCell(std::addressof(avg_v_cell)))) {
if (R_FAILED(m_battery_driver.GetAverageVCell(std::addressof(avg_v_cell)))) {
boot::ShutdownSystem();
}
this->charge_arbiter.SetBatteryAverageVCell(avg_v_cell);
m_charge_arbiter.SetBatteryAverageVCell(avg_v_cell);
/* Update open circuit voltage. */
int ocv;
if (R_FAILED(this->battery_driver.GetOpenCircuitVoltage(std::addressof(ocv)))) {
if (R_FAILED(m_battery_driver.GetOpenCircuitVoltage(std::addressof(ocv)))) {
boot::ShutdownSystem();
}
this->charge_arbiter.SetBatteryOpenCircuitVoltage(ocv);
m_charge_arbiter.SetBatteryOpenCircuitVoltage(ocv);
/* Update charge done current. */
this->UpdateChargeDoneCurrent();
/* Update arbiter power state. */
this->charge_arbiter.SetPowerState(powctl::PowerState::ShutdownChargeMain);
m_charge_arbiter.SetPowerState(powctl::PowerState::ShutdownChargeMain);
/* Apply the newly selected rule. */
this->ApplyArbiterRule();
@@ -217,19 +217,19 @@ namespace ams::boot {
void BatteryChecker::ApplyArbiterRule() {
/* Get the selected rule. */
const auto *rule = this->charge_arbiter.GetSelectedRule();
const auto *rule = m_charge_arbiter.GetSelectedRule();
AMS_ASSERT(rule != nullptr);
/* Check if we need to perform charger initialization. */
const bool reinit_charger = rule->reinitialize_charger;
const auto cur_charge_current_state = this->charge_current_state;
const auto cur_charge_current_state = m_charge_current_state;
/* Set the charger to not charging while we make changes. */
if (!reinit_charger || cur_charge_current_state != powctl::ChargeCurrentState_NotCharging) {
if (R_FAILED(this->charger_driver.SetChargeCurrentState(powctl::ChargeCurrentState_NotCharging))) {
if (R_FAILED(m_charger_driver.SetChargeCurrentState(powctl::ChargeCurrentState_NotCharging))) {
boot::ShutdownSystem();
}
this->charge_current_state = powctl::ChargeCurrentState_NotCharging;
m_charge_current_state = powctl::ChargeCurrentState_NotCharging;
/* Update start time. */
this->UpdateStartTime();
@@ -237,25 +237,25 @@ namespace ams::boot {
/* Process fast charge current limit when rule is smaller. */
const auto rule_fast_charge_current_limit = rule->fast_charge_current_limit;
const auto cur_fast_charge_current_limit = this->fast_charge_current_limit;
const auto cur_fast_charge_current_limit = m_fast_charge_current_limit;
if (rule_fast_charge_current_limit < cur_fast_charge_current_limit) {
if (R_FAILED(this->charger_driver.SetFastChargeCurrentLimit(rule_fast_charge_current_limit))) {
if (R_FAILED(m_charger_driver.SetFastChargeCurrentLimit(rule_fast_charge_current_limit))) {
boot::ShutdownSystem();
}
this->fast_charge_current_limit = rule_fast_charge_current_limit;
m_fast_charge_current_limit = rule_fast_charge_current_limit;
/* Update start time. */
this->UpdateStartTime();
}
/* Process charge voltage limit when rule is smaller. */
const auto rule_charge_voltage_limit = std::min(rule->charge_voltage_limit, this->charge_arbiter.GetChargeVoltageLimit());
const auto cur_charge_voltage_limit = this->charge_voltage_limit;
const auto rule_charge_voltage_limit = std::min(rule->charge_voltage_limit, m_charge_arbiter.GetChargeVoltageLimit());
const auto cur_charge_voltage_limit = m_charge_voltage_limit;
if (rule_charge_voltage_limit < cur_charge_voltage_limit) {
if (R_FAILED(this->charger_driver.SetChargeVoltageLimit(rule_charge_voltage_limit))) {
if (R_FAILED(m_charger_driver.SetChargeVoltageLimit(rule_charge_voltage_limit))) {
boot::ShutdownSystem();
}
this->charge_voltage_limit = rule_charge_voltage_limit;
m_charge_voltage_limit = rule_charge_voltage_limit;
/* Update start time. */
this->UpdateStartTime();
@@ -263,12 +263,12 @@ namespace ams::boot {
/* Process battery compensation when rule is smaller. */
const auto rule_battery_compensation = rule->battery_compensation;
const auto cur_battery_compensation = this->battery_compensation;
const auto cur_battery_compensation = m_battery_compensation;
if (rule_battery_compensation < cur_battery_compensation) {
if (R_FAILED(this->charger_driver.SetBatteryCompensation(rule_battery_compensation))) {
if (R_FAILED(m_charger_driver.SetBatteryCompensation(rule_battery_compensation))) {
boot::ShutdownSystem();
}
this->battery_compensation = rule_battery_compensation;
m_battery_compensation = rule_battery_compensation;
/* Update start time. */
this->UpdateStartTime();
@@ -276,12 +276,12 @@ namespace ams::boot {
/* Process voltage clamp when rule is smaller. */
const auto rule_voltage_clamp = rule->voltage_clamp;
const auto cur_voltage_clamp = this->voltage_clamp;
const auto cur_voltage_clamp = m_voltage_clamp;
if (rule_voltage_clamp < cur_voltage_clamp) {
if (R_FAILED(this->charger_driver.SetVoltageClamp(rule_voltage_clamp))) {
if (R_FAILED(m_charger_driver.SetVoltageClamp(rule_voltage_clamp))) {
boot::ShutdownSystem();
}
this->voltage_clamp = rule_voltage_clamp;
m_voltage_clamp = rule_voltage_clamp;
/* Update start time. */
this->UpdateStartTime();
@@ -289,10 +289,10 @@ namespace ams::boot {
/* Process voltage clamp when rule is larger. */
if (rule_voltage_clamp > cur_voltage_clamp) {
if (R_FAILED(this->charger_driver.SetVoltageClamp(rule_voltage_clamp))) {
if (R_FAILED(m_charger_driver.SetVoltageClamp(rule_voltage_clamp))) {
boot::ShutdownSystem();
}
this->voltage_clamp = rule_voltage_clamp;
m_voltage_clamp = rule_voltage_clamp;
/* Update start time. */
this->UpdateStartTime();
@@ -300,10 +300,10 @@ namespace ams::boot {
/* Process battery compensation when rule is larger. */
if (rule_battery_compensation > cur_battery_compensation) {
if (R_FAILED(this->charger_driver.SetBatteryCompensation(rule_battery_compensation))) {
if (R_FAILED(m_charger_driver.SetBatteryCompensation(rule_battery_compensation))) {
boot::ShutdownSystem();
}
this->battery_compensation = rule_battery_compensation;
m_battery_compensation = rule_battery_compensation;
/* Update start time. */
this->UpdateStartTime();
@@ -311,10 +311,10 @@ namespace ams::boot {
/* Process fast charge current limit when rule is larger. */
if (rule_fast_charge_current_limit > cur_fast_charge_current_limit) {
if (R_FAILED(this->charger_driver.SetFastChargeCurrentLimit(rule_fast_charge_current_limit))) {
if (R_FAILED(m_charger_driver.SetFastChargeCurrentLimit(rule_fast_charge_current_limit))) {
boot::ShutdownSystem();
}
this->fast_charge_current_limit = rule_fast_charge_current_limit;
m_fast_charge_current_limit = rule_fast_charge_current_limit;
/* Update start time. */
this->UpdateStartTime();
@@ -322,10 +322,10 @@ namespace ams::boot {
/* Process charge voltage limit when rule is larger. */
if (rule_charge_voltage_limit > cur_charge_voltage_limit) {
if (R_FAILED(this->charger_driver.SetChargeVoltageLimit(rule_charge_voltage_limit))) {
if (R_FAILED(m_charger_driver.SetChargeVoltageLimit(rule_charge_voltage_limit))) {
boot::ShutdownSystem();
}
this->charge_voltage_limit = rule_charge_voltage_limit;
m_charge_voltage_limit = rule_charge_voltage_limit;
/* Update start time. */
this->UpdateStartTime();
@@ -333,10 +333,10 @@ namespace ams::boot {
/* If we're not charging and we expect to reinitialize the charger, do so. */
if (cur_charge_current_state != powctl::ChargeCurrentState_Charging && reinit_charger) {
if (R_FAILED(this->charger_driver.SetChargeCurrentState(powctl::ChargeCurrentState_Charging))) {
if (R_FAILED(m_charger_driver.SetChargeCurrentState(powctl::ChargeCurrentState_Charging))) {
boot::ShutdownSystem();
}
this->charge_current_state = powctl::ChargeCurrentState_Charging;
m_charge_current_state = powctl::ChargeCurrentState_Charging;
/* Update start time. */
this->UpdateStartTime();
@@ -357,7 +357,7 @@ namespace ams::boot {
if (show_charging_display) {
/* Get the raw battery charge. */
float raw_battery_charge;
if (R_FAILED(this->battery_driver.GetSocRep(std::addressof(raw_battery_charge)))) {
if (R_FAILED(m_battery_driver.GetSocRep(std::addressof(raw_battery_charge)))) {
return CheckBatteryResult::Shutdown;
}
@@ -372,13 +372,13 @@ namespace ams::boot {
while (true) {
/* Get the raw battery charge. */
float raw_battery_charge;
if (R_FAILED(this->battery_driver.GetSocRep(std::addressof(raw_battery_charge)))) {
if (R_FAILED(m_battery_driver.GetSocRep(std::addressof(raw_battery_charge)))) {
return CheckBatteryResult::Shutdown;
}
/* Get the average vcell. */
int battery_voltage;
if (R_FAILED(this->battery_driver.GetAverageVCell(std::addressof(battery_voltage)))) {
if (R_FAILED(m_battery_driver.GetAverageVCell(std::addressof(battery_voltage)))) {
return CheckBatteryResult::Shutdown;
}

View File

@@ -36,17 +36,17 @@ namespace ams::boot {
Result PmicDriver::GetOnOffIrq(u8 *out) {
const u8 addr = 0x0B;
return ReadI2cRegister(this->i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr));
return ReadI2cRegister(m_i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr));
}
Result PmicDriver::GetPowerStatus(u8 *out) {
const u8 addr = 0x15;
return ReadI2cRegister(this->i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr));
return ReadI2cRegister(m_i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr));
}
Result PmicDriver::GetNvErc(u8 *out) {
const u8 addr = 0x0C;
return ReadI2cRegister(this->i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr));
return ReadI2cRegister(m_i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr));
}
Result PmicDriver::GetPowerButtonPressed(bool *out) {
@@ -62,17 +62,17 @@ namespace ams::boot {
/* Get value, set or clear software reset mask. */
u8 on_off_2_val = 0;
R_ABORT_UNLESS(ReadI2cRegister(this->i2c_session, std::addressof(on_off_2_val), sizeof(on_off_2_val), std::addressof(on_off_2_addr), sizeof(on_off_2_addr)));
R_ABORT_UNLESS(ReadI2cRegister(m_i2c_session, std::addressof(on_off_2_val), sizeof(on_off_2_val), std::addressof(on_off_2_addr), sizeof(on_off_2_addr)));
if (reboot) {
on_off_2_val |= 0x80;
} else {
on_off_2_val &= ~0x80;
}
R_ABORT_UNLESS(WriteI2cRegister(this->i2c_session, std::addressof(on_off_2_val), sizeof(on_off_2_val), std::addressof(on_off_2_addr), sizeof(on_off_2_addr)));
R_ABORT_UNLESS(WriteI2cRegister(m_i2c_session, std::addressof(on_off_2_val), sizeof(on_off_2_val), std::addressof(on_off_2_addr), sizeof(on_off_2_addr)));
/* Get value, set software reset mask. */
u8 on_off_1_val = 0;
R_ABORT_UNLESS(ReadI2cRegister(this->i2c_session, std::addressof(on_off_1_val), sizeof(on_off_1_val), std::addressof(on_off_1_addr), sizeof(on_off_1_addr)));
R_ABORT_UNLESS(ReadI2cRegister(m_i2c_session, std::addressof(on_off_1_val), sizeof(on_off_1_val), std::addressof(on_off_1_addr), sizeof(on_off_1_addr)));
on_off_1_val |= 0x80;
/* Finalize the battery on non-Calcio. */
@@ -82,7 +82,7 @@ namespace ams::boot {
}
/* Actually write the value to trigger shutdown/reset. */
R_ABORT_UNLESS(WriteI2cRegister(this->i2c_session, std::addressof(on_off_1_val), sizeof(on_off_1_val), std::addressof(on_off_1_addr), sizeof(on_off_1_addr)));
R_ABORT_UNLESS(WriteI2cRegister(m_i2c_session, std::addressof(on_off_1_val), sizeof(on_off_1_val), std::addressof(on_off_1_addr), sizeof(on_off_1_addr)));
/* Allow up to 5 seconds for shutdown/reboot to take place. */
os::SleepThread(TimeSpan::FromSeconds(5));

View File

@@ -21,14 +21,14 @@ namespace ams::boot {
/* Driver object. */
class PmicDriver {
private:
i2c::driver::I2cSession i2c_session;
i2c::driver::I2cSession m_i2c_session;
public:
PmicDriver() {
R_ABORT_UNLESS(i2c::driver::OpenSession(std::addressof(this->i2c_session), i2c::DeviceCode_Max77620Pmic));
R_ABORT_UNLESS(i2c::driver::OpenSession(std::addressof(m_i2c_session), i2c::DeviceCode_Max77620Pmic));
}
~PmicDriver() {
i2c::driver::CloseSession(this->i2c_session);
i2c::driver::CloseSession(m_i2c_session);
}
private:
Result GetPowerStatus(u8 *out);

View File

@@ -21,14 +21,14 @@ namespace ams::boot {
Result RtcDriver::ReadRtcRegister(u8 *out, u8 address) {
const u8 update_addr = 0x04;
const u8 update_val = 0x10;
R_TRY(WriteI2cRegister(this->i2c_session, &update_val, sizeof(update_val), &update_addr, sizeof(update_addr)));
R_TRY(WriteI2cRegister(m_i2c_session, &update_val, sizeof(update_val), &update_addr, sizeof(update_addr)));
os::SleepThread(TimeSpan::FromMilliSeconds(16));
return ReadI2cRegister(this->i2c_session, out, sizeof(*out), &address, sizeof(address));
return ReadI2cRegister(m_i2c_session, out, sizeof(*out), &address, sizeof(address));
}
Result RtcDriver::GetRtcIntr(u8 *out) {
const u8 addr = 0x00;
return ReadI2cRegister(this->i2c_session, out, sizeof(*out), &addr, sizeof(addr));
return ReadI2cRegister(m_i2c_session, out, sizeof(*out), &addr, sizeof(addr));
}
Result RtcDriver::GetRtcIntrM(u8 *out) {

View File

@@ -20,14 +20,14 @@ namespace ams::boot {
class RtcDriver {
private:
i2c::driver::I2cSession i2c_session;
i2c::driver::I2cSession m_i2c_session;
public:
RtcDriver() {
R_ABORT_UNLESS(i2c::driver::OpenSession(std::addressof(this->i2c_session), i2c::DeviceCode_Max77620Rtc));
R_ABORT_UNLESS(i2c::driver::OpenSession(std::addressof(m_i2c_session), i2c::DeviceCode_Max77620Rtc));
}
~RtcDriver() {
i2c::driver::CloseSession(this->i2c_session);
i2c::driver::CloseSession(m_i2c_session);
}
private:
Result ReadRtcRegister(u8 *out, u8 address);