Zephyr API Documentation  3.4.0
A Scalable Open Source RTOS
3.4.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Fuel Gauge Interface

Fuel Gauge Interface. More...

Data Structures

struct  fuel_gauge_get_property
 
struct  fuel_gauge_set_property
 
struct  fuel_gauge_get_buffer_property
 
struct  sbs_gauge_manufacturer_name
 
struct  sbs_gauge_device_name
 
struct  sbs_gauge_device_chemistry
 
struct  fuel_gauge_driver_api
 

Macros

#define SBS_GAUGE_MANUFACTURER_NAME_MAX_SIZE   20
 
#define SBS_GAUGE_DEVICE_NAME_MAX_SIZE   20
 
#define SBS_GAUGE_DEVICE_CHEMISTRY_MAX_SIZE   4
 

Typedefs

typedef uint16_t fuel_gauge_prop_t
 
typedef int(* fuel_gauge_get_property_t) (const struct device *dev, struct fuel_gauge_get_property *props, size_t props_len)
 Callback API for getting a fuel_gauge property.
 
typedef int(* fuel_gauge_set_property_t) (const struct device *dev, struct fuel_gauge_set_property *props, size_t props_len)
 Callback API for setting a fuel_gauge property.
 
typedef int(* fuel_gauge_get_buffer_property_t) (const struct device *dev, struct fuel_gauge_get_buffer_property *prop, void *dst, size_t dst_len)
 Callback API for getting a fuel_gauge buffer property.
 

Enumerations

enum  fuel_gauge_property {
  FUEL_GAUGE_AVG_CURRENT = 0 , FUEL_GAUGE_CURRENT , FUEL_GAUGE_CHARGE_CUTOFF , FUEL_GAUGE_CYCLE_COUNT ,
  FUEL_GAUGE_CONNECT_STATE , FUEL_GAUGE_FLAGS , FUEL_GAUGE_FULL_CHARGE_CAPACITY , FUEL_GAUGE_PRESENT_STATE ,
  FUEL_GAUGE_REMAINING_CAPACITY , FUEL_GAUGE_RUNTIME_TO_EMPTY , FUEL_GAUGE_RUNTIME_TO_FULL , FUEL_GAUGE_SBS_MFR_ACCESS ,
  FUEL_GAUGE_ABSOLUTE_STATE_OF_CHARGE , FUEL_GAUGE_RELATIVE_STATE_OF_CHARGE , FUEL_GAUGE_TEMPERATURE , FUEL_GAUGE_VOLTAGE ,
  FUEL_GAUGE_SBS_MODE , FUEL_GAUGE_CHARGE_CURRENT , FUEL_GAUGE_CHARGE_VOLTAGE , FUEL_GAUGE_STATUS ,
  FUEL_GAUGE_DESIGN_CAPACITY , FUEL_GAUGE_DESIGN_VOLTAGE , FUEL_GAUGE_SBS_ATRATE , FUEL_GAUGE_SBS_ATRATE_TIME_TO_FULL ,
  FUEL_GAUGE_SBS_ATRATE_TIME_TO_EMPTY , FUEL_GAUGE_SBS_ATRATE_OK , FUEL_GAUGE_SBS_REMAINING_CAPACITY_ALARM , FUEL_GAUGE_SBS_REMAINING_TIME_ALARM ,
  FUEL_GAUGE_MANUFACTURER_NAME , FUEL_GAUGE_DEVICE_NAME , FUEL_GAUGE_DEVICE_CHEMISTRY , FUEL_GAUGE_COMMON_COUNT ,
  FUEL_GAUGE_CUSTOM_BEGIN , FUEL_GAUGE_PROP_MAX = UINT16_MAX
}
 

Functions

int fuel_gauge_get_prop (const struct device *dev, struct fuel_gauge_get_property *props, size_t props_len)
 Fetch a battery fuel-gauge property.
 
