Skip to content

Commit 50867e6

Browse files
committed
Apply style guide to enums
1 parent 80e009f commit 50867e6

File tree

2 files changed

+45
-40
lines changed

2 files changed

+45
-40
lines changed

src/Charger.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,26 +224,26 @@ ChargingState Charger::getState(){
224224
uint8_t reg_val = PMIC.readPMICreg(Register::CHARGER_CHG_SNS);
225225
switch (extractBits(reg_val, 0, 3)) {
226226
case 0:
227-
return ChargingState::PreCharge;
227+
return ChargingState::preCharge;
228228
case 1:
229-
return ChargingState::FastChargeConstantCurrent;
229+
return ChargingState::fastChargeConstantCurrent;
230230
case 2:
231-
return ChargingState::FastChargeConstantVoltage;
231+
return ChargingState::fastChargeConstantVoltage;
232232
case 3:
233-
return ChargingState::EndOfCharge;
233+
return ChargingState::endOfCharge;
234234
case 4:
235-
return ChargingState::Done;
235+
return ChargingState::done;
236236
case 6:
237-
return ChargingState::TimerFaultError;
237+
return ChargingState::timerFaultError;
238238
case 7:
239-
return ChargingState::ThermistorSuspendError;
239+
return ChargingState::thermistorSuspendError;
240240
case 8:
241-
return ChargingState::ChargerDisabled;
241+
return ChargingState::chargerDisabled;
242242
case 9:
243-
return ChargingState::BatteryOvervoltageError;
243+
return ChargingState::batteryOvervoltageError;
244244
case 12:
245-
return ChargingState::ChargerBypassed;
245+
return ChargingState::chargerBypassed;
246246
default:
247-
return ChargingState::None;
247+
return ChargingState::none;
248248
}
249249
}

src/Charger.h

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,75 +9,64 @@ typedef IEndOfCharge EndOfChargeCurrent;
99
typedef IInputCurrentLimit InputCurrentLimit;
1010

1111
/**
12-
* Enum representing different states of charging.
13-
* @see #None
14-
* @see #PreCharge
15-
* @see #FastChargeConstantCurrent
16-
* @see #FastChargeConstantVoltage
17-
* @see #EndOfCharge
18-
* @see #Done
19-
* @see #TimerFaultError
20-
* @see #ThermistorSuspendError
21-
* @see #ChargerDisabled
22-
* @see #BatteryOvervoltageError
23-
* @see #ChargerBypassed
12+
* Enum representing different states of charging.
2413
*/
2514

2615
enum class ChargingState {
2716
/**
2817
* Provided by the registers, not used in this API.
2918
*/
30-
None = -1,
19+
none = -1,
3120

3221
/**
3322
* First stage of the charging process, prepares battery for the charging process.
3423
*/
35-
PreCharge = 0,
24+
preCharge = 0,
3625

3726
/**
3827
* Second phase of the charging process where the battery is charging in constant current mode until it reaches the voltage where the it's considered fully charged. (4.2V)
3928
*/
40-
FastChargeConstantCurrent = 1,
29+
fastChargeConstantCurrent = 1,
4130

4231
/**
4332
* Third phase of the charging process where the battery is kept at the fully charged voltage and current is slowly decreased to the end of charge current.
4433
*/
45-
FastChargeConstantVoltage = 2,
34+
fastChargeConstantVoltage = 2,
4635

4736
/**
4837
* If the battery is still connected, the charger will ensure it's kept at 4.2V by topping up the voltage to avoid self discharge.
4938
*/
50-
EndOfCharge = 3,
39+
endOfCharge = 3,
5140

5241
/**
5342
* Battery is fully charged
5443
*/
55-
Done = 4,
44+
done = 4,
5645

5746
/**
5847
* The timer that is monitoring the charge status has encountered an error.
5948
*/
60-
TimerFaultError = 6,
49+
timerFaultError = 6,
6150

6251
/**
6352
* Charging was suspended due to overheating
6453
*/
65-
ThermistorSuspendError = 7,
54+
thermistorSuspendError = 7,
6655

6756
/**
6857
* Charger is disabled
6958
*/
70-
ChargerDisabled = 8,
59+
chargerDisabled = 8,
7160

7261
/**
7362
* Charging was suspended due to an overvoltage fault
7463
*/
75-
BatteryOvervoltageError = 9,
64+
batteryOvervoltageError = 9,
7665

7766
/**
7867
* The charger is bypassed completely and the USB voltage is powering the board
7968
*/
80-
ChargerBypassed = 12
69+
chargerBypassed = 12
8170
};
8271

8372
/**
@@ -131,9 +120,15 @@ class Charger {
131120

132121
/**
133122
* @brief Set the end-of-charge current.
134-
* The default end-of-charge current is set to 0.05A.
123+
* The charger IC determines when to terminate the charge cycle based on the current going into the battery
124+
* dropping below the given threshold during the constant voltage phase. At this point, the battery
125+
* is considered fully charged and charging is completed. If charge termination is disabled,
126+
* the charge current will naturally decay to 0mA, but this is rarely done in practice.
127+
* This is because the amount of charge going into the battery exponentially decreases during CV charging,
128+
* and it would take a significantly longer time to recharge the battery with a very little increase in capacity.
135129
* @param current End-of-charge current in milli amperes (mA).
136-
* Supported values: 5, 10, 20, 30, 50
130+
* The default end-of-charge current is set to 5 mA.
131+
* Supported values: 5, 10, 20, 30, 50
137132
* @return True if successful, false if an invalid value was provided or if the PMIC communication failed.
138133
*/
139134
bool setEndOfChargeCurrent(uint16_t current);
@@ -164,20 +159,30 @@ class Charger {
164159
* @brief Get the input current limit. It is a safeguard to prevent overcurrent when charging
165160
* respectively to the maximum current the power source can provide.
166161
*
167-
* This function returns the current limit of the input power source.
168-
*
169-
* @return The input current limit in amps.
162+
* @return The input current limit in milli amperes (mA).
170163
*/
171164
uint16_t getInputCurrentLimit();
172165

173166
/**
174167
* @brief Get the current charging status.
175168
* @return Charging status enum value (ChargingState).
169+
* The possible states are:
170+
* - none: Provided by the registers, not used in this API.
171+
* - preCharge: First stage of the charging process, prepares battery for the charging process.
172+
* - fastChargeConstantCurrent: Second phase of the charging process where the battery is charging in constant current mode until it reaches the voltage where the it's considered fully charged. (4.2V)
173+
* - fastChargeConstantVoltage: Third phase of the charging process where the battery is kept at the fully charged voltage and current is slowly decreased to the end of charge current.
174+
* - endOfCharge: If the battery is still connected, the charger will ensure it's kept at 4.2V by topping up the voltage to avoid self discharge.
175+
* - done: Battery is fully charged
176+
* - timerFaultError: The timer that is monitoring the charge status has encountered an error.
177+
* - thermistorSuspendError: Charging was suspended due to overheating
178+
* - chargerDisabled: Charger is disabled
179+
* - batteryOvervoltageError: Charging was suspended due to an overvoltage fault
180+
* - chargerBypassed: The charger is bypassed completely and the USB voltage is powering the board
176181
*/
177182
ChargingState getState();
178183

179184
/**
180-
* @brief Checks if the charger is enabled.
185+
* @brief Checks if the charger and thus charging is enabled.
181186
* By default, the charger is enabled.
182187
* @return true if the charger is enabled, false otherwise.
183188
*/

0 commit comments

Comments
 (0)