Power: Also ask charger if charge done (#1378)

* power: Also ask charger if charge done
* F7: bump API Symbols version
* Lib: remove double include in bq25896.c

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Shane Synan 2022-09-26 11:34:59 -04:00 committed by GitHub
parent 3e3a167764
commit 9f501034c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 5 deletions

View File

@ -96,7 +96,7 @@ void power_free(Power* power) {
static void power_check_charging_state(Power* power) {
if(furi_hal_power_is_charging()) {
if(power->info.charge == 100) {
if((power->info.charge == 100) || (furi_hal_power_is_charging_done())) {
if(power->state != PowerStateCharged) {
notification_internal_message(power->notification, &sequence_charged);
power->state = PowerStateCharged;

View File

@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,1.11,,
Version,+,1.12,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/cli/cli.h,,
Header,+,applications/services/cli/cli_vcp.h,,
@ -1141,6 +1141,7 @@ Function,+,furi_hal_power_insomnia_enter,void,
Function,+,furi_hal_power_insomnia_exit,void,
Function,-,furi_hal_power_insomnia_level,uint16_t,
Function,+,furi_hal_power_is_charging,_Bool,
Function,+,furi_hal_power_is_charging_done,_Bool,
Function,+,furi_hal_power_is_otg_enabled,_Bool,
Function,+,furi_hal_power_off,void,
Function,+,furi_hal_power_reset,void,

1 entry status name type params
2 Version + 1.11 1.12
3 Header + applications/services/bt/bt_service/bt.h
4 Header + applications/services/cli/cli.h
5 Header + applications/services/cli/cli_vcp.h
1141 Function + furi_hal_power_insomnia_exit void
1142 Function - furi_hal_power_insomnia_level uint16_t
1143 Function + furi_hal_power_is_charging _Bool
1144 Function + furi_hal_power_is_charging_done _Bool
1145 Function + furi_hal_power_is_otg_enabled _Bool
1146 Function + furi_hal_power_off void
1147 Function + furi_hal_power_reset void

View File

@ -266,6 +266,13 @@ bool furi_hal_power_is_charging() {
return ret;
}
bool furi_hal_power_is_charging_done() {
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
bool ret = bq25896_is_charging_done(&furi_hal_i2c_handle_power);
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
return ret;
}
void furi_hal_power_shutdown() {
furi_hal_power_insomnia_enter();

View File

@ -85,6 +85,12 @@ uint8_t furi_hal_power_get_bat_health_pct();
*/
bool furi_hal_power_is_charging();
/** Get charge complete status
*
* @return true if done charging and connected to charger
*/
bool furi_hal_power_is_charging_done();
/** Switch MCU to SHUTDOWN */
void furi_hal_power_shutdown();

View File

@ -1,5 +1,4 @@
#include "bq25896.h"
#include "bq25896_reg.h"
#include <stddef.h>
@ -81,7 +80,7 @@ void bq25896_poweroff(FuriHalI2cBusHandle* handle) {
handle, BQ25896_ADDRESS, 0x09, *(uint8_t*)&bq25896_regs.r09, BQ25896_I2C_TIMEOUT);
}
bool bq25896_is_charging(FuriHalI2cBusHandle* handle) {
ChrgStat bq25896_get_charge_status(FuriHalI2cBusHandle* handle) {
furi_hal_i2c_read_mem(
handle,
BQ25896_ADDRESS,
@ -91,7 +90,16 @@ bool bq25896_is_charging(FuriHalI2cBusHandle* handle) {
BQ25896_I2C_TIMEOUT);
furi_hal_i2c_read_reg_8(
handle, BQ25896_ADDRESS, 0x0B, (uint8_t*)&bq25896_regs.r0B, BQ25896_I2C_TIMEOUT);
return bq25896_regs.r0B.CHRG_STAT != ChrgStatNo;
return bq25896_regs.r0B.CHRG_STAT;
}
bool bq25896_is_charging(FuriHalI2cBusHandle* handle) {
// Include precharge, fast charging, and charging termination done as "charging"
return bq25896_get_charge_status(handle) != ChrgStatNo;
}
bool bq25896_is_charging_done(FuriHalI2cBusHandle* handle) {
return bq25896_get_charge_status(handle) == ChrgStatDone;
}
void bq25896_enable_charging(FuriHalI2cBusHandle* handle) {

View File

@ -1,5 +1,7 @@
#pragma once
#include "bq25896_reg.h"
#include <stdbool.h>
#include <stdint.h>
#include <furi_hal_i2c.h>
@ -10,9 +12,15 @@ void bq25896_init(FuriHalI2cBusHandle* handle);
/** Send device into shipping mode */
void bq25896_poweroff(FuriHalI2cBusHandle* handle);
/** Get charging status */
ChrgStat bq25896_get_charge_status(FuriHalI2cBusHandle* handle);
/** Is currently charging */
bool bq25896_is_charging(FuriHalI2cBusHandle* handle);
/** Is charging completed while connected to charger */
bool bq25896_is_charging_done(FuriHalI2cBusHandle* handle);
/** Enable charging */
void bq25896_enable_charging(FuriHalI2cBusHandle* handle);