int fuel_gauge_set_prop (const struct device *dev, struct fuel_gauge_set_property *props, size_t props_len)
 Set a battery fuel-gauge property.
 
int fuel_gauge_get_buffer_prop (const struct device *dev, struct fuel_gauge_get_buffer_property *prop, void *dst, size_t dst_len)
 Fetch a battery fuel-gauge buffer property.
 

Detailed Description

Fuel Gauge Interface.

Macro Definition Documentation

◆ SBS_GAUGE_DEVICE_CHEMISTRY_MAX_SIZE

#define SBS_GAUGE_DEVICE_CHEMISTRY_MAX_SIZE   4

◆ SBS_GAUGE_DEVICE_NAME_MAX_SIZE

#define SBS_GAUGE_DEVICE_NAME_MAX_SIZE   20

◆ SBS_GAUGE_MANUFACTURER_NAME_MAX_SIZE

#define SBS_GAUGE_MANUFACTURER_NAME_MAX_SIZE   20

#include <zephyr/drivers/fuel_gauge.h>

Data structures for reading SBS buffer properties

Typedef Documentation

◆ fuel_gauge_get_buffer_property_t

fuel_gauge_get_buffer_property_t

#include <zephyr/drivers/fuel_gauge.h>

Callback API for getting a fuel_gauge buffer property.

See fuel_gauge_get_buffer_property() for argument description

◆ fuel_gauge_get_property_t

fuel_gauge_get_property_t

#include <zephyr/drivers/fuel_gauge.h>

Callback API for getting a fuel_gauge property.

See fuel_gauge_get_property() for argument description

◆ fuel_gauge_prop_t

◆ fuel_gauge_set_property_t

fuel_gauge_set_property_t

#include <zephyr/drivers/fuel_gauge.h>

Callback API for setting a fuel_gauge property.

See fuel_gauge_set_property() for argument description

Enumeration Type Documentation

◆ fuel_gauge_property

#include <zephyr/drivers/fuel_gauge.h>

Enumerator
FUEL_GAUGE_AVG_CURRENT 

Runtime Dynamic Battery Parameters Provide a 1 minute average of the current on the battery. Does not check for flags or whether those values are bad readings. See driver instance header for details on implementation and how the average is calculated. Units in uA negative=discharging

FUEL_GAUGE_CURRENT 

Battery current (uA); negative=discharging

FUEL_GAUGE_CHARGE_CUTOFF 

Whether the battery underlying the fuel-gauge is cut off from charge

FUEL_GAUGE_CYCLE_COUNT 

Cycle count in 1/100ths (number of charge/discharge cycles)

FUEL_GAUGE_CONNECT_STATE 

Connect state of battery

FUEL_GAUGE_FLAGS 

General Error/Runtime Flags

FUEL_GAUGE_FULL_CHARGE_CAPACITY 

Full Charge Capacity in uAh (might change in some implementations to determine wear)

FUEL_GAUGE_PRESENT_STATE 

Is the battery physically present

FUEL_GAUGE_REMAINING_CAPACITY 

Remaining capacity in uAh

FUEL_GAUGE_RUNTIME_TO_EMPTY 

Remaining battery life time in minutes

FUEL_GAUGE_RUNTIME_TO_FULL 

Remaining time in minutes until battery reaches full charge

FUEL_GAUGE_SBS_MFR_ACCESS 

Retrieve word from SBS1.1 ManufactuerAccess

FUEL_GAUGE_ABSOLUTE_STATE_OF_CHARGE 

Absolute state of charge (percent, 0-100) - expressed as % of design capacity

FUEL_GAUGE_RELATIVE_STATE_OF_CHARGE 

Relative state of charge (percent, 0-100) - expressed as % of full charge capacity

FUEL_GAUGE_TEMPERATURE 

Temperature in 0.1 K

FUEL_GAUGE_VOLTAGE 

Battery voltage (uV)

FUEL_GAUGE_SBS_MODE 

Battery Mode (flags)

FUEL_GAUGE_CHARGE_CURRENT 

