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

📄 test2.c

📁 基于嵌入式Linux系统的led驱动程序开发源程序及详细文档
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

int main()
{
	int fd;
	int i;
	char drv_buf[8][2] = {0x60,0x00,0x61,0x01,0x62,0x02,0x63,0x03,0x64,0x040,0x65,0x05,0x66,0x06,0x67,0x07};
	char drv_buf1[8][2] = {0x60,0x1f,0x61,0x1f,0x62,0x1f,0x63,0x1f,0x64,0x1f,0x65,0x1f,0x66,0x1f,0x67,0x1f};
	char drv_buf2[16][2]= {0x60,0xc0,0x60,0x1f,0x61,0xc1,0x61,0x1f,0x62,0xc2,0x62,0x1f,0x63,0xc3,0x63,0x1f,
		                   0x64,0xc4,0x64,0x1f,0x65, 0xc5,0x65,0x1f,0x66,0xc6,0x66,0x1f,0x67,0xc7,0x67,0x1f};

	fd=open("/dev/led2",O_RDWR);
	if(fd < 0){
		printf("####DEMO device open fail####\n");
		return (-1);
	}

 for(i = 0;i < 8; i++)
	 write(fd, drv_buf[i], 2);
 sleep(1);
 for(i = 0;i < 8; i++)
	 write(fd, drv_buf1[i], 2);
 sleep(1);
 for(i = 0;i < 8; i++)
	{
	 write(fd, drv_buf2[2*i], 2);
	 sleep(1);
	 write(fd, drv_buf2[2*i+1], 2);
	}    
	close(fd);
}

⌨️ 快捷键说明

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