Skip to content

Commit

Permalink
Added Charging Safety Timer Management
Browse files Browse the repository at this point in the history
Added Charging Safety Timer Management in order to fix arduino-libraries#11
  • Loading branch information
Rocketct committed Jun 10, 2022
1 parent bc6ea2c commit 2e704b3
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/BQ24195.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,15 @@ bool PMICClass::enableCharging() {
DATA = DATA & 0b11001111;
DATA = DATA | 0b00010000;
return writeRegister(POWERON_CONFIG_REGISTER, DATA);

// enable Charging Safety Timer
DATA = readRegister(CHARGE_TIMER_CONTROL_REGISTER);

if (DATA == -1) {
return 0;
}

return writeRegister(CHARGE_TIMER_CONTROL_REGISTER, (DATA | 0b00001000));
}

/*******************************************************************************
Expand All @@ -475,7 +484,18 @@ bool PMICClass::disableCharging() {
return 0;
}

return writeRegister(POWERON_CONFIG_REGISTER, DATA & 0xCF);
if (writeRegister(POWERON_CONFIG_REGISTER, DATA & 0xCF)){
return 0;
}

// disable Charging Safety Timer
DATA = readRegister(CHARGE_TIMER_CONTROL_REGISTER);

if (DATA == -1) {
return 0;
}

return writeRegister(CHARGE_TIMER_CONTROL_REGISTER, (DATA & 0b11110110));
}

/*******************************************************************************
Expand Down

0 comments on commit 2e704b3

Please sign in to comment.