#include<unistd.h>
#include<sys/types.h>
#include<sys/mman.h>
#include<stdio.h>
#include<fcntl.h>
#include <iostream.h>
int main(int argc, char** argv)
{
int iADC_fd;
unsigned char* pcADCPorts;
unsigned int* piADCCON, * piADCTSC, * piADCDLY, * piADCDAT0, * piADCDAT1;
iADC_fd = 0x0;
pcADCPorts = NULL;
piADCCON = NULL;
piADCTSC = NULL;
piADCDLY = NULL;
piADCDAT0 = NULL;
piADCDAT1 = NULL;
printf("ADC Control Test AP v0.1 20060704 00\n");
iADC_fd = open("/dev/mem", O_RDWR);
if (iADC_fd == -1)
{
printf("can't open /dev/mem.\n");
return ;
}
pcADCPorts = (unsigned char *) mmap(0, getpagesize(),PROT_READ | PROT_WRITE, MAP_SHARED,iADC_fd, 0x5800000);
piADCCON = (unsigned int *) (pcADCPorts); //ADC Control Register
piADCTSC = (unsigned int *) (pcADCPorts + 0x4); //ADC Touch Screen Control Register
piADCDLY = (unsigned int *) (pcADCPorts + 0x8); //ADC Start or Interval Delay Register
piADCDAT0 = (unsigned int *) (pcADCPorts + 0xC); //ADC Conversion Data Register
piADCDAT1 = (unsigned int *) (pcADCPorts + 0x10); //ADC Conversion Data Register
for ( int ip=0;ip<100;ip++)
{
printf("piADCCON[%x] piADCTSC[%x] piADCDLY[%x] piADCDAT0[%x] piADCDAT1[%x] \n", *piADCCON, *piADCTSC, *piADCDLY, *piADCDAT0, *piADCDAT1);
sleep(1);
}
if (iADC_fd != 0x0)
{
close(iADC_fd);
}
printf("ADC Control Test AP v0.1 end\n");
iADC_fd = 0x0;
pcADCPorts = NULL;
piADCCON = NULL;
piADCTSC = NULL;
piADCDLY = NULL;
piADCDAT0 = NULL;
piADCDAT1 = NULL;
}