Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions Firmware/RTK_Everywhere/Begin.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1481,24 +1481,8 @@ void beginCharger()
{
// Set pre-charge defaults for the MP2762A
// See issue: https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/issues/240
if (mp2762Begin(i2c_0) == true)
{
// Resetting registers to defaults
mp2762registerReset();

// Setting FastCharge to 6.6V
mp2762setFastChargeVoltageMv(6600);

// Setting precharge current to 880mA
mp2762setPrechargeCurrentMa(880);

systemPrintln("Charger configuration complete");
online.batteryCharger_mp2762a = true;
}
else
{
if (mp2762Begin(i2c_0, 6600, 880) == false)
systemPrintln("MP2762A charger failed to initialize");
}
}
}

Expand Down
11 changes: 11 additions & 0 deletions Firmware/RTK_Everywhere/Developer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,17 @@ void tiltRequestStop() {}

#endif // COMPILE_IM19_IMU

//----------------------------------------
// MP2762A Charger
//----------------------------------------

#ifndef COMPILE_MP2762A_CHARGER
bool mp2762Begin(TwoWire *i2cBus, uint16_t volts, uint16_t milliamps) {return false;}
uint16_t mp2762getBatteryVoltageMv() {return 0;}
uint8_t mp2762getChargeStatus() {return 0;}
void mp2762resetSafetyTimer() {}
#endif // COMPILE_MP2762A_CHARGER

//----------------------------------------
// UM980
//----------------------------------------
Expand Down
18 changes: 17 additions & 1 deletion Firmware/RTK_Everywhere/MP2762A_Charger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Helper functions for the MP2762A Charger controller
*/

#ifdef COMPILE_MP2762A_CHARGER

const uint8_t mp2762deviceAddress = 0x5C;

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

// Returns true if device acknowledges its address
bool mp2762Begin(TwoWire *i2cBus)
bool mp2762Begin(TwoWire *i2cBus, uint16_t volts, uint16_t milliamps)
{
if (i2cIsDevicePresent(i2cBus, mp2762deviceAddress) == false)
return (false);
mp2762I2c = i2cBus;

// Resetting registers to defaults
mp2762registerReset();

// Setting FastCharge voltage
mp2762setFastChargeVoltageMv(volts);

// Setting precharge current
mp2762setPrechargeCurrentMa(milliamps);

systemPrintln("Charger configuration complete");
online.batteryCharger_mp2762a = true;
return (true);
}

Expand Down Expand Up @@ -225,3 +239,5 @@ bool mp2762writeRegister(uint8_t address, uint8_t value)
}
return (true);
}

#endif // COMPILE_MP2762A_CHARGER
1 change: 1 addition & 0 deletions Firmware/RTK_Everywhere/RTK_Everywhere.ino
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
#define COMPILE_IM19_IMU // Comment out to remove IM19_IMU functionality
#define COMPILE_POINTPERFECT_LIBRARY // Comment out to remove PPL support
#define COMPILE_BQ40Z50 // Comment out to remove BQ40Z50 functionality
#define COMPILE_MP2762A_CHARGER // Comment out to remove MP2762A charger functionality

#if defined(COMPILE_WIFI) || defined(COMPILE_ETHERNET) || defined(COMPILE_CELLULAR)
#define COMPILE_NETWORK
Expand Down
5 changes: 5 additions & 0 deletions Firmware/RTK_Everywhere/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ sed -i 's|#define COMPILE_IM19_IMU|//#define COMPILE_IM19_IMU|' RTK_Everywhere.i
make
git reset --hard --quiet HEAD

# MP2762A Charger
sed -i 's|#define COMPILE_MP2762A_CHARGER|//#define COMPILE_MP2762A_CHARGER|' RTK_Everywhere.ino
make
git reset --hard --quiet HEAD

# PointPerfect Library
sed -i 's|#define COMPILE_POINTPERFECT_LIBRARY|//#define COMPILE_POINTPERFECT_LIBRARY|' RTK_Everywhere.ino
make
Expand Down