Skip to content

Commit 8093d3a

Browse files
committed
chg error has status system error
1 parent e8a99db commit 8093d3a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/system/power.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ static void power_thread(void)
558558

559559
device_charged = charged; // TODO: timer on device_plugged could be used to infer charged state
560560

561+
static bool adc_abnormal = false;
561562
if (!power_init)
562563
{
563564
// log battery state once
@@ -568,7 +569,7 @@ static void power_thread(void)
568569
if (abnormal_reading)
569570
{
570571
LOG_ERR("Battery voltage reading is abnormal");
571-
set_status(SYS_STATUS_SYSTEM_ERROR, true);
572+
adc_abnormal = true;
572573
}
573574
set_regulator(SYS_REGULATOR_DCDC); // Switch to DCDC
574575
power_init = true;
@@ -604,6 +605,11 @@ static void power_thread(void)
604605

605606
connection_update_battery(battery_available, device_plugged, device_charged, calibrated_battery_pptt, battery_mV);
606607

608+
if ((adc_abnormal || chg_ret) && !get_status(SYS_STATUS_SYSTEM_ERROR))
609+
set_status(SYS_STATUS_SYSTEM_ERROR, true);
610+
else if (get_status(SYS_STATUS_SYSTEM_ERROR))
611+
set_status(SYS_STATUS_SYSTEM_ERROR, false);
612+
607613
if (chg_ret)
608614
set_led(SYS_LED_PATTERN_CRITICAL, SYS_LED_PRIORITY_CRITICAL);
609615
else

0 commit comments

Comments
 (0)