Battery and charger driver interface.
More...
Battery and charger driver interface.
Implemented by the PMIC driver. The battery state service builds state of charge and charging state on top of it.
◆ BatteryConstants
| Data Fields |
|
int32_t |
i_ua |
Battery current in microamperes. |
|
int32_t |
t_mc |
Battery temperature in millidegrees Celsius. |
|
int32_t |
v_mv |
Battery voltage in millivolts. |
◆ BatteryChargeStatus
Battery charge status.
| Enumerator |
|---|
| BatteryChargeStatusUnknown | Unknown charge status.
|
| BatteryChargeStatusComplete | Charging is complete, battery full.
|
| BatteryChargeStatusTrickle | Trickle charging.
|
| BatteryChargeStatusCC | Constant current charging.
|
| BatteryChargeStatusCV | Constant voltage charging.
|
◆ battery_charge_controller_thinks_we_are_charging()
| bool battery_charge_controller_thinks_we_are_charging |
( |
void |
| ) |
|
Check whether the charge controller reports charging.
This is the raw charger status, not the notion of charging used by the rest of the system, which comes from the battery state service. Always false while charging is forced off with battery_force_charge_enable().
- Returns
- True if the charge controller is charging.
◆ battery_charge_controller_thinks_we_are_charging_impl()
| bool battery_charge_controller_thinks_we_are_charging_impl |
( |
void |
| ) |
|
◆ battery_charge_status_get()
Get the charge status.
- Parameters
-
| [out] | status | Current charge status. |
- Return values
-
| 0 | Success. |
| negative | Error code on failure. |
◆ battery_force_charge_enable()
| void battery_force_charge_enable |
( |
bool |
is_charging | ) |
|
◆ battery_get_constants()
Measure battery voltage, current and temperature.
- Parameters
-
| [out] | constants | Measurements. |
- Return values
-
| 0 | Success. |
| negative | Error code on failure. |
◆ battery_get_millivolts()
| int battery_get_millivolts |
( |
void |
| ) |
|
Measure the battery voltage.
- Returns
- Battery voltage in millivolts, 0 on failure.
◆ battery_init()
| void battery_init |
( |
void |
| ) |
|
Initialize the battery driver.
◆ battery_is_usb_connected()
| bool battery_is_usb_connected |
( |
void |
| ) |
|
Check whether USB power is connected.
Always false while charging is forced off with battery_force_charge_enable().
- Returns
- True if USB power is present.
◆ battery_is_usb_connected_impl()
| bool battery_is_usb_connected_impl |
( |
void |
| ) |
|
◆ battery_set_charge_enable()
| void battery_set_charge_enable |
( |
bool |
charging_enabled | ) |
|
Enable or disable the charger.
- Parameters
-
| charging_enabled | True to allow charging. |
◆ battery_set_fast_charge()
| void battery_set_fast_charge |
( |
bool |
fast_charge_enabled | ) |
|
Enable or disable fast charging.
A no-op on chargers that manage the charge current themselves.
- Parameters
-
| fast_charge_enabled | True to allow fast charging. |