Skip to content

Commit 1fabd1d

Browse files
committed
nicla-system: Move function to read LDO register to pmic driver.
1 parent 47f3026 commit 1fabd1d

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

libraries/Nicla_System/src/BQ25120A.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ uint8_t BQ25120A::getFastChargeControlRegister()
2525
return readByte(BQ25120A_ADDRESS, BQ25120A_FAST_CHG);
2626
}
2727

28+
uint8_t BQ25120A::getLDOControlRegister()
29+
{
30+
return readByte(BQ25120A_ADDRESS, BQ25120A_LDO_CTRL);
31+
}
32+
2833
void BQ25120A::writeByte(uint8_t address, uint8_t subAddress, uint8_t data)
2934
{
3035
setHighImpedanceModeEnabled(false);

libraries/Nicla_System/src/BQ25120A.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ class BQ25120A
4141
*/
4242
uint8_t getFaultsRegister();
4343

44+
/**
45+
* @brief Gets the data from the SYS VOUT Control Register.
46+
* @see Section 9.6.7 of the datasheet.
47+
*
48+
* @return uint8_t The data from the SYS VOUT Control Register.
49+
*/
50+
uint8_t getLDOControlRegister();
51+
4452
/**
4553
* @brief Gets the data from the fast charge control register.
4654
* @see Section 9.6.4 of the datasheet.

libraries/Nicla_System/src/Nicla_System.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ bool nicla::enable3V3LDO()
6565
{
6666
uint8_t ldo_reg = 0xE4;
6767
_pmic.writeByte(BQ25120A_ADDRESS, BQ25120A_LDO_CTRL, ldo_reg);
68-
if (_pmic.readByte(BQ25120A_ADDRESS, BQ25120A_LDO_CTRL) != ldo_reg) {
68+
if (_pmic.getLDOControlRegister() != ldo_reg) {
6969
return false;
7070
}
7171
return true;
@@ -75,18 +75,18 @@ bool nicla::enable1V8LDO()
7575
{
7676
uint8_t ldo_reg = 0xA8;
7777
_pmic.writeByte(BQ25120A_ADDRESS, BQ25120A_LDO_CTRL, ldo_reg);
78-
if (_pmic.readByte(BQ25120A_ADDRESS, BQ25120A_LDO_CTRL) != ldo_reg) {
78+
if (_pmic.getLDOControlRegister() != ldo_reg) {
7979
return false;
8080
}
8181
return true;
8282
}
8383

8484
bool nicla::disableLDO()
8585
{
86-
uint8_t ldo_reg = _pmic.readByte(BQ25120A_ADDRESS, BQ25120A_LDO_CTRL);
86+
uint8_t ldo_reg = _pmic.getLDOControlRegister();
8787
ldo_reg &= 0x7F;
8888
_pmic.writeByte(BQ25120A_ADDRESS, BQ25120A_LDO_CTRL, ldo_reg);
89-
if (_pmic.readByte(BQ25120A_ADDRESS, BQ25120A_LDO_CTRL) != ldo_reg) {
89+
if (_pmic.getLDOControlRegister() != ldo_reg) {
9090
return false;
9191
}
9292
return true;
@@ -103,11 +103,6 @@ bool nicla::enterShipMode()
103103
_pmic.writeByte(BQ25120A_ADDRESS, BQ25120A_STATUS, status_reg);
104104
}
105105

106-
uint8_t nicla::readLDOreg()
107-
{
108-
return _pmic.readByte(BQ25120A_ADDRESS, BQ25120A_LDO_CTRL);
109-
}
110-
111106
bool nicla::enableCharge(uint8_t mA, bool disableNtc)
112107
{
113108

libraries/Nicla_System/src/Nicla_System.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class nicla {
5151
* @return true if the ship mode is entered successfully.
5252
*/
5353
static bool enterShipMode();
54-
static uint8_t readLDOreg();
5554
static bool enableCharge(uint8_t mA = 20, bool disableNtc = true);
5655

5756
/**

0 commit comments

Comments
 (0)