usertest.c

来自「这是嵌入式中的FPGA的驱动」· C语言 代码 · 共 46 行

C
46
字号
#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <sys/ioctl.h>#include <unistd.h>#include <stdio.h>#include <sys/mman.h>#include <unistd.h>int main(int argv , char * argc[]){	int fd;	int data, ret;	fd = open("/dev/AT91_FPGA_Driver0", O_RDWR);	printf("open FPGA, fd = %d\n", fd);	if(fd == -1) 	{		printf("open error...\n");		return -1;	}		printf("read FPGA...\n");	ret = read(fd, &data, sizeof(int));	if(ret < 0) 	{		printf("read error...\n");		close(fd);		return -1;	}		printf("write FPGA...\n");	ret = write(fd, &data, sizeof(int));	if(ret < 0) 	{		printf("write error...\n");		close(fd);		return -1;	}			close(fd);	printf("close FPGA...\n");	return 0;}

⌨️ 快捷键说明

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