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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user