@@ -12,6 +12,9 @@ static const uint8_t IP5306_REG_CHARGE_OUT_BIT = 0x10; // charge out bit
1212
1313static const uint8_t IP5306_REG_CHG_DIG = 0x24 ; // charge current
1414static const uint8_t IP5306_REG_CHG_CTL0 = 0x20 ; // charge voltage
15+ static const uint8_t IP5306_REG_CHG_CTL1 = 0x21 ; // charge control
16+ static const uint8_t IP5306_REG_CHG_CTL2 = 0x22 ; // charge control
17+ static const uint8_t IP5306_REG_CHG_CTL3 = 0x23 ; // charge control
1518
1619static const uint8_t IP5306_REG_SYS_CTL0 = 0x00 ; // initialize
1720static const uint8_t IP5306_REG_SYS_CTL1 = 0x01 ; // sys control 1
@@ -67,49 +70,49 @@ void IP5306::setup() {
6770 }
6871 ESP_LOGI (TAG, " ip5306 setChargeVolt done" );
6972
70- if (!setPowerBoostOnOff (true )) {
73+ if (!setPowerBoostOnOff (powerBoostOn_ )) {
7174 ESP_LOGE (TAG, " setPowerBoostOnOff failed" );
7275 this ->mark_failed ();
7376 return ;
7477 }
7578 ESP_LOGI (TAG, " ip5306 setPowerBoostOnOff done" );
7679
77- if (!setPowerBoostSet (true )) {
80+ if (!setPowerBoostSet (powerBoostSet_ )) {
7881 ESP_LOGE (TAG, " setPowerBoostSet failed" );
7982 this ->mark_failed ();
8083 return ;
8184 }
8285 ESP_LOGI (TAG, " ip5306 setPowerBoostSet done" );
8386
84- if (!setPowerVin (true )) {
87+ if (!setPowerVin (powerVin_ )) {
8588 ESP_LOGE (TAG, " setPowerVin failed" );
8689 this ->mark_failed ();
8790 return ;
8891 }
8992 ESP_LOGI (TAG, " ip5306 setPowerVin done" );
9093
91- if (!enablePowerBtn (true )) {
94+ if (!enablePowerBtn (enablePowerBtn_ )) {
9295 ESP_LOGE (TAG, " enablePowerBtn failed" );
9396 this ->mark_failed ();
9497 return ;
9598 }
9699 ESP_LOGI (TAG, " ip5306 enablePowerBtn done" );
97100
98- if (!setPowerBoostKeepOn (true )) {
101+ if (!setPowerBoostKeepOn (powerBoostKeepOn_ )) {
99102 ESP_LOGE (TAG, " setPowerBoostKeepOn failed" );
100103 this ->mark_failed ();
101104 return ;
102105 }
103106 ESP_LOGI (TAG, " ip5306 setPowerBoostKeepOn done" );
104107
105- if (!setAutoBootOnLoad (false )) {
108+ if (!setAutoBootOnLoad (autoBootOnLoad_ )) {
106109 ESP_LOGE (TAG, " setAutoBootOnLoad failed" );
107110 this ->mark_failed ();
108111 return ;
109112 }
110113 ESP_LOGI (TAG, " ip5306 setAutoBootOnLoad done" );
111114
112- if (!setLowPowerShutdownTime (64 )) {
115+ if (!setLowPowerShutdownTime (lowPowerShutdownTime_ )) {
113116 ESP_LOGE (TAG, " setLowPowerShutdownTime failed" );
114117 this ->mark_failed ();
115118 return ;
@@ -121,25 +124,25 @@ void IP5306::completeChargingSetup() {
121124 uint8_t data[1 ];
122125 uint8_t value;
123126 // End charge current 200ma
124- if (this ->read_register (0x21 , data, 1 ) == i2c::ERROR_OK) {
127+ if (this ->read_register (IP5306_REG_CHG_CTL1 , data, 1 ) == i2c::ERROR_OK) {
125128 value = (data[0 ] & 0x3f ) | 0x00 ;
126- this ->write_register (0x21 , &value, 1 );
129+ this ->write_register (IP5306_REG_CHG_CTL1 , &value, 1 );
127130 } else {
128131 ESP_LOGE (TAG, " completeChargingSetup read 1 failed" );
129132 }
130133
131134 // Add volt 28mv
132- if (this ->read_register (0x22 , data, 1 ) == i2c::ERROR_OK) {
135+ if (this ->read_register (IP5306_REG_CHG_CTL2 , data, 1 ) == i2c::ERROR_OK) {
133136 value = (data[0 ] & 0xfc ) | 0x02 ;
134- this ->write_register (0x22 , &value, 1 );
137+ this ->write_register (IP5306_REG_CHG_CTL2 , &value, 1 );
135138 } else {
136139 ESP_LOGE (TAG, " completeChargingSetup read 2 failed" );
137140 }
138141
139142 // Vin charge CC
140- if (this ->read_register (0x23 , data, 1 ) == i2c::ERROR_OK) {
143+ if (this ->read_register (IP5306_REG_CHG_CTL3 , data, 1 ) == i2c::ERROR_OK) {
141144 value = (data[0 ] & 0xdf ) | 0x20 ;
142- this ->write_register (0x23 , &value, 1 );
145+ this ->write_register (IP5306_REG_CHG_CTL3 , &value, 1 );
143146 } else {
144147 ESP_LOGE (TAG, " completeChargingSetup read 3 failed" );
145148 }
0 commit comments