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

📄 main.c

📁 linux下的外围键盘及led驱动程序
💻 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 LED'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>#define LED1 	0#define ON 	1#define OFF 	0/********************************************************************************************************** Function name: main()** Descriptions	: Controle led on/off.** Input	: NONE** Output	: NONE** Created by	: Chenxibing** Created Date	: 2005-12-28**-----------------------------------------------------------------------------------------------------** Modified by	:** Modified Date: **-----------------------------------------------------------------------------------------------------********************************************************************************************************/int main(int argc, char **argv){	int i;	int fd;	fd = open("/dev/magic-leds", 0);	if (fd < 0)	{		perror("Failed to open magic-leds");		exit(1);	}	for (i=0; i<5; i++)	{		ioctl(fd, ON,  LED1);		usleep(500000);		ioctl(fd, OFF, LED1);		usleep(500000);	}	close(fd);	return 0;}

⌨️ 快捷键说明

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