ledshow.c

来自「一个linux 2.6内核下的完整的字符驱动实例」· C语言 代码 · 共 37 行

C
37
字号
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include "stdio.h"#include "sys/types.h"#include "sys/ioctl.h"#include "stdlib.h"#include "termios.h"#include "sys/stat.h"#include "fcntl.h"#include "sys/time.h"int main(){	int on=1;	int led;	int fd;	fd = open("/dev/leds", 0);	if (fd < 0) {		            perror("open device leds");		              exit(1);	                }	printf("leds test show. press ctrl+c to exit  \n");	while(1)		{		   for(led=0;led<5;led++)		   	{		         ioctl(fd, on, led);				 usleep(50000);		   	}		   on=!on;		}	  	close(fd);	return 0;}

⌨️ 快捷键说明

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