From 2d0af6f3c7f1a33337ab5d9498364149104fd346 Mon Sep 17 00:00:00 2001 From: Torne Wuff Date: Tue, 3 Nov 2009 20:35:04 +0000 Subject: 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 --- apps/debug_menu.c | 13 +++++++++++++ firmware/target/arm/ipod/adc-ipod-pcf.c | 4 ++++ firmware/target/arm/ipod/adc-target.h | 10 +++++++--- 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) #ifdef ADC_ACCESSORY lcd_putsf(0, line++, "ACCESSORY: %d", adc_read(ADC_ACCESSORY)); #endif +#ifdef IPOD_VIDEO + lcd_putsf(0, line++, "4066_ISTAT: %d", adc_read(ADC_4066_ISTAT)); +#endif #if defined(IPOD_ACCESSORY_PROTOCOL) extern unsigned char serbuf[]; @@ -1529,6 +1532,16 @@ static bool view_battery(void) dock ? "enabled" : "disabled"); lcd_putsf(0, 7, "Headphone: %s", headphone ? "connected" : "disconnected"); +#ifdef IPOD_VIDEO + x = (adc_read(ADC_4066_ISTAT) * 2400) / +#if MEM == 64 + (1024 * 2); +#else + (1024 * 3); +#endif + lcd_putsf(0, 8, "Ibat: %d mA", x); + lcd_putsf(0, 9, "Vbat * Ibat: %d mW", x * y / 1000); +#endif #elif defined TOSHIBA_GIGABEAT_S int line = 3; 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) adc_battery->timeout = 0; adcdata[ADC_ACCESSORY].channelnum = 4; adcdata[ADC_ACCESSORY].timeout = 0; +#ifdef IPOD_VIDEO + adcdata[ADC_4066_ISTAT].channelnum = 7; + adcdata[ADC_4066_ISTAT].timeout = 0; +#endif _adc_read(adc_battery); } 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 @@ #ifndef _ADC_TARGET_H_ #define _ADC_TARGET_H_ -#define NUM_ADC_CHANNELS 2 - #define ADC_BATTERY 0 #define ADC_ACCESSORY 1 #define ADC_UNREG_POWER ADC_BATTERY - +#ifdef IPOD_VIDEO +#define ADC_4066_ISTAT 2 +#define NUM_ADC_CHANNELS 3 +#else +#define NUM_ADC_CHANNELS 2 +#endif + /* Force a scan now */ unsigned short adc_scan(int channel); #endif -- cgit v1.2.3