summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--firmware/target/arm/s3c2440/gigabeat-fx/adc-meg-fx.c84
1 files changed, 38 insertions, 46 deletions
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/adc-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/adc-meg-fx.c
index 9a934c2487..266555fe3b 100644
--- a/firmware/target/arm/s3c2440/gigabeat-fx/adc-meg-fx.c
+++ b/firmware/target/arm/s3c2440/gigabeat-fx/adc-meg-fx.c
@@ -21,16 +21,12 @@
#include "adc-target.h"
#include "kernel.h"
-
-
static unsigned short adc_readings[NUM_ADC_CHANNELS];
/* prototypes */
static unsigned short __adc_read(int channel);
static void adc_tick(void);
-
-
void adc_init(void)
{
int i;
@@ -59,20 +55,14 @@ void adc_init(void)
/* attach the adc reading to the tick */
tick_add_task(adc_tick);
-
-
}
-
-
/* Called to get the recent ADC reading */
inline unsigned short adc_read(int channel)
{
return adc_readings[channel];
}
-
-
/**
* Read the ADC by polling
* @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)
{
- int i;
+ int i;
- /* Set the channel */
- ADCCON = (ADCCON & ~(0x7<<3)) | (channel<<3);
+ /* Set the channel */
+ ADCCON = (ADCCON & ~(0x7<<3)) | (channel<<3);
- /* Start the conversion process */
- ADCCON |= 0x1;
+ /* Start the conversion process */
+ ADCCON |= 0x1;
- /* Wait for a low Enable_start */
- for (i = 20000;;) {
- if(0 == (ADCCON & 0x1)) {
- break;
- }
- else {
- i--;
- if (0 == i) {
- /* Ran out of time */
- return ADC_READ_ERROR;
- }
+ /* Wait for a low Enable_start */
+ for (i = 20000;;)
+ {
+ if(0 == (ADCCON & 0x1))
+ {
+ break;
+ }
+ else
+ {
+ i--;
+ if (0 == i)
+ {
+ /* Ran out of time */
+ return ADC_READ_ERROR;
+ }
+ }
}
- }
- /* Wait for high End_of_Conversion */
- for(i = 20000;;) {
- if(ADCCON & (1<<15)) {
- break;
- }
- else {
- i--;
- if(0 == i) {
- /* Ran out of time */
- return ADC_READ_ERROR;
- }
+ /* Wait for high End_of_Conversion */
+ for(i = 20000;;)
+ {
+ if(ADCCON & (1<<15))
+ {
+ break;
+ }
+ else
+ {
+ i--;
+ if(0 == i)
+ {
+ /* Ran out of time */
+ return ADC_READ_ERROR;
+ }
+ }
}
- }
-
- return (ADCDAT0 & 0x3ff);
+ return (ADCDAT0 & 0x3ff);
}
-
-
/* add this to the tick so that the ADC converts are done in the background */
static void adc_tick(void)
{
@@ -140,6 +135,3 @@ static void adc_tick(void)
}
}
-
-
-