PebbleOS
Loading...
Searching...
No Matches
Modules | Data Structures | Enumerations | Functions
Battery

Battery and charger driver interface. More...

Modules

 QEMU battery
 Battery state set from the QEMU host.
 

Data Structures

struct  BatteryConstants
 Battery measurements. More...
 

Enumerations

enum  BatteryChargeStatus {
  BatteryChargeStatusUnknown , BatteryChargeStatusComplete , BatteryChargeStatusTrickle , BatteryChargeStatusCC ,
  BatteryChargeStatusCV
}
 Battery charge status. More...
 

Functions

void battery_init (void)
 Initialize the battery driver.
 
int battery_get_millivolts (void)
 Measure the battery voltage.
 
int battery_get_constants (BatteryConstants *constants)
 Measure battery voltage, current and temperature.
 
bool battery_charge_controller_thinks_we_are_charging (void)
 Check whether the charge controller reports charging.
 
bool battery_is_usb_connected (void)
 Check whether USB power is connected.
 
void battery_set_charge_enable (bool charging_enabled)
 Enable or disable the charger.
 
void battery_set_fast_charge (bool fast_charge_enabled)
 Enable or disable fast charging.
 
bool battery_is_usb_connected_impl (void)
 Driver implementation of battery_is_usb_connected().
 
bool battery_charge_controller_thinks_we_are_charging_impl (void)
 Driver implementation of battery_charge_controller_thinks_we_are_charging().
 
void battery_force_charge_enable (bool is_charging)
 Force charging on or off.
 
int battery_charge_status_get (BatteryChargeStatus *status)
 Get the charge status.
 

Detailed Description

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.


Data Structure Documentation

◆ BatteryConstants

struct BatteryConstants

Battery measurements.

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.

Enumeration Type Documentation

◆ 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.

Function Documentation

◆ 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  )

Driver implementation of battery_charge_controller_thinks_we_are_charging().

Ignores battery_force_charge_enable().

Returns
True if the charge controller is charging.

◆ battery_charge_status_get()

int battery_charge_status_get ( BatteryChargeStatus *  status)

Get the charge status.

Parameters
[out]statusCurrent charge status.
Return values
0Success.
negativeError code on failure.

◆ battery_force_charge_enable()

void battery_force_charge_enable ( bool  is_charging)

Force charging on or off.

Enables or disables the charger. While forced off, battery_is_usb_connected() and battery_charge_controller_thinks_we_are_charging() report false.

Parameters
is_chargingTrue to allow charging, false to force it off.

◆ battery_get_constants()

int battery_get_constants ( BatteryConstants *  constants)

Measure battery voltage, current and temperature.

Parameters
[out]constantsMeasurements.
Return values
0Success.
negativeError 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  )

Driver implementation of battery_is_usb_connected().

Ignores battery_force_charge_enable().

Returns
True if USB power is present.

◆ battery_set_charge_enable()

void battery_set_charge_enable ( bool  charging_enabled)

Enable or disable the charger.

Parameters
charging_enabledTrue 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_enabledTrue to allow fast charging.