pattern.c
来自「rt 7520采集卡 linux驱动源代码」· C语言 代码 · 共 63 行
C
63 行
/* 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 + =
减小字号Ctrl + -
显示快捷键?