forked from len0rd/rockbox
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
This commit is contained in:
parent
43ccc1eef7
commit
0a080891e7
1 changed files with 7 additions and 6 deletions
|
@ -25,6 +25,7 @@
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "adc.h"
|
#include "adc.h"
|
||||||
#include "adc-target.h"
|
#include "adc-target.h"
|
||||||
|
#include "system-target.h"
|
||||||
|
|
||||||
static struct mutex adc_mtx SHAREDBSS_ATTR;
|
static struct mutex adc_mtx SHAREDBSS_ATTR;
|
||||||
|
|
||||||
|
@ -41,24 +42,24 @@ unsigned short adc_scan(int channel)
|
||||||
|
|
||||||
if ((IPOD_HW_REVISION >> 16) == 1)
|
if ((IPOD_HW_REVISION >> 16) == 1)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i;
|
||||||
unsigned pval = GPIOB_OUTPUT_VAL;
|
unsigned pval = GPIOB_OUTPUT_VAL;
|
||||||
|
|
||||||
GPIOB_OUTPUT_VAL = pval | 0x04; /* B2 -> high */
|
GPIOB_OUTPUT_VAL = pval | 0x04; /* B2 -> high */
|
||||||
for (i = 32; i > 0; --i);
|
udelay(2);
|
||||||
|
|
||||||
GPIOB_OUTPUT_VAL = pval; /* B2 -> low */
|
GPIOB_OUTPUT_VAL = pval; /* B2 -> low */
|
||||||
for (i = 200; i > 0; --i);
|
udelay(10);
|
||||||
|
|
||||||
for (j = 0; j < 8; j++)
|
for (i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
GPIOB_OUTPUT_VAL = pval | 0x02; /* B1 -> high */
|
GPIOB_OUTPUT_VAL = pval | 0x02; /* B1 -> high */
|
||||||
for (i = 8; i > 0; --i);
|
udelay(1);
|
||||||
|
|
||||||
data = (data << 1) | ((GPIOB_INPUT_VAL & 0x08) >> 3);
|
data = (data << 1) | ((GPIOB_INPUT_VAL & 0x08) >> 3);
|
||||||
|
|
||||||
GPIOB_OUTPUT_VAL = pval; /* B1 -> low */
|
GPIOB_OUTPUT_VAL = pval; /* B1 -> low */
|
||||||
for (i = 320; i > 0; --i);
|
udelay(15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((IPOD_HW_REVISION >> 16) == 2)
|
else if ((IPOD_HW_REVISION >> 16) == 2)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue