adp536x

The adp536x library provides an API to the ADP5360 power management integrated circuit (PMIC).

Implementation

The library accesses the features of the ADP5360 PMIC by conducting Inter-Integrated Circuit (I2C) transactions with its registers. Generic read, write, and masked write functions are private to the library. The feature-specific functions are available to the user.

Supported features

The library provides several functions to set operating parameters for the ADP5360 PMIC and for reading status values.

Requirements

An I2C interface is required to communicate with the ADP5360 PMIC.

Configuration

To enable the library, set the CONFIG_ADP536X Kconfig option to y in the project configuration file prj.conf.

Initialize the library using the adp536x_init() function and use the API to configure and read from the ADP5360 PMIC.

Dependencies

This library uses the I2C-capable hardware.

API documentation

Header file: include/adp536x
Source files: lib/adp536x/src

Following define VBUS current limit values, charging current values, and overcharge protection threshold values respectively:

group adp536x

Defines

ADP536X_VBUS_ILIM_50mA
ADP536X_VBUS_ILIM_100mA
ADP536X_VBUS_ILIM_150mA
ADP536X_VBUS_ILIM_200mA
ADP536X_VBUS_ILIM_250mA
ADP536X_VBUS_ILIM_300mA
ADP536X_VBUS_ILIM_400mA
ADP536X_VBUS_ILIM_500mA
ADP536X_CHG_CURRENT_10mA
ADP536X_CHG_CURRENT_50mA
ADP536X_CHG_CURRENT_100mA
ADP536X_CHG_CURRENT_150mA
ADP536X_CHG_CURRENT_200mA
ADP536X_CHG_CURRENT_250mA
ADP536X_CHG_CURRENT_300mA
ADP536X_CHG_CURRENT_320mA
ADP536X_OC_CHG_THRESHOLD_25mA
ADP536X_OC_CHG_THRESHOLD_50mA
ADP536X_OC_CHG_THRESHOLD_100mA
ADP536X_OC_CHG_THRESHOLD_150mA
ADP536X_OC_CHG_THRESHOLD_200mA
ADP536X_OC_CHG_THRESHOLD_250mA
ADP536X_OC_CHG_THRESHOLD_300mA
ADP536X_OC_CHG_THRESHOLD_400mA

Enums

enum adp536x_fg_enabled

Fuel gauge state

Values:

enumerator ADP566X_FG_DISABLED

Disable fuel gauge

enumerator ADP566X_FG_ENABLED

Enable fuel gauge

enum adp536x_fg_mode

Fuel gauge mode

Values:

enumerator ADP566X_FG_MODE_ACTIVE
enumerator ADP566X_FG_MODE_SLEEP

Fuel gauge is in active mode

Functions

int adp536x_init(const struct device *dev)

Initialize ADP536X.

Parameters
  • dev[in] Pointer to the I2C bus device.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_vbus_current_set(uint8_t value)

Set the VBUS current limit.

Parameters
  • value[in] The upper current threshold in LSB.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_charger_current_set(uint8_t value)

Set the charger current.

Parameters
  • value[in] The charger current in LSB.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_charger_termination_voltage_set(uint8_t value)

Set the charger termination voltage.

This function configures the maximum battery voltage where the charger remains active.

Parameters
  • value[in] The charger termination voltage.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_charging_enable(bool enable)

Enable charging.

Parameters
  • enable[in] The requested charger operation state.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_charger_status_1_read(uint8_t *buf)

Read the STATUS1 register.

Parameters
  • buf[out] The read value of the STATUS1 register.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_charger_status_2_read(uint8_t *buf)

Read the STATUS2 register.

Parameters
  • buf[out] The read value of the STATUS2 register.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_oc_chg_hiccup_set(bool enable)

Enable charge hiccup protection mode.

Parameters
  • enable[in] The requested hiccup protection state.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_oc_dis_hiccup_set(bool enable)

Enable discharge hiccup protection mode.

Parameters
  • enable[in] The requested hiccup protection state.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_buckbst_enable(bool enable)

Enable the buck/boost regulator.

Parameters
  • enable[in] The requested regulator operation state.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_buck_1v8_set(void)

Set the buck regulator to 1.8 V.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_buckbst_3v3_set(void)

Set the buck/boost regulator to 3.3 V.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_factory_reset(void)

Reset the device to its default values.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_oc_chg_current_set(uint8_t value)

Set the charge over-current threshold.

Parameters
  • value[in] The over-current threshold.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_buck_discharge_set(bool enable)

Set the buck discharge resistor status.

Parameters
  • enable[in] Boolean value to enable or disable the discharge resistor.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_fg_set_mode(enum adp536x_fg_enabled en, enum adp536x_fg_mode mode)

Set Fuel Gauge operating mode.

Parameters
  • en[in] Enable or disable the fuel gauge.

  • mode[in] Active or sleep mode.

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_fg_soc(uint8_t *percentage)

Read battery state of charge.

Parameters
  • percentage[out] Percentage of battery remaining

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.

int adp536x_fg_volts(uint16_t *millivolts)

Read battery voltage.

Parameters
  • millivolts[out] Battery voltage in millivolts

Return values

0 – If the operation was successful. Otherwise, a (negative) error code is returned.