Skip to content

Commit 1d6b39b

Browse files
committed
Add comments
1 parent 8d761e7 commit 1d6b39b

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

examples/Charger/Charger.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
Usage:
1414
15-
1. Connect the Battery:
15+
1. Connect a Battery to the board
1616
1717
2. Upload the Sketch:
1818
- Open the provided sketch in the Arduino IDE.

examples/Standby_WakeFromPin/Standby_WakeFromPin.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ void setup() {
2929
board.enableWakeupFromPin();
3030
#endif
3131

32-
// TODO why is this needed? Why true?
32+
// TODO why is this needed? Why true? -> Peripherals still off after reset?
33+
// only necessary for C33
3334
board.setAllPeripheralsPower(true);
3435
// TODO why is this needed?
3536
charger.setEnabled(false);

src/Battery.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Battery::Battery(BatteryCharacteristics batteryCharacteristics) : characteristic
1111
}
1212

1313
bool Battery::begin(bool enforceReload) {
14+
// PMIC already initializes the I2C bus, so no need to call Wire.begin() for the fuel gauge
1415
if(PMIC.begin() != 0){
1516
return false;
1617
}
@@ -72,6 +73,7 @@ void Battery::configureBatteryCharacteristics(){
7273

7374
void Battery::releaseFromHibernation(){
7475
// See section "Soft-Wakeup" in user manual https://www.analog.com/media/en/technical-documentation/user-guides/max1726x-modelgauge-m5-ez-user-guide.pdf
76+
// TODO to preserve the hiberation config, probably better to only set bit 15 to 0
7577
writeRegister16Bits(this->wire, FUEL_GAUGE_ADDRESS, HIB_CFG_REG, 0x0); // Exit Hibernate Mode
7678
writeRegister16Bits(this->wire, FUEL_GAUGE_ADDRESS, SOFT_WAKEUP_REG, 0x90); // Wakes up the fuel gauge from hibernate mode to reduce the response time of the IC to configuration changes
7779
writeRegister16Bits(this->wire, FUEL_GAUGE_ADDRESS, SOFT_WAKEUP_REG, 0x0); // This command must be manually cleared (0x0000) afterward to keep proper fuel gauge timing

src/WireUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ static inline uint8_t getBit(TwoWire *wire, uint8_t address, uint8_t reg, uint8_
101101
* @param indexFrom The index of the first bit to replace starting from LSB (0)
102102
* @param indexTo The index of the last bit (included) to replace starting from LSB (0)
103103
*/
104+
// TODO switch order of parameters to conform with bitWrite()
104105
static inline void replaceRegisterBits(TwoWire *wire, uint8_t address, uint8_t reg, uint16_t data, uint16_t indexFrom, uint8_t indexTo) {
105106
uint16_t registerValue = readRegister16Bits(wire, address, reg);
106107

@@ -126,6 +127,7 @@ static inline void replaceRegisterBits(TwoWire *wire, uint8_t address, uint8_t r
126127
* @param data The new data (1 bit) to write to the register.
127128
* @param index The index of the bit to replace.
128129
*/
130+
// TODO switch order of parameters to conform with bitWrite()
129131
static inline void replaceRegisterBit(TwoWire *wire, uint8_t address, uint8_t reg, uint16_t data, uint16_t index) {
130132
replaceRegisterBits(wire, address, reg, data, index, index);
131133
}

0 commit comments

Comments
 (0)