2020-12-02 13:47:13 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
2022-09-26 11:34:59 -04:00
|
|
|
#include "bq25896_reg.h"
|
|
|
|
|
|
2020-12-02 13:47:13 +03:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdint.h>
|
2022-01-05 19:10:18 +03:00
|
|
|
#include <furi_hal_i2c.h>
|
2020-12-02 13:47:13 +03:00
|
|
|
|
2021-03-24 12:35:33 +03:00
|
|
|
/** Initialize Driver */
|
2025-03-31 16:23:32 +01:00
|
|
|
bool bq25896_init(const FuriHalI2cBusHandle* handle);
|
2020-12-02 13:47:13 +03:00
|
|
|
|
2023-07-05 20:48:02 +04:00
|
|
|
/** Set boost lim*/
|
2025-03-31 16:23:32 +01:00
|
|
|
void bq25896_set_boost_lim(const FuriHalI2cBusHandle* handle, BoostLim boost_lim);
|
2023-07-05 20:48:02 +04:00
|
|
|
|
2021-03-24 12:35:33 +03:00
|
|
|
/** Send device into shipping mode */
|
2025-03-31 16:23:32 +01:00
|
|
|
void bq25896_poweroff(const FuriHalI2cBusHandle* handle);
|
2020-12-02 13:47:13 +03:00
|
|
|
|
2022-09-26 11:34:59 -04:00
|
|
|
/** Get charging status */
|
2025-03-31 16:23:32 +01:00
|
|
|
ChrgStat bq25896_get_charge_status(const FuriHalI2cBusHandle* handle);
|
2022-09-26 11:34:59 -04:00
|
|
|
|
2021-03-24 12:35:33 +03:00
|
|
|
/** Is currently charging */
|
2025-03-31 16:23:32 +01:00
|
|
|
bool bq25896_is_charging(const FuriHalI2cBusHandle* handle);
|
2020-12-02 13:47:13 +03:00
|
|
|
|
2022-09-26 11:34:59 -04:00
|
|
|
/** Is charging completed while connected to charger */
|
2025-03-31 16:23:32 +01:00
|
|
|
bool bq25896_is_charging_done(const FuriHalI2cBusHandle* handle);
|
2022-09-26 11:34:59 -04:00
|
|
|
|
2021-10-04 10:01:41 +03:00
|
|
|
/** Enable charging */
|
2025-03-31 16:23:32 +01:00
|
|
|
void bq25896_enable_charging(const FuriHalI2cBusHandle* handle);
|
2021-10-04 10:01:41 +03:00
|
|
|
|
|
|
|
|
/** Disable charging */
|
2025-03-31 16:23:32 +01:00
|
|
|
void bq25896_disable_charging(const FuriHalI2cBusHandle* handle);
|
2021-10-04 10:01:41 +03:00
|
|
|
|
2021-03-24 12:35:33 +03:00
|
|
|
/** Enable otg */
|
2025-03-31 16:23:32 +01:00
|
|
|
void bq25896_enable_otg(const FuriHalI2cBusHandle* handle);
|
2020-12-02 13:47:13 +03:00
|
|
|
|
2021-03-24 12:35:33 +03:00
|
|
|
/** Disable otg */
|
2025-03-31 16:23:32 +01:00
|
|
|
void bq25896_disable_otg(const FuriHalI2cBusHandle* handle);
|
2020-12-02 13:47:13 +03:00
|
|
|
|
2021-09-30 23:03:28 +03:00
|
|
|
/** Is otg enabled */
|
2025-03-31 16:23:32 +01:00
|
|
|
bool bq25896_is_otg_enabled(const FuriHalI2cBusHandle* handle);
|
2021-09-30 23:03:28 +03:00
|
|
|
|
2023-02-26 12:23:39 -05:00
|
|
|
/** Get VREG (charging limit) voltage in mV */
|
2025-03-31 16:23:32 +01:00
|
|
|
uint16_t bq25896_get_vreg_voltage(const FuriHalI2cBusHandle* handle);
|
2022-12-08 01:57:49 -05:00
|
|
|
|
2023-02-26 12:23:39 -05:00
|
|
|
/** Set VREG (charging limit) voltage in mV
|
2022-12-08 01:57:49 -05:00
|
|
|
*
|
|
|
|
|
* Valid range: 3840mV - 4208mV, in steps of 16mV
|
|
|
|
|
*/
|
2025-03-31 16:23:32 +01:00
|
|
|
void bq25896_set_vreg_voltage(const FuriHalI2cBusHandle* handle, uint16_t vreg_voltage);
|
2022-12-08 01:57:49 -05:00
|
|
|
|
2022-01-21 19:55:44 +03:00
|
|
|
/** Check OTG BOOST Fault status */
|
2025-03-31 16:23:32 +01:00
|
|
|
bool bq25896_check_otg_fault(const FuriHalI2cBusHandle* handle);
|
2022-01-21 19:55:44 +03:00
|
|
|
|
2021-03-24 12:35:33 +03:00
|
|
|
/** Get VBUS Voltage in mV */
|
2025-03-31 16:23:32 +01:00
|
|
|
uint16_t bq25896_get_vbus_voltage(const FuriHalI2cBusHandle* handle);
|
2020-12-02 13:47:13 +03:00
|
|
|
|
2021-03-24 12:35:33 +03:00
|
|
|
/** Get VSYS Voltage in mV */
|
2025-03-31 16:23:32 +01:00
|
|
|
uint16_t bq25896_get_vsys_voltage(const FuriHalI2cBusHandle* handle);
|
2020-12-02 13:47:13 +03:00
|
|
|
|
2021-03-24 12:35:33 +03:00
|
|
|
/** Get VBAT Voltage in mV */
|
2025-03-31 16:23:32 +01:00
|
|
|
uint16_t bq25896_get_vbat_voltage(const FuriHalI2cBusHandle* handle);
|
2020-12-02 13:47:13 +03:00
|
|
|
|
2021-03-24 12:35:33 +03:00
|
|
|
/** Get VBAT current in mA */
|
2025-03-31 16:23:32 +01:00
|
|
|
uint16_t bq25896_get_vbat_current(const FuriHalI2cBusHandle* handle);
|
2020-12-02 13:47:13 +03:00
|
|
|
|
2021-03-24 12:35:33 +03:00
|
|
|
/** Get NTC voltage in mpct of REGN */
|
2025-03-31 16:23:32 +01:00
|
|
|
uint32_t bq25896_get_ntc_mpct(const FuriHalI2cBusHandle* handle);
|