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

📄 ledshow.c

📁 一个linux 2.6内核下的完整的字符驱动实例
💻 C
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -