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

📄 2410gpio_test_app.c

📁 在linux2.6内核测试没有问题!我用得是s3c2410!功能简单!但是入门很有用
💻 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>
#include <sys/ioctl.h>
#define GPF4_ON 0x4800
#define GPF4_OFF 0x4801
//用户编写的

int main(void)
{
	int fd;
	int *arginfo=(int *)malloc(4);
	printf("entered main\n");
	if((fd=open("/dev/GPIO_TEST",O_RDWR))==-1)//mknod /dev/GPIO_TEST c 252 0
	{
		perror("open eror");
		exit(1);
	}
	printf("open ok\n");

	while(1)
	{  
		ioctl(fd,GPF4_OFF,arginfo); //GPF0 1
		sleep(1);
		ioctl(fd,GPF4_ON,arginfo);  //GPF0 0
		sleep(1);
	}

	close(fd);
	return 0;
}

⌨️ 快捷键说明

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