112void control_OTG(
const uint16_t mv,
const uint16_t ma);
bool is_vbus_signal_detected()
Return true if the USB VBUS presence signal is active.
Definition: charger.cpp:436
bool is_vbus_powered()
Return true if voltage is detected on VBUS.
Definition: charger.cpp:432
void control_OTG(const uint16_t mv, const uint16_t ma)
Set the OTG control parameters. Set the parameters to zero to disable OTG mode.
Definition: charger.cpp:170
bool setup()
call once at program startup
Definition: charger.cpp:330
void shutdown()
Call when system goes to sleep.
Definition: charger.cpp:424
Charger_t get_state()
Return the latest known state of the charger.
Definition: charger.cpp:438
void set_enable_charge(const bool shouldCharge)
debug feature: enable/disable the charging process
Definition: charger.cpp:430
void loop()
call at every loop runs
Definition: charger.cpp:369
bool can_use_vbus_power()
Return true if we are allowed to use the VBUS power.
Definition: charger.cpp:434
Program scope.
Definition: control_fixed_modes.hpp:12
Store the charger characteristics.
Definition: charger.h:33
std::string softwareErrorMessage
Contain a more detailed error of a software error.
Definition: charger.h:98
ChargerStatus_t status
global high level charger status
Definition: charger.h:84
int16_t batteryCurrent_mA
battery current (> 0 charging, < 0 discharging)
Definition: charger.h:55
uint16_t batteryVoltage_mV
battery voltage
Definition: charger.h:53
std::string hardwareErrorMessage
Contain a more detailed error of an hardware error.
Definition: charger.h:96
uint16_t powerRail_mV
powerRail voltage (can be the same as VBUS in charge & OTG mode). Min value at 3200mV
Definition: charger.h:50
bool isChargeOkSignalHigh
True if we have a valid chargeOk signal from the component.
Definition: charger.h:37
bool is_effectivly_charging() const
Return true when the battery is truly charging.
Definition: charger.cpp:448
bool is_charge_finished() const
Return true if the charge is finished.
Definition: charger.cpp:446
bool is_charging() const
Return true when the status is charging or powered.
Definition: charger.cpp:440
uint16_t inputCurrent_mA
input current in VBUS side, in milliamps.
Definition: charger.h:45
std::string get_status_str() const
Return the status as a string.
Definition: charger.cpp:453
bool areMeasuresOk
everything below makes no sense if this is false
Definition: charger.h:35
ChargerStatus_t
Indicates a charger status soecific states.
Definition: charger.h:61
@ CHARGING
currently charging the batteries
@ POWER_DETECTED
charger detects power on the input
@ SLOW_CHARGING
charging but very slowly
@ INACTIVE
no input power, charger is down
@ ERROR_SOFTWARE
a software error was detected
@ CHARGE_FINISHED
charging process is done
@ ERROR_HARDWARE
critical: some hardware is faulty
@ ERROR_BATTERY_MISSING
battery not detected
@ UNINITIALIZED
not initialized yet
bool isInOtg
True if OTG is activated.
Definition: charger.h:39
uint16_t chargeCurrent_mA
charge current of the battery, in milliamps.
Definition: charger.h:47
uint32_t lastUpdateTime_ms
time of the last update of this struct.
Definition: charger.h:42