#include "S3C2451_adc.h"
//#define ADCCON (*(volatile unsigned *)0x58000000)
//#define ADCTSC (*(volatile unsigned *)0x58000004)
//#define ADCDLY (*(volatile unsigned *)0x58000008)
//#define ADCDAT0 (*(volatile unsigned *)0x5800000c)
//#define ADCDAT1 (*(volatile unsigned *)0x58000010)
//#define ADCUPDN (*(volatile unsigned *)0x58000014)
//#define ADCMUX (*(volatile unsigned *)0x58000018)
int read_adc(int resolution)
{
rADCCON = (1<<16)|(1 << 14) | (65 << 6) | (resolution << 3);
rADCCON &= ~((1<<2)|(1<<1));
rADCCON |= (1 << 0);
while (rADCCON & (1 << 0));
while (!(rADCCON & (1 << 15)) );
return (rADCDAT0 & 0xfff);
}
//#define ADCCON (*(volatile unsigned *)0x58000000)
//#define ADCTSC (*(volatile unsigned *)0x58000004)
//#define ADCDLY (*(volatile unsigned *)0x58000008)
//#define ADCDAT0 (*(volatile unsigned *)0x5800000c)
//#define ADCDAT1 (*(volatile unsigned *)0x58000010)
//#define ADCUPDN (*(volatile unsigned *)0x58000014)
//#define ADCMUX (*(volatile unsigned *)0x58000018)
int read_adc(int resolution)
{
rADCCON = (1<<16)|(1 << 14) | (65 << 6) | (resolution << 3);
rADCCON &= ~((1<<2)|(1<<1));
rADCCON |= (1 << 0);
while (rADCCON & (1 << 0));
while (!(rADCCON & (1 << 15)) );
return (rADCDAT0 & 0xfff);
}