diff options
| author | Marcin Bukat <marcin.bukat@gmail.com> | 2011-07-18 22:00:17 +0000 |
|---|---|---|
| committer | Marcin Bukat <marcin.bukat@gmail.com> | 2011-07-18 22:00:17 +0000 |
| commit | 8fba4fb937332f4125d5fe6aee90e37dc9f68b0e (patch) | |
| tree | e786ea0a69971b83e1c26d2bbebf684613a602da | |
| parent | a5e7354b20b1b406e850ac26d589ea0ddb4936e2 (diff) | |
| download | rockbox-8fba4fb937332f4125d5fe6aee90e37dc9f68b0e.zip rockbox-8fba4fb937332f4125d5fe6aee90e37dc9f68b0e.tar.gz rockbox-8fba4fb937332f4125d5fe6aee90e37dc9f68b0e.tar.bz2 rockbox-8fba4fb937332f4125d5fe6aee90e37dc9f68b0e.tar.xz | |
rk27xx - fix (hopefully) adc readings
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30164 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/target/arm/rk27xx/adc-rk27xx.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/firmware/target/arm/rk27xx/adc-rk27xx.c b/firmware/target/arm/rk27xx/adc-rk27xx.c index c8bbae7..524cf4d 100644 --- a/firmware/target/arm/rk27xx/adc-rk27xx.c +++ b/firmware/target/arm/rk27xx/adc-rk27xx.c @@ -11,7 +11,7 @@ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 + * as published by the Free Software Foundation; either version 1 * of the License, or (at your option) any later version. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY @@ -28,11 +28,17 @@ unsigned int adc_scan(int channel) { - ADC_CTRL = (1<<4) | (1<<3) | (channel & (NUM_ADC_CHANNELS - 1)); - - /* wait for conversion ready ~10us */ - while (ADC_STAT & 0x01); + ADC_CTRL = (1<<4)|(1<<3) | (channel & (NUM_ADC_CHANNELS - 1)); + /* Wait for conversion ready. + * The doc says one should pool ADC_STAT for end of conversion + * or setup interrupt. Neither of these two methods work as + * advertised. + * + * ~10us should be enough so we wait 20us to be on the safe side + */ + udelay(20); + /* 10bits result */ return (ADC_DATA & 0x3ff); } @@ -43,5 +49,5 @@ void adc_init(void) SCU_DIVCON1 = (SCU_DIVCON1 & ~(0xff<<10)) | (49<<10); /* enable clocks for ADC */ - SCU_CLKCFG |= 3<<23; + SCU_CLKCFG &= ~(3<<23); } |