Skip to content

Commit 6286728

Browse files
committed
nicla-system: Add function to disable charging.
1 parent 6ab5b66 commit 6286728

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

libraries/Nicla_System/src/Nicla_System.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ bool nicla::enableCharging(uint16_t mA, bool disableNtc)
150150
return _pmic.getFastChargeControlRegister() == _fastChargeRegisterData;
151151
}
152152

153+
bool nicla::disableCharging()
154+
{
155+
// Set Bit 1 to 1 to disable charging.
156+
_fastChargeRegisterData |= 0b10;
157+
_pmic.writeByte(BQ25120A_ADDRESS, BQ25120A_FAST_CHG, _fastChargeRegisterData);
158+
return _pmic.getFastChargeControlRegister() == _fastChargeRegisterData;
159+
}
160+
153161
bool nicla::runsOnBattery() {
154162
return _pmic.runsOnBattery(BQ25120A_ADDRESS);
155163
}

libraries/Nicla_System/src/Nicla_System.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ class nicla {
8282
*/
8383
static bool enableCharging(uint16_t mA = 20, bool disableNtc = true);
8484

85+
/**
86+
* @brief Disables charging of the battery. It can be resumed by calling enableCharging().
87+
*
88+
* @return true If the charging is disabled successfully. False, otherwise.
89+
*/
90+
static bool disableCharging();
91+
8592
/**
8693
* @brief Determines if the board is charged from the battery.
8794
*

0 commit comments

Comments
 (0)