Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorあく <alleteam@gmail.com>2022-04-19 02:09:11 +0300
committerGitHub <noreply@github.com>2022-04-19 02:09:11 +0300
commit1623134a8287c04e90e1030062ea1acd55bde59a (patch)
treeea7e46416d7a4e6891cd5de57e28431eb8809313 /firmware
parent703844dd69818b9bc4ac376c7a5f24ed6b62037b (diff)
Build system improvements and bug fixes (#1129)
* Assets: recompile * Makefile: add debug_other to main makefile * Github: stop compilation if compiled assets not in sync with assets sources * Assets: recompile * Makefile: correct debug_other rule. Bt: prevent on system start hook from waiting for bt service * Power, FuriHal: gauge self check report * Loader: move on system start hook call to the beginning
Diffstat (limited to 'firmware')
-rw-r--r--firmware/targets/f7/furi_hal/furi_hal_power.c31
-rw-r--r--firmware/targets/furi_hal_include/furi_hal_power.h14
2 files changed, 40 insertions, 5 deletions
diff --git a/firmware/targets/f7/furi_hal/furi_hal_power.c b/firmware/targets/f7/furi_hal/furi_hal_power.c
index e5060536..2b78c7f0 100644
--- a/firmware/targets/f7/furi_hal/furi_hal_power.c
+++ b/firmware/targets/f7/furi_hal/furi_hal_power.c
@@ -21,6 +21,9 @@ typedef struct {
volatile uint8_t insomnia;
volatile uint8_t deep_insomnia;
volatile uint8_t suppress_charge;
+
+ uint8_t gauge_initialized;
+ uint8_t charger_initialized;
} FuriHalPower;
static volatile FuriHalPower furi_hal_power = {
@@ -84,6 +87,29 @@ void furi_hal_power_init() {
FURI_LOG_I(TAG, "Init OK");
}
+bool furi_hal_power_gauge_is_ok() {
+ bool ret = true;
+
+ BatteryStatus battery_status;
+ OperationStatus operation_status;
+
+ 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) {
+ ret = false;
+ } else {
+ ret &= battery_status.BATTPRES;
+ ret &= operation_status.INITCOMP;
+ ret &= (cedv.design_cap == bq27220_get_design_capacity(&furi_hal_i2c_handle_power));
+ }
+
+ furi_hal_i2c_release(&furi_hal_i2c_handle_power);
+
+ return ret;
+}
+
uint16_t furi_hal_power_insomnia_level() {
return furi_hal_power.insomnia;
}
@@ -315,10 +341,9 @@ void furi_hal_power_dump_state() {
} else {
// Operation status register
printf(
- "bq27220: CALMD: %d, SEC0: %d, SEC1: %d, EDV2: %d, VDQ: %d, INITCOMP: %d, SMTH: %d, BTPINT: %d, CFGUPDATE: %d\r\n",
+ "bq27220: CALMD: %d, SEC: %d, EDV2: %d, VDQ: %d, INITCOMP: %d, SMTH: %d, BTPINT: %d, CFGUPDATE: %d\r\n",
operation_status.CALMD,
- operation_status.SEC0,
- operation_status.SEC1,
+ operation_status.SEC,
operation_status.EDV2,
operation_status.VDQ,
operation_status.INITCOMP,
diff --git a/firmware/targets/furi_hal_include/furi_hal_power.h b/firmware/targets/furi_hal_include/furi_hal_power.h
index c55e3804..717f6570 100644
--- a/firmware/targets/furi_hal_include/furi_hal_power.h
+++ b/firmware/targets/furi_hal_include/furi_hal_power.h
@@ -19,10 +19,20 @@ typedef enum {
FuriHalPowerICFuelGauge,
} FuriHalPowerIC;
-/** Initialize drivers
- */
+/** Initialize drivers */
void furi_hal_power_init();
+/** Check if gauge is ok
+ *
+ * Verifies that:
+ * - gauge is alive
+ * - correct profile loaded
+ * - self diagnostic status is good
+ *
+ * @return true if gauge is ok
+ */
+bool furi_hal_power_gauge_is_ok();
+
/** Get current insomnia level
*
* @return insomnia level: 0 - no insomnia, >0 - insomnia, bearer count.