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

📄 pattern.c

📁 rt 7520采集卡 linux驱动源代码
💻 C
字号:
/*	FILE NAME: pattern.c	FILE DESCRIPTION:		Reads digital data from a file and writes it to digital I/O		port 0.  The data file name is passed in as the second command		line argument.	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 <unistd.h>	//usleep#include <errno.h>	//errno#include <stdlib.h>	//exit#include "dm7520_library.h"int main(int argc, char * argv[]){ FILE * devfile; FILE * infile; char buffer [4096]; char c; int cnt,i; if (argc<2) {fprintf(stderr,"Usage: %s <devicename> patternfile\n",argv[0]);exit(1);} if (NULL==(devfile=fopen(argv[1],"r")))    {    fprintf(stderr,"Cannot open device, errno=%d\n",errno);    perror("Error is");    exit(2);   } if (NULL==(infile=fopen(argv[2],"r")))    {    perror("Cannot open inputfile:");    exit(2);   } InitBoard7520(fileno(devfile)); SetDIO0Direction7520(fileno(devfile),255);  while ((cnt=fread(buffer,sizeof(char),4096,infile))>0)   {    for (i=0;i<cnt;i++)      {       c=buffer[i];       WriteDIO07520(fileno(devfile),(int)c);        usleep(100000);      }   }  fclose(infile); return(0); }

⌨️ 快捷键说明

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