sama5d3 环境检测 adc测试
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
//逻辑通道和物理通道的对应关系
//channel7 ain0
//channel6 ain1
//channel3 ain2
//channel4 ain3
//channel5 ain4
//channel2 ain5
//channel1 ain6
//channel0 ain7
int main(int argc, char *argv)
{
int i, n, fd;
int ret;
unsigned short val[8];
fd = open("/dev/ad7927", O_RDWR); //打开设备
if (fd < 0)
{
printf("can't open /dev/ad7927!\n");
exit(1);
}
ret = read(fd, val, 8*sizeof(unsigned short)); //读取
if(ret > 0)
{
for(i=0;i<8;i++)
printf("channel=%d,result = %x\n",
(val[i]&0xe000)>>13, val[i]&0x1fff);
}
sleep(10);
return 0;
}