summaryrefslogtreecommitdiffstats
path: root/firmware/export
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-11-30 14:16:13 +0000
committerAidan MacDonald <amachronic@protonmail.com>2021-12-23 11:39:58 +0000
commitad05c872fe1a0d925f478106bfb56e731f3ce53c (patch)
tree156bae0098029e193a9914b6c7049f31efa3805f /firmware/export
parent923f92cb12ee39364ddec340de140d126ced1347 (diff)
downloadrockbox-ad05c872fe1a0d925f478106bfb56e731f3ce53c.tar.gz
rockbox-ad05c872fe1a0d925f478106bfb56e731f3ce53c.zip
powermgmt: Add battery current measurement
This allows targets to report the actual discharging or charging current if they are able to. Change-Id: I0b538e6ac94346f1434e45f83c8da8c1260a53a3
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/config.h2
-rw-r--r--firmware/export/powermgmt.h7
2 files changed, 9 insertions, 0 deletions
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 17bc626a80..2ae7ef2c53 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -208,6 +208,8 @@
Usually application ports, and only
if the estimation is better that ours
(which it probably is) */
+#define CURRENT_MEASURE 8 /* Target can report battery charge and/or
+ * discharge current */
/* CONFIG_LCD */
#define LCD_SSD1815 1 /* as used by Sansa M200 and others */
#define LCD_S1D15E06 3 /* as used by iRiver H100 series */
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
index c6fc3d5bdf..9d4d4e06aa 100644
--- a/firmware/export/powermgmt.h
+++ b/firmware/export/powermgmt.h
@@ -94,6 +94,11 @@ void powermgmt_init(void) INIT_ATTR;
#define BATT_AVE_SAMPLES 128
#endif
+#ifndef BATT_CURRENT_AVE_SAMPLES
+/* TODO may need tweaking */
+#define BATT_CURRENT_AVE_SAMPLES 16
+#endif
+
#ifndef POWER_THREAD_STEP_TICKS
/* 2HZ sample rate unless otherwise specified */
#define POWER_THREAD_STEP_TICKS (HZ/2)
@@ -118,6 +123,8 @@ int battery_current(void); /* battery current in milliamps
int _battery_level(void); /* percent */
int _battery_time(void); /* minutes */
int _battery_voltage(void); /* voltage in millivolts */
+int _battery_current(void); /* (dis)charge current in milliamps */
+
#if CONFIG_CHARGING >= CHARGING_TARGET
void powermgmt_init_target(void);
void charging_algorithm_close(void);