Zephyr API 3.6.99
Loading...
Searching...
No Matches
Charger Interface

Charger Interface . More...

Data Structures

struct  charger_current_notifier
 The input current thresholds for the charger to notify the system. More...
 
union  charger_propval
 container for a charger_property value More...
 
struct  charger_driver_api
 Charging device API. More...
 

Typedefs

typedef uint16_t charger_prop_t
 A charger property's identifier.
 
typedef void(* charger_status_notifier_t) (enum charger_status status)
 The charger status change callback to notify the system.
 
typedef void(* charger_online_notifier_t) (enum charger_online online)
 The charger online change callback to notify the system.
 
typedef int(* charger_get_property_t) (const struct device *dev, const charger_prop_t prop, union charger_propval *val)
 Callback API for getting a charger property.
 
typedef int(* charger_set_property_t) (const struct device *dev, const charger_prop_t prop, const union charger_propval *val)
 Callback API for setting a charger property.
 
typedef int(* charger_charge_enable_t) (const struct device *dev, const bool enable)
 Callback API enabling or disabling a charge cycle.
 

Enumerations

enum  charger_property {
  CHARGER_PROP_ONLINE = 0 , CHARGER_PROP_PRESENT , CHARGER_PROP_STATUS , CHARGER_PROP_CHARGE_TYPE ,
  CHARGER_PROP_HEALTH , CHARGER_PROP_CONSTANT_CHARGE_CURRENT_UA , CHARGER_PROP_PRECHARGE_CURRENT_UA , CHARGER_PROP_CHARGE_TERM_CURRENT_UA ,
  CHARGER_PROP_CONSTANT_CHARGE_VOLTAGE_UV , CHARGER_PROP_INPUT_REGULATION_CURRENT_UA , CHARGER_PROP_INPUT_REGULATION_VOLTAGE_UV , CHARGER_PROP_INPUT_CURRENT_NOTIFICATION ,
  CHARGER_PROP_DISCHARGE_CURRENT_NOTIFICATION , CHARGER_PROP_SYSTEM_VOLTAGE_NOTIFICATION_UV , CHARGER_PROP_STATUS_NOTIFICATION , CHARGER_PROP_ONLINE_NOTIFICATION ,
  CHARGER_PROP_COMMON_COUNT , CHARGER_PROP_CUSTOM_BEGIN = CHARGER_PROP_COMMON_COUNT + 1 , CHARGER_PROP_MAX = UINT16_MAX
}
 Runtime Dynamic Battery Parameters. More...
 
enum  charger_online { CHARGER_ONLINE_OFFLINE = 0 , CHARGER_ONLINE_FIXED , CHARGER_ONLINE_PROGRAMMABLE }
 External supply states. More...
 
enum  charger_status {
  CHARGER_STATUS_UNKNOWN = 0 , CHARGER_STATUS_CHARGING , CHARGER_STATUS_DISCHARGING , CHARGER_STATUS_NOT_CHARGING ,
  CHARGER_STATUS_FULL
}
 Charging states. More...
 
enum  charger_charge_type {
  CHARGER_CHARGE_TYPE_UNKNOWN = 0 , CHARGER_CHARGE_TYPE_NONE , CHARGER_CHARGE_TYPE_TRICKLE , CHARGER_CHARGE_TYPE_FAST ,
  CHARGER_CHARGE_TYPE_STANDARD , CHARGER_CHARGE_TYPE_ADAPTIVE , CHARGER_CHARGE_TYPE_LONGLIFE , CHARGER_CHARGE_TYPE_BYPASS
}
 Charge algorithm types. More...
 
enum  charger_health {
  CHARGER_HEALTH_UNKNOWN = 0 , CHARGER_HEALTH_GOOD , CHARGER_HEALTH_OVERHEAT , CHARGER_HEALTH_OVERVOLTAGE ,
  CHARGER_HEALTH_UNSPEC_FAILURE , CHARGER_HEALTH_COLD , CHARGER_HEALTH_WATCHDOG_TIMER_EXPIRE , CHARGER_HEALTH_SAFETY_TIMER_EXPIRE ,
  CHARGER_HEALTH_CALIBRATION_REQUIRED , CHARGER_HEALTH_WARM , CHARGER_HEALTH_COOL , CHARGER_HEALTH_HOT ,
  CHARGER_HEALTH_NO_BATTERY
}
 Charger health conditions. More...
 
enum  charger_notification_severity { CHARGER_SEVERITY_PEAK = 0 , CHARGER_SEVERITY_CRITICAL , CHARGER_SEVERITY_WARNING }
 Charger severity levels for system notifications. More...
 

