Separate load and USB out, improve state handling
Identified issues: - The load output and USB charging port shared the same state machine, which did not allow to set different switch-off thresholds. - Load error codes were global, so it was not possible to have multiple load instances. This commit introduces load-specific error_flags, makes the LoadOutput class inherit from PowerPort (to improve code readability), separates the load driver better from higher level implementation and adds a second LoadOutput object for the USB charging port.
This commit is contained in:
+3
-2
@@ -15,6 +15,7 @@
|
||||
#include "pcb.h" // hardware-specific settings
|
||||
#include "config.h" // user-specific configuration
|
||||
#include "setup.h"
|
||||
#include "helper.h"
|
||||
|
||||
#include "half_bridge.h" // PWM generation for DC/DC converter
|
||||
#include "hardware.h" // hardware-related functions like load switch, LED control, watchdog, etc.
|
||||
@@ -72,7 +73,7 @@ void main(void)
|
||||
|
||||
while (1) {
|
||||
leds_update_1s();
|
||||
leds_update_soc(charger.soc, dev_stat.has_error(ERR_LOAD_LOW_SOC));
|
||||
leds_update_soc(charger.soc, flags_check(&load.error_flags, ERR_LOAD_SHEDDING));
|
||||
|
||||
eeprom_update();
|
||||
|
||||
@@ -120,7 +121,7 @@ void control_thread()
|
||||
#endif
|
||||
|
||||
lv_terminal.energy_balance();
|
||||
load_terminal.energy_balance();
|
||||
load.energy_balance();
|
||||
dev_stat.update_energy();
|
||||
dev_stat.update_min_max_values();
|
||||
charger.update_soc(&bat_conf);
|
||||
|
||||
Reference in New Issue
Block a user