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

📄 addrv_test.c

📁 at91rm9200 AD/DA转换驱动 很好的驱动开发范例
💻 C
字号:
#include <stdio.h>#include <string.h>#include <malloc.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <signal.h>int main(void){        int fd,count;        int CH;        short result;        if((fd=open("/dev/ad",O_RDWR))==-1)                {                perror("open error");                exit(1);                }             while(1)    {    Loop:      printf("\n\rPlease Input Channel Number For Testing[0-7]:");      while ((CH = getchar()) != '\n')      if(CH>'7')      {      printf("\n\rError,The Channel Number Must between 0 ~ 7\n\r");      goto Loop;      }    if((count=write(fd,(char *)&CH,1))!=1)			{			perror("write error");			exit(1);                        }    if((count=read(fd,(char*)&result,2))!=2)                        {			perror("read error");			exit(1);                        }       printf("\n\rThe Input Voltage = %.2fv\n\r",result*10.0/4096.0);   }            close(fd);        return 0;   }                  

⌨️ 快捷键说明

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