Call powermgmt_init_target() before polling the battery

In the old position of the call, the first battery reading would
be made before initializing the target's power management code.

If the target needs to initialize before giving a battery reading,
then the first reading would be wrong and the power thread might
inappropriately shut down based on a false zero reading.

The new position avoids forcing special-case logic onto the target
power management code.

Change-Id: I483cfabe30c6881d80a1094fd526fa0065523d19
This commit is contained in:
Aidan MacDonald 2021-03-16 12:06:18 +00:00 committed by Solomon Peachy
parent 1c54c5227b
commit 4d83f7a192

View file

@ -705,14 +705,14 @@ static void power_thread(void)
power_thread_inputs = power_input_status();
#endif
/* call target specific init now */
powermgmt_init_target();
/* initialize voltage averaging (if available) */
average_init();
/* get initial battery level value (in %) */
init_battery_percent();
/* get some initial data for the power curve */
collect_power_history();
/* call target specific init now */
powermgmt_init_target();
next_power_hist = current_tick + HZ*60;