mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-09 05:49:09 -07:00
Merge branch 'dev' of https://github.com/flipperdevices/flipperzero-firmware into xfw-dev
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,34.2,,
|
||||
Version,+,34.3,,
|
||||
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
|
||||
Header,+,applications/main/archive/helpers/favorite_timeout.h,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
@@ -53,7 +53,6 @@ Header,+,firmware/targets/f7/furi_hal/furi_hal_idle_timer.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_interrupt.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_nfc.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_os.h,,
|
||||
Header,-,firmware/targets/f7/furi_hal/furi_hal_power_calibration.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_pwm.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_resources.h,,
|
||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_rfid.h,,
|
||||
@@ -1349,6 +1348,7 @@ 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_is_shutdown_requested,_Bool,
|
||||
Function,+,furi_hal_power_off,void,
|
||||
Function,+,furi_hal_power_reset,void,
|
||||
Function,+,furi_hal_power_set_battery_charge_voltage_limit,void,float
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <hw_conf.h>
|
||||
#include <bq27220.h>
|
||||
#include <bq27220_data_memory.h>
|
||||
#include <bq25896.h>
|
||||
|
||||
#include <furi.h>
|
||||
@@ -37,16 +38,18 @@ typedef struct {
|
||||
volatile uint8_t insomnia;
|
||||
volatile uint8_t suppress_charge;
|
||||
|
||||
uint8_t gauge_initialized;
|
||||
uint8_t charger_initialized;
|
||||
bool gauge_ok;
|
||||
bool charger_ok;
|
||||
} FuriHalPower;
|
||||
|
||||
static volatile FuriHalPower furi_hal_power = {
|
||||
.insomnia = 0,
|
||||
.suppress_charge = 0,
|
||||
.gauge_ok = false,
|
||||
.charger_ok = false,
|
||||
};
|
||||
|
||||
#include <furi_hal_power_calibration.h>
|
||||
extern const BQ27220DMData furi_hal_power_gauge_data_memory[];
|
||||
|
||||
void furi_hal_power_init() {
|
||||
#ifdef FURI_HAL_POWER_DEBUG
|
||||
@@ -63,8 +66,13 @@ void furi_hal_power_init() {
|
||||
LL_C2_PWR_SetPowerMode(FURI_HAL_POWER_STOP_MODE);
|
||||
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
bq27220_init(&furi_hal_i2c_handle_power, &cedv);
|
||||
bq25896_init(&furi_hal_i2c_handle_power);
|
||||
// Find and init gauge
|
||||
if(bq27220_init(&furi_hal_i2c_handle_power)) {
|
||||
furi_hal_power.gauge_ok = bq27220_apply_data_memory(
|
||||
&furi_hal_i2c_handle_power, furi_hal_power_gauge_data_memory);
|
||||
}
|
||||
// Find and init charger
|
||||
furi_hal_power.charger_ok = bq25896_init(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
@@ -78,14 +86,29 @@ bool furi_hal_power_gauge_is_ok() {
|
||||
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
|
||||
if(bq27220_get_battery_status(&furi_hal_i2c_handle_power, &battery_status) == BQ27220_ERROR ||
|
||||
bq27220_get_operation_status(&furi_hal_i2c_handle_power, &operation_status) ==
|
||||
BQ27220_ERROR) {
|
||||
if(!bq27220_get_battery_status(&furi_hal_i2c_handle_power, &battery_status) ||
|
||||
!bq27220_get_operation_status(&furi_hal_i2c_handle_power, &operation_status)) {
|
||||
ret = false;
|
||||
} else {
|
||||
ret &= battery_status.BATTPRES;
|
||||
ret &= operation_status.INITCOMP;
|
||||
ret &= (cedv.design_cap == bq27220_get_design_capacity(&furi_hal_i2c_handle_power));
|
||||
ret &= furi_hal_power.gauge_ok;
|
||||
}
|
||||
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool furi_hal_power_is_shutdown_requested() {
|
||||
bool ret = false;
|
||||
|
||||
BatteryStatus battery_status;
|
||||
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
|
||||
if(bq27220_get_battery_status(&furi_hal_i2c_handle_power, &battery_status) != BQ27220_ERROR) {
|
||||
ret = battery_status.SYSDWN;
|
||||
}
|
||||
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
@@ -576,9 +599,8 @@ void furi_hal_power_debug_get(PropertyValueCallback out, void* context) {
|
||||
|
||||
const uint32_t ntc_mpct = bq25896_get_ntc_mpct(&furi_hal_i2c_handle_power);
|
||||
|
||||
if(bq27220_get_battery_status(&furi_hal_i2c_handle_power, &battery_status) != BQ27220_ERROR &&
|
||||
bq27220_get_operation_status(&furi_hal_i2c_handle_power, &operation_status) !=
|
||||
BQ27220_ERROR) {
|
||||
if(bq27220_get_battery_status(&furi_hal_i2c_handle_power, &battery_status) &&
|
||||
bq27220_get_operation_status(&furi_hal_i2c_handle_power, &operation_status)) {
|
||||
property_value_out(&property_context, "%lu", 2, "charger", "ntc", ntc_mpct);
|
||||
property_value_out(&property_context, "%d", 2, "gauge", "calmd", operation_status.CALMD);
|
||||
property_value_out(&property_context, "%d", 2, "gauge", "sec", operation_status.SEC);
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
const ParamCEDV cedv = {
|
||||
.cedv_conf.gauge_conf =
|
||||
{
|
||||
.CCT = 1,
|
||||
.CSYNC = 0,
|
||||
.EDV_CMP = 0,
|
||||
.SC = 1,
|
||||
.FIXED_EDV0 = 1,
|
||||
.FCC_LIM = 1,
|
||||
.FC_FOR_VDQ = 1,
|
||||
.IGNORE_SD = 1,
|
||||
.SME0 = 0,
|
||||
},
|
||||
.full_charge_cap = 2101,
|
||||
.design_cap = 2101,
|
||||
.EDV0 = 3300,
|
||||
.EDV1 = 3321,
|
||||
.EDV2 = 3355,
|
||||
.EMF = 3679,
|
||||
.C0 = 430,
|
||||
.C1 = 0,
|
||||
.R1 = 408,
|
||||
.R0 = 334,
|
||||
.T0 = 4626,
|
||||
.TC = 11,
|
||||
.DOD0 = 4044,
|
||||
.DOD10 = 3905,
|
||||
.DOD20 = 3807,
|
||||
.DOD30 = 3718,
|
||||
.DOD40 = 3642,
|
||||
.DOD50 = 3585,
|
||||
.DOD60 = 3546,
|
||||
.DOD70 = 3514,
|
||||
.DOD80 = 3477,
|
||||
.DOD90 = 3411,
|
||||
.DOD100 = 3299,
|
||||
};
|
||||
149
firmware/targets/f7/furi_hal/furi_hal_power_config.c
Normal file
149
firmware/targets/f7/furi_hal/furi_hal_power_config.c
Normal file
@@ -0,0 +1,149 @@
|
||||
#include <bq27220_data_memory.h>
|
||||
|
||||
const BQ27220DMGaugingConfig furi_hal_power_gauge_data_memory_gauging_config = {
|
||||
.CCT = 1,
|
||||
.CSYNC = 0,
|
||||
.EDV_CMP = 0,
|
||||
.SC = 1,
|
||||
.FIXED_EDV0 = 1,
|
||||
.FCC_LIM = 1,
|
||||
.FC_FOR_VDQ = 1,
|
||||
.IGNORE_SD = 1,
|
||||
.SME0 = 0,
|
||||
};
|
||||
|
||||
const BQ27220DMData furi_hal_power_gauge_data_memory[] = {
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1GaugingConfig,
|
||||
.type = BQ27220DMTypePtr16,
|
||||
.value.u32 = (uint32_t)&furi_hal_power_gauge_data_memory_gauging_config,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1FullChargeCapacity,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 2100,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1DesignCapacity,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 2100,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1EMF,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 3679,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1C0,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 430,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1R0,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 334,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1T0,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 4626,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1R1,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 408,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1TC,
|
||||
.type = BQ27220DMTypeU8,
|
||||
.value.u8 = 11,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1C1,
|
||||
.type = BQ27220DMTypeU8,
|
||||
.value.u8 = 0,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1StartDOD0,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 4044,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1StartDOD10,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 3905,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1StartDOD20,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 3807,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1StartDOD30,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 3718,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1StartDOD40,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 3642,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1StartDOD50,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 3585,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1StartDOD60,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 3546,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1StartDOD70,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 3514,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1StartDOD80,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 3477,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1StartDOD90,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 3411,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1StartDOD100,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 3299,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1EDV0,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 3300,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1EDV1,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 3321,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressGasGaugingCEDVProfile1EDV2,
|
||||
.type = BQ27220DMTypeU16,
|
||||
.value.u16 = 3355,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressCalibrationCurrentDeadband,
|
||||
.type = BQ27220DMTypeU8,
|
||||
.value.u8 = 1,
|
||||
},
|
||||
{
|
||||
.address = BQ27220DMAddressConfigurationPowerSleepCurrent,
|
||||
.type = BQ27220DMTypeI16,
|
||||
.value.i16 = 1,
|
||||
},
|
||||
{
|
||||
.type = BQ27220DMTypeEnd,
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user