⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 基于ARM9的LINUX下的按键驱动程序
💻 C
字号:
/*****************************************Copyright (c)****************************************************                               Guangzhou Zhiyuan Electronic Co.,LTD.**                                     graduate school**                                 http://www.zyinside.com****------------------------------------- File Info ------------------------------------------------------** File name:           main.c** Last modified Date:  2005-12-28** Last Version:        1.0** Descriptions:        Test program for KEY1's driver.**------------------------------------------------------------------------------------------------------** Created by:          Chenxibing** Created date:        2005-12-27** Version:             1.0** Descriptions:        Preliminary version.****------------------------------------------------------------------------------------------------------** Modified by:** Modified date:** Version:** Descriptions:***********************************************************************************************************/#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <sys/ioctl.h>#include <errno.h>#include <fcntl.h>#include <sys/types.h>//#include <sys/time.h>//#include <sys/stat.h>/********************************************************************************************************** Function name: main()** Descriptions	: Read KEY's value and Pressed times.** Input	: NONE** Output	: NONE** Created by	: Chenxibing** Created Date	: 2005-12-27**-----------------------------------------------------------------------------------------------------** Modified by	:** Modified Date: **-----------------------------------------------------------------------------------------------------********************************************************************************************************/int main(int argc, char **argv){	int fd;	int result;	int key_value;	int times = 1;	fd = open("/dev/magic-key", 0);	if (fd < 0)	{		perror("Failed to open magic-key\n");		exit(1);	}		while(times < 10)	{		result = read(fd, &key_value, sizeof(key_value)) == sizeof(key_value);		if (!result)		{			if (errno == EINVAL)				printf("Wrong size!\n");			goto exit;			}		printf("KEY1's value is %d ;", key_value);		printf(" Be pressed %d times\n", times++);	}exit:	close(fd);	return 0;}

⌨️ 快捷键说明

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