summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2010-08-20 22:21:07 +0000
committerJens Arnold <amiconn@rockbox.org>2010-08-20 22:21:07 +0000
commit0a080891e7b5849df2686df504c15b008ba8cc73 (patch)
tree8ce9b18d1200fb1bcc52d5dc2c2ccea4a1901b30
parent43ccc1eef7a7dae532e36e5ee3fdd144637eb279 (diff)
downloadrockbox-0a080891e7b5849df2686df504c15b008ba8cc73.tar.gz
rockbox-0a080891e7b5849df2686df504c15b008ba8cc73.zip
iPod 1st Gen: Fix battery ADC not working due to the EABI compiler optimizing the delay loops away. Use udelay() instead, not wasting CPU time when the CPU is not boosted.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27850 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/ipod/1g2g/adc-ipod-1g2g.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/firmware/target/arm/ipod/1g2g/adc-ipod-1g2g.c b/firmware/target/arm/ipod/1g2g/adc-ipod-1g2g.c
index cfeb78d198..37c719f2b1 100644
--- a/firmware/target/arm/ipod/1g2g/adc-ipod-1g2g.c
+++ b/firmware/target/arm/ipod/1g2g/adc-ipod-1g2g.c
@@ -25,6 +25,7 @@
25#include "kernel.h" 25#include "kernel.h"
26#include "adc.h" 26#include "adc.h"
27#include "adc-target.h" 27#include "adc-target.h"
28#include "system-target.h"
28 29
29static struct mutex adc_mtx SHAREDBSS_ATTR; 30static struct mutex adc_mtx SHAREDBSS_ATTR;
30 31
@@ -41,24 +42,24 @@ unsigned short adc_scan(int channel)
41 42
42 if ((IPOD_HW_REVISION >> 16) == 1) 43 if ((IPOD_HW_REVISION >> 16) == 1)
43 { 44 {
44 int i, j; 45 int i;
45 unsigned pval = GPIOB_OUTPUT_VAL; 46 unsigned pval = GPIOB_OUTPUT_VAL;
46 47
47 GPIOB_OUTPUT_VAL = pval | 0x04; /* B2 -> high */ 48 GPIOB_OUTPUT_VAL = pval | 0x04; /* B2 -> high */
48 for (i = 32; i > 0; --i); 49 udelay(2);
49 50
50 GPIOB_OUTPUT_VAL = pval; /* B2 -> low */ 51 GPIOB_OUTPUT_VAL = pval; /* B2 -> low */
51 for (i = 200; i > 0; --i); 52 udelay(10);
52 53
53 for (j = 0; j < 8; j++) 54 for (i = 0; i < 8; i++)
54 { 55 {
55 GPIOB_OUTPUT_VAL = pval | 0x02; /* B1 -> high */ 56 GPIOB_OUTPUT_VAL = pval | 0x02; /* B1 -> high */
56 for (i = 8; i > 0; --i); 57 udelay(1);
57 58
58 data = (data << 1) | ((GPIOB_INPUT_VAL & 0x08) >> 3); 59 data = (data << 1) | ((GPIOB_INPUT_VAL & 0x08) >> 3);
59 60
60 GPIOB_OUTPUT_VAL = pval; /* B1 -> low */ 61 GPIOB_OUTPUT_VAL = pval; /* B1 -> low */
61 for (i = 320; i > 0; --i); 62 udelay(15);
62 } 63 }
63 } 64 }
64 else if ((IPOD_HW_REVISION >> 16) == 2) 65 else if ((IPOD_HW_REVISION >> 16) == 2)