SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
PmicChargerBase.hpp
Go to the documentation of this file.
1
51#pragma once
52
53#include <stdint.h>
54
59{
60public:
66 enum class ChargingStatus : uint8_t {
67 NO_CHARGING = 0,
68 PRE_CHARGE = 1,
69 FAST_CHARGE = 2,
70 TERMINATION = 3,
71 UNKNOWN = 0xFF
72 };
73
77 virtual ~PmicChargerBase() = default;
78
87 virtual bool enableCharging(bool enable) = 0;
88
96 virtual bool isCharging() = 0;
97
110 virtual bool setPreChargeCurrent(uint16_t mA) = 0;
111
118 virtual uint16_t getPreChargeCurrent() = 0;
119
132 virtual bool setFastChargeCurrent(uint16_t mA) = 0;
133
140 virtual uint16_t getFastChargeCurrent() = 0;
141
151 virtual bool setTerminationCurrent(uint16_t mA) = 0;
152
159 virtual uint16_t getTerminationCurrent() = 0;
160
171 virtual bool setChargeVoltage(uint16_t mV) = 0;
172
179 virtual uint16_t getChargeVoltage() = 0;
180
187 struct Status {
188 bool online = false;
189 bool vbusPresent = false;
190 bool batteryPresent = false;
191 bool charging = false;
192 bool chargeDone = false;
193 bool fault = false;
194 uint32_t faultCode = 0;
196 };
197
204 virtual Status getStatus() = 0;
205};
PMIC charger capability interface.
virtual uint16_t getPreChargeCurrent()=0
Get pre-charge current setting.
virtual bool enableCharging(bool enable)=0
Enable or disable charging.
virtual bool isCharging()=0
Check whether charger is currently charging.
virtual bool setChargeVoltage(uint16_t mV)=0
Set charge voltage (CV mode voltage)
virtual Status getStatus()=0
Get current charger status.
ChargingStatus
Charging status enumeration.
@ NO_CHARGING
Not charging, battery idle or disconnected.
@ PRE_CHARGE
Pre-charge phase (low current for weak battery)
@ UNKNOWN
Unable to determine status.
@ TERMINATION
Charging terminated (battery full)
@ FAST_CHARGE
Fast charge phase (constant current)
virtual bool setFastChargeCurrent(uint16_t mA)=0
Set fast charge (constant-current) current.
virtual uint16_t getChargeVoltage()=0
Get charge voltage setting.
virtual uint16_t getFastChargeCurrent()=0
Get fast charge current setting.
virtual bool setTerminationCurrent(uint16_t mA)=0
Set termination current.
virtual uint16_t getTerminationCurrent()=0
Get termination current setting.
virtual ~PmicChargerBase()=default
Virtual destructor.
virtual bool setPreChargeCurrent(uint16_t mA)=0
Set pre-charge current.
Charger status structure.
bool vbusPresent
VBUS detected / good (USB power present)
bool chargeDone
Charge termination/done (battery full)
uint32_t faultCode
Optional raw fault code for diagnostics.
bool fault
Any fault latched/active.
bool charging
Charging state (coarse: true if in precharge/fastcharge)
bool batteryPresent
Battery present and detected.
ChargingStatus chargingStatus
Charging status enumeration.
bool online
PMIC reachable / initialized.