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

📄 test-adc.c~

📁 基于s3c2410芯片的ADC驱动程序源代码
💻 C~
字号:
/*********************************************************************
* File:		test-adc.c
* Author:	
* Desc:		ADC channel conversion test example.
* History:		
*	
*********************************************************************/

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <fcntl.h>
#include "test-adc.h"


int main(int argc, char** argv)
{
	int i=2, ch, usConData,usEndData, fd;
	char *pAINx="2";
	static char *driver = "/dev/misc/adc";
	
	printf(" ADC Read Example base on Linux.\n");
	/* open device */
	fd = open(driver, O_RDWR);
	if(fd < 0)
	{
		printf("device open fail\n");
		return -1;
	}
	//printf(" Loop Read %d-times to convert.\n",i);
	printf(" Infinite Reading from AIN%s (^C to exit).\n",pAINx);
	printf(" Press ^C to exit.\n");
	while(1)//i--)
	{
		read(fd, &usConData, 1);             printf("%d\n",usConData);
		printf(" %0.4f \n",usConData*3.3/0x3ff);
		sleep(1);
	}

	printf(" end.\n");
	return 0;
}

⌨️ 快捷键说明

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