2410gpio_test_app.c
来自「在linux2.6内核测试没有问题!我用得是s3c2410!功能简单!但是入门很」· C语言 代码 · 共 37 行
C
37 行
#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 + =
减小字号Ctrl + -
显示快捷键?