Battery desired Max Charging Current (mA)

FUEL_GAUGE_CHARGE_VOLTAGE 

Battery desired Max Charging Voltage (mV)

FUEL_GAUGE_STATUS 

Alarm, Status and Error codes (flags)

FUEL_GAUGE_DESIGN_CAPACITY 

Design Capacity (mAh or 10mWh)

FUEL_GAUGE_DESIGN_VOLTAGE 

Design Voltage (mV)

FUEL_GAUGE_SBS_ATRATE 

AtRate (mA or 10 mW)

FUEL_GAUGE_SBS_ATRATE_TIME_TO_FULL 

AtRateTimeToFull (minutes)

FUEL_GAUGE_SBS_ATRATE_TIME_TO_EMPTY 

AtRateTimeToEmpty (minutes)

FUEL_GAUGE_SBS_ATRATE_OK 

AtRateOK (boolean)

FUEL_GAUGE_SBS_REMAINING_CAPACITY_ALARM 

Remaining Capacity Alarm (mAh or 10mWh)

FUEL_GAUGE_SBS_REMAINING_TIME_ALARM 

Remaining Time Alarm (minutes)

FUEL_GAUGE_MANUFACTURER_NAME 

Manufacturer of pack (1 byte length + 20 bytes data)

FUEL_GAUGE_DEVICE_NAME 

Name of pack (1 byte length + 20 bytes data)

FUEL_GAUGE_DEVICE_CHEMISTRY 

Chemistry (1 byte length + 4 bytes data)

FUEL_GAUGE_COMMON_COUNT 

Reserved to demark end of common fuel gauge properties

FUEL_GAUGE_CUSTOM_BEGIN 

Reserved to demark downstream custom properties - use this value as the actual value may change over future versions of this API

FUEL_GAUGE_PROP_MAX 

Reserved to demark end of valid enum properties

Function Documentation

◆ fuel_gauge_get_buffer_prop()

int fuel_gauge_get_buffer_prop ( const struct device dev,
struct fuel_gauge_get_buffer_property prop,
void *  dst,
size_t  dst_len 
)

#include <zephyr/drivers/fuel_gauge.h>

Fetch a battery fuel-gauge buffer property.

Parameters
devPointer to the battery fuel-gauge device
proppointer to single fuel_gauge_get_buffer_property struct where the property struct field is set by the caller to determine what property is read from the fuel gauge device into the dst field.
dstbyte array or struct that will hold the buffer data that is read from the fuel gauge
dst_lenthe length of the destination array in bytes
Returns
return=0 if successful, return < 0 if getting property failed, return 0 on success

◆ fuel_gauge_get_prop()

int fuel_gauge_get_prop ( const struct device dev,
struct fuel_gauge_get_property props,
size_t  props_len 
)

#include <zephyr/drivers/fuel_gauge.h>

Fetch a battery fuel-gauge property.

Parameters
devPointer to the battery fuel-gauge device
propspointer to array of fuel_gauge_get_property struct where the property struct field is set by the caller to determine what property is read from the fuel gauge device into the fuel_gauge_get_property struct's value field. The props array maintains the same order of properties as it was given.
props_lennumber of properties in props array
Returns
return=0 if successful, return < 0 if getting all properties failed, return > 0 if some properties failed where return=number of failing properties.

◆ fuel_gauge_set_prop()

int fuel_gauge_set_prop ( const struct device dev,
struct fuel_gauge_set_property props,
size_t  props_len 
)

#include <zephyr/drivers/fuel_gauge.h>

Set a battery fuel-gauge property.

Parameters
devPointer to the battery fuel-gauge device
propspointer to array of fuel_gauge_set_property struct where the property struct field is set by the caller to determine what property is written to the fuel gauge device from the fuel_gauge_get_property struct's value field.
props_lennumber of properties in props array
Returns
return=0 if successful, return < 0 if setting all properties failed, return > 0 if some properties failed where return=number of failing properties.