main.c
来自「周立功magic2410实验箱源码 第7章嵌入式Linux驱动开发 7.2 」· C语言 代码 · 共 73 行
C
73 行
/*****************************************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 + =
减小字号Ctrl + -
显示快捷键?