⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpio.txt

📁 GPIO的控制
💻 TXT
字号:
#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;	
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -