@@ -12,6 +12,9 @@ static const uint8_t IP5306_REG_CHARGE_OUT_BIT = 0x10; // charge out bit
12
12
13
13
static const uint8_t IP5306_REG_CHG_DIG = 0x24 ; // charge current
14
14
static 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
15
18
16
19
static const uint8_t IP5306_REG_SYS_CTL0 = 0x00 ; // initialize
17
20
static const uint8_t IP5306_REG_SYS_CTL1 = 0x01 ; // sys control 1
@@ -67,49 +70,49 @@ void IP5306::setup() {
67
70
}
68
71
ESP_LOGI (TAG, " ip5306 setChargeVolt done" );
69
72
70
- if (!setPowerBoostOnOff (true )) {
73
+ if (!setPowerBoostOnOff (powerBoostOn_ )) {
71
74
ESP_LOGE (TAG, " setPowerBoostOnOff failed" );
72
75
this ->mark_failed ();
73
76
return ;
74
77
}
75
78
ESP_LOGI (TAG, " ip5306 setPowerBoostOnOff done" );
76
79
77
- if (!setPowerBoostSet (true )) {
80
+ if (!setPowerBoostSet (powerBoostSet_ )) {
78
81
ESP_LOGE (TAG, " setPowerBoostSet failed" );
79
82
this ->mark_failed ();
80
83
return ;
81
84
}
82
85
ESP_LOGI (TAG, " ip5306 setPowerBoostSet done" );
83
86
84
- if (!setPowerVin (true )) {
87
+ if (!setPowerVin (powerVin_ )) {
85
88
ESP_LOGE (TAG, " setPowerVin failed" );
86
89
this ->mark_failed ();
87
90
return ;
88
91
}
89
92
ESP_LOGI (TAG, " ip5306 setPowerVin done" );
90
93
91
- if (!enablePowerBtn (true )) {
94
+ if (!enablePowerBtn (enablePowerBtn_ )) {
92
95
ESP_LOGE (TAG, " enablePowerBtn failed" );
93
96
this ->mark_failed ();
94
97
return ;
95
98
}
96
99
ESP_LOGI (TAG, " ip5306 enablePowerBtn done" );
97
100
98
- if (!setPowerBoostKeepOn (true )) {
101
+ if (!setPowerBoostKeepOn (powerBoostKeepOn_ )) {
99
102
ESP_LOGE (TAG, " setPowerBoostKeepOn failed" );
100
103
this ->mark_failed ();
101
104
return ;
102
105
}
103
106
ESP_LOGI (TAG, " ip5306 setPowerBoostKeepOn done" );
104
107
105
- if (!setAutoBootOnLoad (false )) {
108
+ if (!setAutoBootOnLoad (autoBootOnLoad_ )) {
106
109
ESP_LOGE (TAG, " setAutoBootOnLoad failed" );
107
110
this ->mark_failed ();
108
111
return ;
109
112
}
110
113
ESP_LOGI (TAG, " ip5306 setAutoBootOnLoad done" );
111
114
112
- if (!setLowPowerShutdownTime (64 )) {
115
+ if (!setLowPowerShutdownTime (lowPowerShutdownTime_ )) {
113
116
ESP_LOGE (TAG, " setLowPowerShutdownTime failed" );
114
117
this ->mark_failed ();
115
118
return ;
@@ -121,25 +124,25 @@ void IP5306::completeChargingSetup() {
121
124
uint8_t data[1 ];
122
125
uint8_t value;
123
126
// 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) {
125
128
value = (data[0 ] & 0x3f ) | 0x00 ;
126
- this ->write_register (0x21 , &value, 1 );
129
+ this ->write_register (IP5306_REG_CHG_CTL1 , &value, 1 );
127
130
} else {
128
131
ESP_LOGE (TAG, " completeChargingSetup read 1 failed" );
129
132
}
130
133
131
134
// 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) {
133
136
value = (data[0 ] & 0xfc ) | 0x02 ;
134
- this ->write_register (0x22 , &value, 1 );
137
+ this ->write_register (IP5306_REG_CHG_CTL2 , &value, 1 );
135
138
} else {
136
139
ESP_LOGE (TAG, " completeChargingSetup read 2 failed" );
137
140
}
138
141
139
142
// 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) {
141
144
value = (data[0 ] & 0xdf ) | 0x20 ;
142
- this ->write_register (0x23 , &value, 1 );
145
+ this ->write_register (IP5306_REG_CHG_CTL3 , &value, 1 );
143
146
} else {
144
147
ESP_LOGE (TAG, " completeChargingSetup read 3 failed" );
145
148
}
0 commit comments