1
0
Fork 0
forked from len0rd/rockbox

powermgmt: Add battery current measurement

This allows targets to report the actual discharging or
charging current if they are able to.

Change-Id: I0b538e6ac94346f1434e45f83c8da8c1260a53a3
This commit is contained in:
Aidan MacDonald 2021-11-30 14:16:13 +00:00
parent 923f92cb12
commit ad05c872fe
4 changed files with 52 additions and 8 deletions

View file

@ -43,6 +43,7 @@ static bool charging = false;
static unsigned int batt_millivolts = BATT_MAXMVOLT;
static unsigned int batt_percent = 100;
static unsigned int batt_runtime = BATT_MAXRUNTIME;
static unsigned int batt_current = 0;
void powermgmt_init_target(void) {}
@ -97,6 +98,8 @@ static void battery_status_update(void)
batt_percent = (batt_millivolts - BATT_MINMVOLT) / (BATT_MAXMVOLT - BATT_MINMVOLT);
batt_runtime = batt_percent * BATT_MAXRUNTIME;
/* current is completely bogus... */
batt_current = charging ? BATT_CHARGE_STEP : BATT_DISCHARGE_STEP;
}
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = { 3200 };
@ -132,6 +135,14 @@ int _battery_time(void)
}
#endif
#if (CONFIG_BATTERY_MEASURE & CURRENT_MEASURE)
int _battery_current(void)
{
battery_status_update();
return batt_current;
}
#endif
#if CONFIG_CHARGING
unsigned int power_input_status(void)
{