summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorBrandon Low <lostlogic@rockbox.org>2006-03-09 01:36:22 +0000
committerBrandon Low <lostlogic@rockbox.org>2006-03-09 01:36:22 +0000
commitca9e8b6cf5d1bdadf0040eb2f4baec1cbd5e3d7a (patch)
tree4b3253906eb2397fe80ac747f6873878fc11861a /firmware
parentc24569feeedc9e6bda80b84d9dd6398f1bb9c586 (diff)
downloadrockbox-ca9e8b6cf5d1bdadf0040eb2f4baec1cbd5e3d7a.zip
rockbox-ca9e8b6cf5d1bdadf0040eb2f4baec1cbd5e3d7a.tar.gz
rockbox-ca9e8b6cf5d1bdadf0040eb2f4baec1cbd5e3d7a.tar.bz2
rockbox-ca9e8b6cf5d1bdadf0040eb2f4baec1cbd5e3d7a.tar.xz
Use an 8 bit ADC read for battery reading on ipod, that provides better than centivolt precision any way, also enable charging, it seems to detect fine when charging by USB
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8966 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/adc.c9
-rw-r--r--firmware/drivers/pcf50605.c12
-rw-r--r--firmware/export/config-ipodvideo.h4
3 files changed, 9 insertions, 16 deletions
diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c
index e5dd4c1..a75f788 100644
--- a/firmware/drivers/adc.c
+++ b/firmware/drivers/adc.c
@@ -298,12 +298,17 @@ static struct adc_struct adcdata[NUM_ADC_CHANNELS] IDATA_ATTR;
* a 13 bit value corresponding to 0-5.4v, the resulting range is 13FB-17FA,
* representing 3.1-5.4v */
static unsigned short ten_bit_subtractor(unsigned short data) {
- return (data<<2)+0x13FB;
+ return (data<<2)+0x4FB;
}
static unsigned short _adc_scan(struct adc_struct *adc)
{
- unsigned short data = pcf50605_a2d_read(adc->channelnum);
+ unsigned short data;
+
+ /* ADCC1, 8 bit, start */
+ pcf50605_write(0x2f, 0x80 | (adc->channelnum << 1) | 0x1);
+ data = pcf50605_read(0x30); /* ADCS1 */
+
if (adc->conversion) {
data = adc->conversion(data);
}
diff --git a/firmware/drivers/pcf50605.c b/firmware/drivers/pcf50605.c
index 7d2036e..c8ea4a4 100644
--- a/firmware/drivers/pcf50605.c
+++ b/firmware/drivers/pcf50605.c
@@ -98,18 +98,6 @@ int pcf50605_write_multiple(int address, const unsigned char* buf, int count)
return 0;
}
-unsigned short pcf50605_a2d_read(int adc_input)
-{
- unsigned short hi;
- unsigned char lo;
-
- ipod_i2c_send(0x8, 0x2f, (adc_input<<1) | 0x1); /* ADCC2, ADCMUX = adc_input, ADCSTART = 1 */
- hi = i2c_readbyte(0x8, 0x30); /* ADCS1 */
- lo = (i2c_readbyte(0x8, 0x31) & 0x3); /* ADCS2 */
-
- return (hi << 2) | lo;
-}
-
/* The following command puts the iPod into a deep sleep. Warning
from the good people of ipodlinux - never issue this command
without setting CHGWAK or EXTONWAK if you ever want to be able to
diff --git a/firmware/export/config-ipodvideo.h b/firmware/export/config-ipodvideo.h
index 1fa778d..9a561c3 100644
--- a/firmware/export/config-ipodvideo.h
+++ b/firmware/export/config-ipodvideo.h
@@ -61,10 +61,10 @@
/* Type of mobile power */
#define CONFIG_BATTERY BATT_LIPOL1300
-#define BATTERY_SCALE_FACTOR 586 /* FIX: this value is picked at random */
+#define BATTERY_SCALE_FACTOR 2353
/* Define this if the platform can charge batteries */
-//#define HAVE_CHARGING 1
+#define HAVE_CHARGING 1
/* define this if the hardware can be powered off while charging */
//#define HAVE_POWEROFF_WHILE_CHARGING