- 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
您可能关注的文档
- 三年级下册数学小数初步认识教学课件-.ppt
- 山东人民版六年级下册品德和社会期末模拟试题6.doc
- 山东省临沂市2017-2018年高二下学期期中联考历史试题.doc
- 山东省临沂市2017-2018年高二下学期期中联考语文试题.doc
- 山东省临沂市2017年中考生物真题考试试题(含解析).doc
- 汕头市2015年普通高中高一数学教学质量监测试题和答案.doc
- 上海中考英语读音规则题解题方法与真题演练.docx
- 上交所-固定收益证 券综合电子平台-外部数据接口规范.doc
- 姗姗桥钻孔灌注桩首件典型施工方案设计20170822.doc
- 少先队活动课《小节俭大用场》.ppt
- 河北盐山中学等校2025-2026学年上学期高三一模化学试卷(含解析).docx
- 河北正定中学2025-2026学年高一上学期期末考试物理试卷(含解析).docx
- 河北张家口市怀安县2025-2026学年第一学期期末教学综合评价八年级地理试卷(含解析).docx
- 河南安阳市殷都区2025-2026学年第一学期期末教学质量检测七年级地理试卷(含解析).docx
- 河南安阳市滑县2025一2026学年第一学期期末学业质量监测八年级地理试题(含解析).docx
- 河南安阳市林州市2025-2026学年上学期期末考试高一政治试题(含解析).docx
- 河南焦作市武陟县第一中学2025-2026学年高一上学期1月月考语文试卷(含解析).docx
- 河南济源市2025-2026学年上学期期末学业质量调研七年级历史试卷(含解析).docx
- PICC导管并发症的紧急处理与护理.pptx
- 河南鹤壁市2025-2026学年高二上学期期末考试生物试题(含解析).docx
原创力文档

文档评论(0)