Skip to content

Added Charging Safety Timer Management #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
62 changes: 61 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 Expand Up @@ -773,6 +793,46 @@ bool PMICClass::disableWatchdog(void) {
return writeRegister(CHARGE_TIMER_CONTROL_REGISTER, (DATA & 0b11001110));
}

/*******************************************************************************
* Function Name : enableSafetyChargeTimer
* Description : Enable Safety Charge timer
* Input : NONE
* Return : 0 on Error, 1 on Success
*******************************************************************************/
bool PMICClass::enableSafetyChargeTimer(void) {

int DATA = readRegister(CHARGE_TIMER_CONTROL_REGISTER);

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

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


/*******************************************************************************
* Function Name : disableSafetyChargeTimer
* Description : Disable Safety Charge timer
* Input : NONE
* Return : 0 on Error, 1 on Success
*******************************************************************************/
bool PMICClass::disableSafetyChargeTimer(void) {
int DATA = readRegister(CHARGE_TIMER_CONTROL_REGISTER) & 0x30;

if ((DATA == 0x10) && (PMIC.chargeStatus() != CHARGE_TERMINATION_DONE)){
return 0;
}

DATA = readRegister(CHARGE_TIMER_CONTROL_REGISTER);

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

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

/*******************************************************************************
* Function Name : setThermalRegulationTemperature
* Description : Sets the Thermal Regulation Threshold
Expand Down
2 changes: 2 additions & 0 deletions src/BQ24195.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class PMICClass {

// Charge Timer Control Register
bool disableWatchdog(void);
bool enableSafetyChargeTimer(void);
bool disableSafetyChargeTimer(void);

// Misc Operation Control Register
bool enableDPDM(void);
Expand Down