@@ -193,35 +193,38 @@ static inline void enable_battery_charging() {
193
193
PERIPH_WIRE.disableWIRE ();
194
194
}
195
195
196
- static inline void disable_battery_charging ( ) {
196
+ static inline void disable_battery_fet ( bool disabled ) {
197
197
PERIPH_WIRE.initMasterWIRE (100000 );
198
198
PERIPH_WIRE.enableWIRE ();
199
199
pinPeripheral (PIN_WIRE_SDA, g_APinDescription[PIN_WIRE_SDA].ulPinType );
200
200
pinPeripheral (PIN_WIRE_SCL, g_APinDescription[PIN_WIRE_SCL].ulPinType );
201
201
202
202
PERIPH_WIRE.startTransmissionWIRE ( PMIC_ADDRESS, WIRE_WRITE_FLAG );
203
203
PERIPH_WIRE.sendDataMasterWIRE (PMIC_REG07);
204
- PERIPH_WIRE.sendDataMasterWIRE (0x2B ); // Charge Battery + Minimum System Voltage 3.5V
204
+ // No D+/D– detection + Safety timer not slowed by 2X during input DPM or thermal regulation +
205
+ // BAT fet disabled/enabled + charge and bat fault INT
206
+ PERIPH_WIRE.sendDataMasterWIRE (0x0B | (disabled ? 0x20 : 0x00 ));
205
207
PERIPH_WIRE.prepareCommandBitsWire (WIRE_MASTER_ACT_STOP);
206
208
207
209
PERIPH_WIRE.disableWIRE ();
208
210
}
209
- #else
210
211
211
212
#endif
212
213
213
214
void initVariant () {
215
+ #if defined(USE_BQ24195L_PMIC)
214
216
pinMode (ADC_BATTERY, OUTPUT);
215
217
digitalWrite (ADC_BATTERY, LOW);
216
218
delay (10 );
217
219
pinMode (ADC_BATTERY, INPUT);
218
220
delay (100 );
219
221
220
- if (analogRead (ADC_BATTERY) > 600 ) {
222
+ bool batteryPresent = analogRead (ADC_BATTERY) > 600 ;
223
+ if (batteryPresent) {
221
224
enable_battery_charging ();
222
- } else {
223
- disable_battery_charging ();
224
225
}
226
+ disable_battery_fet (!batteryPresent);
227
+ #endif
225
228
226
229
// Workaround for RTS not being controlled correctly
227
230
pinMode (GSM_RTS, OUTPUT);
0 commit comments