test.c

来自「李亚锋出的书《ARM嵌入式LINUX设备驱动实例开发》一书的码源!」· C语言 代码 · 共 43 行

C
43
字号
/*
 * File Name: test.c
 *
 * Descriptions: 
 *		The test code of buttons module driver.
 *
 * Author: 
 *		Mike Lee
 * Kernel Version: 2.6.20
 *
 * Update:
 * 		-	2007.07.23	Mike Lee	 Creat this file
 */#include <sys/stat.h>#include <fcntl.h>#include <stdio.h>#include <sys/time.h>#include <sys/types.h>#include <unistd.h>main(){   int fileno;   int number;   fileno = open("/dev/buttons",O_RDWR);   if (fileno == -1)   {   	printf("open buttons device errr!\n");	return 0;   }   while(1)    {   	read(fileno,&number,1);   	printf("key=0x%x\n",number);   }   close(fileno);   return 0;}

⌨️ 快捷键说明

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