test1.c

来自「2440 下的5*5按键驱动程序.请参看具体代码内容.」· C语言 代码 · 共 30 行

C
30
字号
#include <sys/stat.h>#include <fcntl.h>#include <stdio.h>#include <sys/time.h>#include <sys/types.h>#include <unistd.h>


main()
{
   int retval;
   int fileno;
   int ts, maxfd;
   int ret= 0,i,j;
   int number;
   fileno = open("/dev/button",O_RDWR);
       if (fileno == -1) {
               printf("open device led errr!\n");
               return 0;
              }	printf ("open succeed");
   while(1) {
   read(fileno,&number,1);
   printf("key=0x%x\n",number);
    }
   close(fileno);
   return 0;

}

⌨️ 快捷键说明

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