summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorne Wuff <torne@wolfpuppy.org.uk>2009-11-03 20:35:04 +0000
committerTorne Wuff <torne@wolfpuppy.org.uk>2009-11-03 20:35:04 +0000
commit2d0af6f3c7f1a33337ab5d9498364149104fd346 (patch)
tree84109df61eae758cf6368e9b1e4d52a205502541
parent9c343fab5dca19e89488170e8076f2b9f255151f (diff)
downloadrockbox-2d0af6f3c7f1a33337ab5d9498364149104fd346.tar.gz
rockbox-2d0af6f3c7f1a33337ab5d9498364149104fd346.zip
FS#9728: Battery current measuring on the Video iPod
Patch by Boris Gjenero. Displays the current flowing into or out of the battery on the ipodvideo. Other ipods do not appear to have this ADC channel connected. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23500 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/debug_menu.c13
-rw-r--r--firmware/target/arm/ipod/adc-ipod-pcf.c4
-rw-r--r--firmware/target/arm/ipod/adc-target.h10
3 files changed, 24 insertions, 3 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index f9fb7a3bb7..4b80d81c55 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1125,6 +1125,9 @@ bool dbg_ports(void)
1125#ifdef ADC_ACCESSORY 1125#ifdef ADC_ACCESSORY
1126 lcd_putsf(0, line++, "ACCESSORY: %d", adc_read(ADC_ACCESSORY)); 1126 lcd_putsf(0, line++, "ACCESSORY: %d", adc_read(ADC_ACCESSORY));
1127#endif 1127#endif
1128#ifdef IPOD_VIDEO
1129 lcd_putsf(0, line++, "4066_ISTAT: %d", adc_read(ADC_4066_ISTAT));
1130#endif
1128 1131
1129#if defined(IPOD_ACCESSORY_PROTOCOL) 1132#if defined(IPOD_ACCESSORY_PROTOCOL)
1130extern unsigned char serbuf[]; 1133extern unsigned char serbuf[];
@@ -1529,6 +1532,16 @@ static bool view_battery(void)
1529 dock ? "enabled" : "disabled"); 1532 dock ? "enabled" : "disabled");
1530 lcd_putsf(0, 7, "Headphone: %s", 1533 lcd_putsf(0, 7, "Headphone: %s",
1531 headphone ? "connected" : "disconnected"); 1534 headphone ? "connected" : "disconnected");
1535#ifdef IPOD_VIDEO
1536 x = (adc_read(ADC_4066_ISTAT) * 2400) /
1537#if MEM == 64
1538 (1024 * 2);
1539#else
1540 (1024 * 3);
1541#endif
1542 lcd_putsf(0, 8, "Ibat: %d mA", x);
1543 lcd_putsf(0, 9, "Vbat * Ibat: %d mW", x * y / 1000);
1544#endif
1532#elif defined TOSHIBA_GIGABEAT_S 1545#elif defined TOSHIBA_GIGABEAT_S
1533 int line = 3; 1546 int line = 3;
1534 unsigned int st; 1547 unsigned int st;
diff --git a/firmware/target/arm/ipod/adc-ipod-pcf.c b/firmware/target/arm/ipod/adc-ipod-pcf.c
index e4a54e09f8..e60d8ebb8f 100644
--- a/firmware/target/arm/ipod/adc-ipod-pcf.c
+++ b/firmware/target/arm/ipod/adc-ipod-pcf.c
@@ -87,5 +87,9 @@ void adc_init(void)
87 adc_battery->timeout = 0; 87 adc_battery->timeout = 0;
88 adcdata[ADC_ACCESSORY].channelnum = 4; 88 adcdata[ADC_ACCESSORY].channelnum = 4;
89 adcdata[ADC_ACCESSORY].timeout = 0; 89 adcdata[ADC_ACCESSORY].timeout = 0;
90#ifdef IPOD_VIDEO
91 adcdata[ADC_4066_ISTAT].channelnum = 7;
92 adcdata[ADC_4066_ISTAT].timeout = 0;
93#endif
90 _adc_read(adc_battery); 94 _adc_read(adc_battery);
91} 95}
diff --git a/firmware/target/arm/ipod/adc-target.h b/firmware/target/arm/ipod/adc-target.h
index 14b10e6a2b..708febac9d 100644
--- a/firmware/target/arm/ipod/adc-target.h
+++ b/firmware/target/arm/ipod/adc-target.h
@@ -21,12 +21,16 @@
21#ifndef _ADC_TARGET_H_ 21#ifndef _ADC_TARGET_H_
22#define _ADC_TARGET_H_ 22#define _ADC_TARGET_H_
23 23
24#define NUM_ADC_CHANNELS 2
25
26#define ADC_BATTERY 0 24#define ADC_BATTERY 0
27#define ADC_ACCESSORY 1 25#define ADC_ACCESSORY 1
28#define ADC_UNREG_POWER ADC_BATTERY 26#define ADC_UNREG_POWER ADC_BATTERY
29 27#ifdef IPOD_VIDEO
28#define ADC_4066_ISTAT 2
29#define NUM_ADC_CHANNELS 3
30#else
31#define NUM_ADC_CHANNELS 2
32#endif
33
30/* Force a scan now */ 34/* Force a scan now */
31unsigned short adc_scan(int channel); 35unsigned short adc_scan(int channel);
32#endif 36#endif