Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #19 from cyberman54/patch-4
Browse files Browse the repository at this point in the history
bugfix setChargeControlCur() [issue #18]
  • Loading branch information
lewisxhe authored May 10, 2020
2 parents ffd77dd + 709404a commit 4e5783d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=AXP202X_Library
version=1.1.0
version=1.1.1
author=Lewis He
maintainer=Lewis He <[email protected]>
sentence=Arduino library for X-Power AXP202 chip
Expand Down
15 changes: 9 additions & 6 deletions src/axp20x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1777,16 +1777,19 @@ int AXP20X_Class::setChargeControlCur(uint16_t mA)
return AXP_NOT_INIT;
switch (_chip_id) {
case AXP202_CHIP_ID:
_readByte(AXP202_CHARGE1, 1, &val);
val &= 0b11110000;
mA -= 300;
val = mA / 100;
val |= (mA / 100);
_writeByte(AXP202_CHARGE1, 1, &val);
return AXP_PASS;
case AXP192_CHIP_ID:
case AXP173_CHIP_ID:
val = mA;
if(val > AXP1XX_CHARGE_CUR_1320MA){
val = AXP1XX_CHARGE_CUR_1320MA;
}
case AXP173_CHIP_ID:
_readByte(AXP202_CHARGE1, 1, &val);
val &= 0b11110000;
if(mA > AXP1XX_CHARGE_CUR_1320MA)
mA = AXP1XX_CHARGE_CUR_1320MA;
val |= mA;
_writeByte(AXP202_CHARGE1, 1, &val);
return AXP_PASS;
default:
Expand Down

0 comments on commit 4e5783d

Please sign in to comment.