1
0
Fork 0
forked from len0rd/rockbox

Cleanup some tabs and whitespace

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17288 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Karl Kurbjun 2008-04-29 01:43:15 +00:00
parent c741ecc68a
commit f3d83c7be7

View file

@ -21,16 +21,12 @@
#include "adc-target.h" #include "adc-target.h"
#include "kernel.h" #include "kernel.h"
static unsigned short adc_readings[NUM_ADC_CHANNELS]; static unsigned short adc_readings[NUM_ADC_CHANNELS];
/* prototypes */ /* prototypes */
static unsigned short __adc_read(int channel); static unsigned short __adc_read(int channel);
static void adc_tick(void); static void adc_tick(void);
void adc_init(void) void adc_init(void)
{ {
int i; int i;
@ -59,20 +55,14 @@ void adc_init(void)
/* attach the adc reading to the tick */ /* attach the adc reading to the tick */
tick_add_task(adc_tick); tick_add_task(adc_tick);
} }
/* Called to get the recent ADC reading */ /* Called to get the recent ADC reading */
inline unsigned short adc_read(int channel) inline unsigned short adc_read(int channel)
{ {
return adc_readings[channel]; return adc_readings[channel];
} }
/** /**
* Read the ADC by polling * Read the ADC by polling
* @param channel The ADC channel to read * @param channel The ADC channel to read
@ -80,47 +70,52 @@ inline unsigned short adc_read(int channel)
*/ */
static unsigned short __adc_read(int channel) static unsigned short __adc_read(int channel)
{ {
int i; int i;
/* Set the channel */ /* Set the channel */
ADCCON = (ADCCON & ~(0x7<<3)) | (channel<<3); ADCCON = (ADCCON & ~(0x7<<3)) | (channel<<3);
/* Start the conversion process */ /* Start the conversion process */
ADCCON |= 0x1; ADCCON |= 0x1;
/* Wait for a low Enable_start */ /* Wait for a low Enable_start */
for (i = 20000;;) { for (i = 20000;;)
if(0 == (ADCCON & 0x1)) { {
break; if(0 == (ADCCON & 0x1))
{
break;
}
else
{
i--;
if (0 == i)
{
/* Ran out of time */
return ADC_READ_ERROR;
}
}
} }
else {
i--;
if (0 == i) {
/* Ran out of time */
return ADC_READ_ERROR;
}
}
}
/* Wait for high End_of_Conversion */ /* Wait for high End_of_Conversion */
for(i = 20000;;) { for(i = 20000;;)
if(ADCCON & (1<<15)) { {
break; if(ADCCON & (1<<15))
{
break;
}
else
{
i--;
if(0 == i)
{
/* Ran out of time */
return ADC_READ_ERROR;
}
}
} }
else { return (ADCDAT0 & 0x3ff);
i--;
if(0 == i) {
/* Ran out of time */
return ADC_READ_ERROR;
}
}
}
return (ADCDAT0 & 0x3ff);
} }
/* add this to the tick so that the ADC converts are done in the background */ /* add this to the tick so that the ADC converts are done in the background */
static void adc_tick(void) static void adc_tick(void)
{ {
@ -140,6 +135,3 @@ static void adc_tick(void)
} }
} }