summaryrefslogtreecommitdiff
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 @@
208 Usually application ports, and only 208 Usually application ports, and only
209 if the estimation is better that ours 209 if the estimation is better that ours
210 (which it probably is) */ 210 (which it probably is) */
211#define CURRENT_MEASURE 8 /* Target can report battery charge and/or
212 * discharge current */
211/* CONFIG_LCD */ 213/* CONFIG_LCD */
212#define LCD_SSD1815 1 /* as used by Sansa M200 and others */ 214#define LCD_SSD1815 1 /* as used by Sansa M200 and others */
213#define LCD_S1D15E06 3 /* as used by iRiver H100 series */ 215#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;
94#define BATT_AVE_SAMPLES 128 94#define BATT_AVE_SAMPLES 128
95#endif 95#endif
96 96
97#ifndef BATT_CURRENT_AVE_SAMPLES
98/* TODO may need tweaking */
99#define BATT_CURRENT_AVE_SAMPLES 16
100#endif
101
97#ifndef POWER_THREAD_STEP_TICKS 102#ifndef POWER_THREAD_STEP_TICKS
98/* 2HZ sample rate unless otherwise specified */ 103/* 2HZ sample rate unless otherwise specified */
99#define POWER_THREAD_STEP_TICKS (HZ/2) 104#define POWER_THREAD_STEP_TICKS (HZ/2)
@@ -118,6 +123,8 @@ int battery_current(void); /* battery current in milliamps
118int _battery_level(void); /* percent */ 123int _battery_level(void); /* percent */
119int _battery_time(void); /* minutes */ 124int _battery_time(void); /* minutes */
120int _battery_voltage(void); /* voltage in millivolts */ 125int _battery_voltage(void); /* voltage in millivolts */
126int _battery_current(void); /* (dis)charge current in milliamps */
127
121#if CONFIG_CHARGING >= CHARGING_TARGET 128#if CONFIG_CHARGING >= CHARGING_TARGET
122void powermgmt_init_target(void); 129void powermgmt_init_target(void);
123void charging_algorithm_close(void); 130void charging_algorithm_close(void);