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

📄 user_inp.c

📁 rt 7520采集卡 linux驱动源代码
💻 C
字号:
/*	FILE NAME: user_inp.c	FILE DESCRIPTION:		Demonstrates usage of User Input 0 and User Input 1.		The following connections must be made before running this		program:			* CN2 pin 44 ==> CN2 pin 54			* CN2 pin 46 ==> CN2 pin 53	PROJECT NAME: Linux DM7520 Driver, Library, and Example Programs	PROJECT VERSION: (Defined in README.TXT)	Copyright 2004 RTD Embedded Technologies, Inc.  All Rights Reserved.*/#include <stdio.h>	//printf
#include <stdlib.h>	//exit#include <errno.h>	//errno
#include "dm7520_library.h"int main(int argc, char * argv[]){ FILE * infile;
 int devno;	//device handler
 int errors = 0;
 int i;
 uint16_t userInp;

 if (argc<2) {fprintf(stderr,"Usage: %s <device>\n",argv[0]);exit(1);}

 if (NULL==(infile=fopen(argv[1],"r")))
   {
    fprintf(stderr,"Cannot open file, errno=%d\n",errno);
    perror("Error is");
    exit(2);
   }

 devno = fileno(infile);		// get device handler

 InitBoard7520(devno);
 SetDIO1Direction7520(devno, 1);	//set port1 to output
 

 for (i=0; i<4; i++) {
	WriteDIO17520(devno,i);
	ReadUserInput7520(devno, &userInp);
	if (i != userInp) {
		printf("Error: written to port1=%d, Read from user input=%d\n", i, userInp);
		errors++;
	}
 }

 printf("Test done. Number of errors=%d\n", errors);
 fclose(infile); return(0);}

⌨️ 快捷键说明

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