gpio_keys_input_test.c
来自「ixp425 linux2.6 gpio 中断驱动及测试」· C语言 代码 · 共 32 行
C
32 行
#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <linux/input.h>int main( int argc, char *argv[] ){ int fd, i; struct input_event x; system("/bin/mknod /dev/event0 c 13 64"); fd = open("/dev/event0", O_RDONLY); if( fd < 0 ) { perror("open"); goto END; } for(;;) { printf("read gpio \n"); if(read( fd, &x, sizeof(x))) { printf("------------------%d %d %d\n", x.type, x.code, x.value); } }END: return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?