summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/charge_state_v2.c13
-rw-r--r--common/host_command_pd.c2
2 files changed, 11 insertions, 4 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index c37e8189f1..1b796c9c27 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -457,6 +457,15 @@ const struct batt_params *charger_current_battery_params(void)
return &curr.batt;
}
+void charger_init(void)
+{
+ /* Initialize current state */
+ memset(&curr, 0, sizeof(curr));
+ curr.batt.is_present = BP_NOT_SURE;
+ curr.desired_input_current = CONFIG_CHARGER_INPUT_CURRENT;
+}
+DECLARE_HOOK(HOOK_INIT, charger_init, HOOK_PRIO_DEFAULT);
+
/* Main loop */
void charger_task(void)
{
@@ -466,10 +475,6 @@ void charger_task(void)
/* Get the battery-specific values */
batt_info = battery_get_info();
- /* Initialize all the state */
- memset(&curr, 0, sizeof(curr));
- curr.batt.is_present = BP_NOT_SURE;
- curr.desired_input_current = CONFIG_CHARGER_INPUT_CURRENT;
prev_ac = prev_charge = -1;
state_machine_force_idle = 0;
shutdown_warning_time.val = 0UL;
diff --git a/common/host_command_pd.c b/common/host_command_pd.c
index 444e9e3288..252ade01b7 100644
--- a/common/host_command_pd.c
+++ b/common/host_command_pd.c
@@ -56,6 +56,8 @@ static void pd_exchange_status(void)
void pd_command_task(void)
{
+ /* On startup exchange status with the PD */
+ pd_exchange_status();
while (1) {
/* Wait for the next command event */