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

📄 dadrv_test.c

📁 Linux环境下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;    char CH;    int v0=0xffff0000,v10P=0x7fff0000, v10N=0x80000000,v5P=0x3fff0000;         if((fd=open("/dev/da",O_RDWR))==-1)                {                perror("open error");                exit(1);                }                     printf("Please Input Channel Number For Testing[0/1]:");      CH = getchar();      if((count=write(fd,(char *)&CH,1))!=1)                        {                        perror("write error");                        exit(1);                        }      printf("\n\rConvting ...");      if((count=write(fd,(char*)&v0,4))!=4)                        {			perror("write error");			exit(1);                        }      if((count=write(fd,(char*)&v10P,4))!=4)                        {                        perror("write error");                        exit(1);                        }      if((count=write(fd,(char*)&v10N,4))!=4)                        {                        perror("write error");                        exit(1);                        }      if((count=write(fd,(char*)&v5P,4))!=4)                        {                        perror("write error");                        exit(1);                        }      if((count=write(fd,(char*)&v0,4))!=4)                        {                        perror("write error");                        exit(1);                        }      printf("Ok!\n\r");         close(fd);return 0;}                 

⌨️ 快捷键说明

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