Functions

int charger_get_prop (const struct device *dev, const charger_prop_t prop, union charger_propval *val)
 Fetch a battery charger property.
 
int charger_set_prop (const struct device *dev, const charger_prop_t prop, const union charger_propval *val)
 Set a battery charger property.
 
int charger_charge_enable (const struct device *dev, const bool enable)
 Enable or disable a charge cycle.
 

Detailed Description

Charger Interface .

Typedef Documentation

◆ charger_charge_enable_t

typedef int(* charger_charge_enable_t) (const struct device *dev, const bool enable)

#include <zephyr/drivers/charger.h>

Callback API enabling or disabling a charge cycle.

See charger_charge_enable() for argument description

◆ charger_get_property_t

typedef int(* charger_get_property_t) (const struct device *dev, const charger_prop_t prop, union charger_propval *val)

#include <zephyr/drivers/charger.h>

Callback API for getting a charger property.

See charger_get_property() for argument description

◆ charger_online_notifier_t

typedef void(* charger_online_notifier_t) (enum charger_online online)

#include <zephyr/drivers/charger.h>

The charger online change callback to notify the system.

Parameters
onlineCurrent external supply state

◆ charger_prop_t

#include <zephyr/drivers/charger.h>

A charger property's identifier.

See charger_property for a list of identifiers

◆ charger_set_property_t

typedef int(* charger_set_property_t) (const struct device *dev, const charger_prop_t prop, const union charger_propval *val)

#include <zephyr/drivers/charger.h>

Callback API for setting a charger property.

See charger_set_property() for argument description

◆ charger_status_notifier_t

typedef void(* charger_status_notifier_t) (enum charger_status status)

#include <zephyr/drivers/charger.h>

The charger status change callback to notify the system.

Parameters
statusCurrent charging state

Enumeration Type Documentation

◆ charger_charge_type

#include <zephyr/drivers/charger.h>

Charge algorithm types.

Enumerator
CHARGER_CHARGE_TYPE_UNKNOWN 

Charge type is unknown.

CHARGER_CHARGE_TYPE_NONE 

Charging is not occurring.

CHARGER_CHARGE_TYPE_TRICKLE 

Charging is occurring at the slowest desired charge rate, typically for battery detection or preconditioning.

CHARGER_CHARGE_TYPE_FAST 

Charging is occurring at the fastest desired charge rate.

CHARGER_CHARGE_TYPE_STANDARD 

Charging is occurring at a moderate charge rate.

CHARGER_CHARGE_TYPE_ADAPTIVE 
CHARGER_CHARGE_TYPE_LONGLIFE 
CHARGER_CHARGE_TYPE_BYPASS 

◆ charger_health

#include <zephyr/drivers/charger.h>

Charger health conditions.

These conditions determine the ability to, or the rate of, charge

Enumerator
CHARGER_HEALTH_UNKNOWN 

Charger health condition is unknown.

CHARGER_HEALTH_GOOD 

Charger health condition is good.

CHARGER_HEALTH_OVERHEAT 

The charger device is overheated.

CHARGER_HEALTH_OVERVOLTAGE 

The battery voltage has exceeded its overvoltage threshold.

CHARGER_HEALTH_UNSPEC_FAILURE 

The battery or charger device is experiencing an unspecified failure.

CHARGER_HEALTH_COLD 

The battery temperature is below the "cold" threshold.

CHARGER_HEALTH_WATCHDOG_TIMER_EXPIRE 

The charger device's watchdog timer has expired.

CHARGER_HEALTH_SAFETY_TIMER_EXPIRE 

The charger device's safety timer has expired.

CHARGER_HEALTH_CALIBRATION_REQUIRED 

The charger device requires calibration.

CHARGER_HEALTH_WARM 

The battery temperature is in the "warm" range.

CHARGER_HEALTH_COOL 

The battery temperature is in the "cool" range.

CHARGER_HEALTH_HOT 

The battery temperature is below the "hot" threshold.

CHARGER_HEALTH_NO_BATTERY 

The charger device does not detect a battery.

◆ charger_notification_severity

#include <zephyr/drivers/charger.h>

Charger severity levels for system notifications.

Enumerator
CHARGER_SEVERITY_PEAK 

Most severe level, typically triggered instantaneously.

CHARGER_SEVERITY_CRITICAL 

More severe than the warning level, less severe than peak.

CHARGER_SEVERITY_WARNING 

Base severity level.

◆ charger_online

#include <zephyr/drivers/charger.h>

External supply states.

