mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
rk27xx - fix (hopefully) adc readings
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30164 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a5e7354b20
commit
8fba4fb937
1 changed files with 12 additions and 6 deletions
|
@ -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
|
||||
|
@ -30,8 +30,14 @@ 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);
|
||||
/* 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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue