test-b-a.c

来自「这是一个基于S3C2410的8位按键的驱动程序源代码」· C语言 代码 · 共 43 行

C
43
字号
#include <sys/stat.h>#include <fcntl.h>#include <stdio.h>#include <sys/time.h>#include <sys/types.h>#include <unistd.h> #include<time.h>main(){  int retval;   int fileno;   int ts, maxfd;   int  ret= 0,i,j;   int number;int size;   fileno = open("/dev/buttons",O_RDWR); if (fileno == -1)    {      printf("open device led errr!\n");      return 0;    }/*if(select(fileno+1,NULL,NULL,NULL,NULL)<0){printf("select error");}*/   while(1) {  number=0;  size=read(fileno,&number,1);if(number!=0) {  printf("read %d number\n",size);  printf("key=%d\n",number);  usleep(200000);     }}     close(fileno);   return 0;}

⌨️ 快捷键说明

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