实验十二-LCD驱动.docVIP

  • 11
  • 0
  • 约6.53千字
  • 约 11页
  • 2018-06-14 发布于上海
  • 举报
实验12 LCD驱动 实验目的 熟悉framebuffer驱动框架; 掌握framebuffer驱动程序设计方法; 实验原理 Framebuffer设备是嵌入式系统中的常用的显示设备。 在linux内核中,framebuffer驱动程序是标准的字符设备驱动程序,主设备号是29。Framebuffer驱动程序的框架如下图: 在FrameBuffer中,fb_info可以说是最重要的一个结构体,它是Linux为帧缓冲设备定义的驱动层接口。它不仅包含了底层函数,而且还有记录设备状态的数据 Ion Memory Manager M samsung S3C framebuffer support //将这个选项选择为M [ ] Bootup logo 4 在开发板上测试驱动程序 启动运行linux系统; 先看看刚刚启动的系统有没有framebuffer驱动; $ ls  /dev/fb0   //查看fb0设备文件,不存在表示没有驱动 插入framebuffer驱动模块; $ insmod cfbcopyarea.ko //在内核/drivers/video目录下 $ insmod cfbfillrect.ko //在内核/drivers/video目录下 $ insmod cfbimgblt.ko //在内核/drivers/video目录下 $ insmod lcd_drv.ko $ ls /dev/fb0 //再看看设备文件在不在 交叉编译测试程序 #includestdio.h #includestdlib.h #includesys/types.h #includesys/stat.h #includefcntl.h #includeunistd.h #includesys/mman.h #include string.h int main(void) { int fd = open(/dev/fb0, O_RDWR); if(fd 0) { perror(open lcd fail); return -1; } unsigned int *p = mmap(NULL, 800*480*4, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if(p == (void *)-1) { perror(mmap fail); close(fd); return -1; } memset(p, 0xff, 800*480*4); int picfd = open(./bbb.bmp, O_RDWR);//注意图片文件名字 if(picfd 0) { perror(open pic fail); return -1; } unsigned char *ppic = mmap(NULL, 800*480*3+54, PROT_READ|PROT_WRITE, MAP_SHARED, picfd, 0); if(p == (void *)-1) { perror(mmap fail); close(picfd); return -1; } ppic += 54; int x,y; for(y=0;y480;y++){ for(x=0;x800;x++) { *(p+x+(480-1-y)*800)= (*ppic16)|(*(ppic+1)8)|(*(ppic+2)0); ppic+=3; } } munmap(p, 800*480*4); munmap(ppic, 800*480*3+54); close(fd); close(picfd); return 0; } 找一幅800*480像素,24bits的BMP图片,运行测试程序 查看LCD屏上有没有显示 实验完成后,可以举手叫老师过来检查,以作平时成绩加分! lcd_drv.c #include linux/module.h #include linux/init.h #include linux/kernel.h #include linux/clk.h #include linux/fb.h #include linux/io.h #include linux/dma-mapping.h #include mach/gpio.h #include mach/map.h #include plat/gpio-cfg.h static struct fb_info *sice_fbinfo; static struct clk *bus_clk; st

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档