Skip to content

Commit c3a97f4

Browse files
authored
Merge pull request #786 from LeeLeahy2/no-mp2762a-charger
Build with COMPILE_MP2762A_CHARGER commented out
2 parents ccb09f3 + d67ea88 commit c3a97f4

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed

Firmware/RTK_Everywhere/Begin.ino

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,24 +1481,8 @@ void beginCharger()
14811481
{
14821482
// Set pre-charge defaults for the MP2762A
14831483
// See issue: https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/issues/240
1484-
if (mp2762Begin(i2c_0) == true)
1485-
{
1486-
// Resetting registers to defaults
1487-
mp2762registerReset();
1488-
1489-
// Setting FastCharge to 6.6V
1490-
mp2762setFastChargeVoltageMv(6600);
1491-
1492-
// Setting precharge current to 880mA
1493-
mp2762setPrechargeCurrentMa(880);
1494-
1495-
systemPrintln("Charger configuration complete");
1496-
online.batteryCharger_mp2762a = true;
1497-
}
1498-
else
1499-
{
1484+
if (mp2762Begin(i2c_0, 6600, 880) == false)
15001485
systemPrintln("MP2762A charger failed to initialize");
1501-
}
15021486
}
15031487
}
15041488

Firmware/RTK_Everywhere/Developer.ino

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,17 @@ void tiltUpdate() {}
287287

288288
#endif // COMPILE_IM19_IMU
289289

290+
//----------------------------------------
291+
// MP2762A Charger
292+
//----------------------------------------
293+
294+
#ifndef COMPILE_MP2762A_CHARGER
295+
bool mp2762Begin(TwoWire *i2cBus, uint16_t volts, uint16_t milliamps) {return false;}
296+
uint16_t mp2762getBatteryVoltageMv() {return 0;}
297+
uint8_t mp2762getChargeStatus() {return 0;}
298+
void mp2762resetSafetyTimer() {}
299+
#endif // COMPILE_MP2762A_CHARGER
300+
290301
//----------------------------------------
291302
// UM980
292303
//----------------------------------------

Firmware/RTK_Everywhere/MP2762A_Charger.ino

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Helper functions for the MP2762A Charger controller
33
*/
44

5+
#ifdef COMPILE_MP2762A_CHARGER
6+
57
const uint8_t mp2762deviceAddress = 0x5C;
68

79
#define MP2762A_PRECHARGE_CURRENT 0x03
@@ -19,11 +21,23 @@ const uint8_t mp2762deviceAddress = 0x5C;
1921
TwoWire *mp2762I2c = nullptr;
2022

2123
// Returns true if device acknowledges its address
22-
bool mp2762Begin(TwoWire *i2cBus)
24+
bool mp2762Begin(TwoWire *i2cBus, uint16_t volts, uint16_t milliamps)
2325
{
2426
if (i2cIsDevicePresent(i2cBus, mp2762deviceAddress) == false)
2527
return (false);
2628
mp2762I2c = i2cBus;
29+
30+
// Resetting registers to defaults
31+
mp2762registerReset();
32+
33+
// Setting FastCharge voltage
34+
mp2762setFastChargeVoltageMv(volts);
35+
36+
// Setting precharge current
37+
mp2762setPrechargeCurrentMa(milliamps);
38+
39+
systemPrintln("Charger configuration complete");
40+
online.batteryCharger_mp2762a = true;
2741
return (true);
2842
}
2943

@@ -225,3 +239,5 @@ bool mp2762writeRegister(uint8_t address, uint8_t value)
225239
}
226240
return (true);
227241
}
242+
243+
#endif // COMPILE_MP2762A_CHARGER

Firmware/RTK_Everywhere/RTK_Everywhere.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
#define COMPILE_IM19_IMU // Comment out to remove IM19_IMU functionality
112112
#define COMPILE_POINTPERFECT_LIBRARY // Comment out to remove PPL support
113113
#define COMPILE_BQ40Z50 // Comment out to remove BQ40Z50 functionality
114+
#define COMPILE_MP2762A_CHARGER // Comment out to remove MP2762A charger functionality
114115

115116
#if defined(COMPILE_WIFI) || defined(COMPILE_ETHERNET) || defined(COMPILE_CELLULAR)
116117
#define COMPILE_NETWORK

Firmware/RTK_Everywhere/check.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ sed -i 's|#define COMPILE_IM19_IMU|//#define COMPILE_IM19_IMU|' RTK_Everywhere.i
110110
make
111111
git reset --hard --quiet HEAD
112112

113+
# MP2762A Charger
114+
sed -i 's|#define COMPILE_MP2762A_CHARGER|//#define COMPILE_MP2762A_CHARGER|' RTK_Everywhere.ino
115+
make
116+
git reset --hard --quiet HEAD
117+
113118
# PointPerfect Library
114119
sed -i 's|#define COMPILE_POINTPERFECT_LIBRARY|//#define COMPILE_POINTPERFECT_LIBRARY|' RTK_Everywhere.ino
115120
make

0 commit comments

Comments
 (0)