diff options
author | Jens Arnold <amiconn@rockbox.org> | 2007-08-17 20:47:24 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2007-08-17 20:47:24 +0000 |
commit | bfa1adcd06eca3b64f6d71b2231db88cd86ef902 (patch) | |
tree | ee53b3a672aed7305e39e72c151928a83bce4e13 /firmware/target/coldfire/iriver/h300/adc-h300.c | |
parent | 98a3789071caac4b7e64f1cc0f5969ecd530cc5c (diff) | |
download | rockbox-bfa1adcd06eca3b64f6d71b2231db88cd86ef902.tar.gz rockbox-bfa1adcd06eca3b64f6d71b2231db88cd86ef902.zip |
H300: Read battery voltage with 10bit precision.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14379 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/coldfire/iriver/h300/adc-h300.c')
-rw-r--r-- | firmware/target/coldfire/iriver/h300/adc-h300.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/firmware/target/coldfire/iriver/h300/adc-h300.c b/firmware/target/coldfire/iriver/h300/adc-h300.c index 77d7b4689f..b13d0c73cc 100644 --- a/firmware/target/coldfire/iriver/h300/adc-h300.c +++ b/firmware/target/coldfire/iriver/h300/adc-h300.c | |||
@@ -26,20 +26,23 @@ | |||
26 | 26 | ||
27 | static int adcc2_parms[] = | 27 | static int adcc2_parms[] = |
28 | { | 28 | { |
29 | [ADC_BUTTONS] = 0x80 | (5 << 1) | 1, /* ADCIN2 */ | 29 | [ADC_BUTTONS] = 0x80 | (5 << 1) | 1, /* 8b, ADCIN2 */ |
30 | [ADC_REMOTE] = 0x80 | (6 << 1) | 1, /* ADCIN3 */ | 30 | [ADC_REMOTE] = 0x80 | (6 << 1) | 1, /* 8b, ADCIN3 */ |
31 | [ADC_BATTERY] = 0x80 | (0 << 1) | 1, /* BATVOLT, resistive divider */ | 31 | [ADC_BATTERY] = 0x00 | (0 << 1) | 1, /* 10b, BATVOLT, resistive divider */ |
32 | [ADC_REMOTEDETECT] = 0x80 | (2 << 1) | 1, /* ADCIN1, resistive divider */ | 32 | [ADC_REMOTEDETECT] = 0x80 | (2 << 1) | 1, /* 8b, ADCIN1, resistive divider */ |
33 | }; | 33 | }; |
34 | 34 | ||
35 | unsigned short adc_scan(int channel) | 35 | unsigned short adc_scan(int channel) |
36 | { | 36 | { |
37 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); | 37 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); |
38 | unsigned char data; | 38 | unsigned data; |
39 | 39 | ||
40 | pcf50606_write(0x2f, adcc2_parms[channel]); | 40 | pcf50606_write(0x2f, adcc2_parms[channel]); |
41 | data = pcf50606_read(0x30); | 41 | data = pcf50606_read(0x30); |
42 | 42 | ||
43 | if (channel == ADC_BATTERY) | ||
44 | data = (data << 2) | (pcf50606_read(0x31) & 0x03); | ||
45 | |||
43 | set_irq_level(level); | 46 | set_irq_level(level); |
44 | return data; | 47 | return data; |
45 | } | 48 | } |