Enumerator
CHARGER_ONLINE_OFFLINE 

External supply not present.

CHARGER_ONLINE_FIXED 

External supply is present and of fixed output.

CHARGER_ONLINE_PROGRAMMABLE 

External supply is present and of programmable output.

◆ charger_property

#include <zephyr/drivers/charger.h>

Runtime Dynamic Battery Parameters.

Enumerator
CHARGER_PROP_ONLINE 

Indicates if external supply is present for the charger.

Value should be of type enum charger_online

CHARGER_PROP_PRESENT 

Reports whether or not a battery is present.

Value should be of type bool

CHARGER_PROP_STATUS 

Represents the charging status of the charger.

Value should be of type enum charger_status

CHARGER_PROP_CHARGE_TYPE 

Represents the charging algo type of the charger.

Value should be of type enum charger_charge_type

CHARGER_PROP_HEALTH 

Represents the health of the charger.

Value should be of type enum charger_health

CHARGER_PROP_CONSTANT_CHARGE_CURRENT_UA 

Configuration of current sink used for charging in µA.

CHARGER_PROP_PRECHARGE_CURRENT_UA 

Configuration of current sink used for conditioning in µA.

CHARGER_PROP_CHARGE_TERM_CURRENT_UA 

Configuration of charge termination target in µA.

CHARGER_PROP_CONSTANT_CHARGE_VOLTAGE_UV 

Configuration of charge voltage regulation target in µV.

CHARGER_PROP_INPUT_REGULATION_CURRENT_UA 

Configuration of the input current regulation target in µA.

This value is a rising current threshold that is regulated by reducing the charge current output

CHARGER_PROP_INPUT_REGULATION_VOLTAGE_UV 

Configuration of the input voltage regulation target in µV.

This value is a falling voltage threshold that is regulated by reducing the charge current output

CHARGER_PROP_INPUT_CURRENT_NOTIFICATION 

Configuration to issue a notification to the system based on the input current level and timing.

Value should be of type struct charger_current_notifier

CHARGER_PROP_DISCHARGE_CURRENT_NOTIFICATION 

Configuration to issue a notification to the system based on the battery discharge current level and timing.

Value should be of type struct charger_current_notifier

CHARGER_PROP_SYSTEM_VOLTAGE_NOTIFICATION_UV 

Configuration of the falling system voltage threshold where a notification is issued to the system, measured in µV.

CHARGER_PROP_STATUS_NOTIFICATION 

Configuration to issue a notification to the system based on the charger status change.

Value should be of type charger_status_notifier_t

CHARGER_PROP_ONLINE_NOTIFICATION 

Configuration to issue a notification to the system based on the charger online change.

Value should be of type charger_online_notifier_t

CHARGER_PROP_COMMON_COUNT 

Reserved to demark end of common charger properties.

CHARGER_PROP_CUSTOM_BEGIN 

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

CHARGER_PROP_MAX 

Reserved to demark end of valid enum properties.

◆ charger_status

#include <zephyr/drivers/charger.h>

Charging states.

Enumerator
CHARGER_STATUS_UNKNOWN 

Charging device state is unknown.

CHARGER_STATUS_CHARGING 

Charging device is charging a battery.

CHARGER_STATUS_DISCHARGING 

Charging device is not able to charge a battery.

CHARGER_STATUS_NOT_CHARGING 

Charging device is not charging a battery.

CHARGER_STATUS_FULL 

The battery is full and the charging device will not attempt charging.

Function Documentation

◆ charger_charge_enable()

int charger_charge_enable ( const struct device * dev,
const bool enable )

#include <zephyr/drivers/charger.h>

Enable or disable a charge cycle.

Parameters
devPointer to the battery charger device
enabletrue enables a charge cycle, false disables a charge cycle
Return values
0if successful
-EIOif communication with the charger failed
-EINVALif the conditions for initiating charging are invalid

◆ charger_get_prop()

int charger_get_prop ( const struct device * dev,
const charger_prop_t prop,
union charger_propval * val )

#include <zephyr/drivers/charger.h>

Fetch a battery charger property.

Parameters
devPointer to the battery charger device
propCharger property to get
valPointer to charger_propval union
Return values
0if successful
<0 if getting property failed

◆ charger_set_prop()

int charger_set_prop ( const struct device * dev,
const charger_prop_t prop,
const union charger_propval * val )

#include <zephyr/drivers/charger.h>

Set a battery charger property.

Parameters
devPointer to the battery charger device
propCharger property to set
valPointer to charger_propval union
Return values
0if successful
<0 if setting property failed