Refactoring of load control and state machine

- State machine and control merged to one function
- Load states marked as deprecated, global error flags used instead
- Reduced duplicated code and made load control function easier to read
This commit is contained in:
Martin Jaeger
2019-11-11 09:35:26 +01:00
parent d1ff837c5e
commit f254c77ab6
13 changed files with 452 additions and 514 deletions
+5 -3
View File
@@ -76,9 +76,11 @@ void adc_alert_undervoltage_triggering()
adcval.battery_voltage = bat_conf.voltage_absolute_min - 0.1;
prepare_adc_readings(adcval);
adc_update_value(ADC_POS_V_BAT);
TEST_ASSERT_EQUAL(false, dev_stat.has_error(ERR_BAT_UNDERVOLTAGE));
TEST_ASSERT_EQUAL(false, dev_stat.has_error(ERR_LOAD_VOLTAGE_DIP));
adc_update_value(ADC_POS_V_BAT);
TEST_ASSERT_EQUAL(true, dev_stat.has_error(ERR_BAT_UNDERVOLTAGE));
load.control();
TEST_ASSERT_EQUAL(true, dev_stat.has_error(ERR_LOAD_VOLTAGE_DIP));
TEST_ASSERT_EQUAL(false, load.pgood);
TEST_ASSERT_EQUAL(LOAD_STATE_OFF_OVERCURRENT, load.state);
// reset values
@@ -163,4 +165,4 @@ void adc_tests()
RUN_TEST(adc_alert_overflow_prevention);
UNITY_END();
}
}