收藏 分享(赏)

hello驱动.ppt

上传人:buyk185 文档编号:7314102 上传时间:2019-05-14 格式:PPT 页数:19 大小:1.02MB
下载 相关 举报
hello驱动.ppt_第1页
第1页 / 共19页
hello驱动.ppt_第2页
第2页 / 共19页
hello驱动.ppt_第3页
第3页 / 共19页
hello驱动.ppt_第4页
第4页 / 共19页
hello驱动.ppt_第5页
第5页 / 共19页
点击查看更多>>
资源描述

1、hello驱动加载,hello驱动,涸豫灵斩伟抛徒灌想造坛惹狂持詹映胀酒揖忙补泻怂怒布劈驾沪中手四蛔hello驱动hello驱动,任务要求,要求:对开发板上的hello驱动加载 实现: 1、驱动设计(在linux内核中加入hello驱动),焕珊逐型捡屯坷网禁幂肾蛹芳亮肾酷侄卓懈返莽适灶粟五逛愚彰晾侈劳星hello驱动hello驱动,驱动编写,第一步:进入/opt/EmbedSky/linux-2.6.30.4/drivers/char目录 cd drivers hello属于字符设备 cd char进入char目录 第三步:编写hello.c驱动源程序 gedit wyl.c,忙寞侥川虾吨核苛

2、蕊泅蔬芯悔晕堆小垢逐家号券召寐待甄敝遇皖撼义论蘸hello驱动hello驱动,第一步、编写驱动,1头文件 2注册函数 3卸载函数 4模块信息,掳健谜暴撇谎痛轩镍徘酶蠢沫乾视轧罐悼豹门贴般鹊偿诀乖逞洗昌妹瞩粒hello驱动hello驱动,第二步、修改配置文件Kconfig,gedit Kconfig,添加驱动选项,航花蚕云怜擞蛊碳灿午寄凿银亥痊李凝辆铡最邦橱压诌撼忌掂挑恐脯柜侠hello驱动hello驱动,第三步、修改Makefile,gedit Makefile 添加,名字与.c文件名一致,万肮涨茎企臀积于众锨玄损赫漳向莎辫符广舔压庸辗惹速钝衬逆繁酌谬横hello驱动hello驱动,第四步、m

3、ake menuconfig,退到根目录 执行make menuconfig,Device driversCharacter devices,找到你新添加的设备,棺裂哮竟喻圃慈预昭顺蹋策故夕炭框安奥烯如辊贪悬砷蝴聋沪壮拈宦毒抛hello驱动hello驱动,选择,三种 M作为模块选择,陪砒吭柜赠猪荐液小翔尤蛆疙眩懈洒井嫂菱句套崩嘲淤浴女年双第套痰边hello驱动hello驱动,第五步 编译,执行make 生成驱动模块手动安装,渐掳洪熏骚苯痉绚远挫烫恐乱猪诅靶排驻体江度氖团汪梧释撤蒸属嚏校叼hello驱动hello驱动,调试,运行,第一步,安装 insmod EmbedSky_hello.ko 第

4、二步,运行应用程序 效果很好!,氏敖欺沥哩者纸岁封蚊蓉渡振嘲赶起脊莲售凳给货鹰祁伍咒挽帅甲俱藕养hello驱动hello驱动,模块卸载,rmmod /lib/zjl_hello.ko加载模块,莫锯邑嫡评垛缓鹏还朗硼葱颇熄喝扎趁倦舔直善镀伞膝蓖阑移苦嘴滴膝划hello驱动hello驱动,任务:按键控制LED等,1、编写按键驱动 2、编写应用程序,链区早非欢檄算艺擎标棕炽肘像臀控储质鲤导虎踪枪缀渍缨把奠呆执掷隧hello驱动hello驱动,按键电路,掖编腿电晴凝伤粹萄耶蔷秦野窖御晋奖掀咕胖廉煤鞍哆虾氖掠赣墒兄耻逸hello驱动hello驱动,#include #include #include #

5、include #include #include #include #include #include #include #include #include #include #include #include #define DEVICE_NAME “keys“struct button_irq_desc int irq;int pin;int pin_setting;int number;char *name; ;,按键驱动采用中断,勒释抒缕纸趟丫倾综腾刘秒址坞命庙伙宜拟专蝎茂谚叹要巧愿感豺纳者誉hello驱动hello驱动,#if !defined (CONFIG_SKY2440_IR

6、Q_TEST) static struct button_irq_desc button_irqs = IRQ_EINT1, S3C2410_GPF1, S3C2410_GPF1_EINT1, 0, “KEY1“, /* K1 */IRQ_EINT4, S3C2410_GPF4, S3C2410_GPF4_EINT4, 1, “KEY2“, /* K2 */IRQ_EINT2, S3C2410_GPF2, S3C2410_GPF2_EINT2, 2, “KEY3“, /* K3 */IRQ_EINT0, S3C2410_GPF0, S3C2410_GPF0_EINT0, 3, “KEY4“,

7、/* K4 */ ; #else static struct button_irq_desc button_irqs = IRQ_EINT9, S3C2410_GPG1, S3C2410_GPG1_EINT9, 0, “KEY1“, /* K1 */IRQ_EINT11, S3C2410_GPG3, S3C2410_GPG3_EINT11, 1, “KEY2“, /* K2 */IRQ_EINT2, S3C2410_GPF2, S3C2410_GPF2_EINT2, 2, “KEY3“, /* K3 */IRQ_EINT0, S3C2410_GPF0, S3C2410_GPF0_EINT0,

8、3, “KEY4“, /* K4 */ ; #endif,static volatile int press_num = 0,0,0,0;static volatile int ev_press = 0; static DECLARE_WAIT_QUEUE_HEAD(keys_waitq);static irqreturn_t interrupt_keys(int irq,void *dev_id) volatile int *press_cnt = (volatile int *)dev_id;*press_cnt=*press_cnt+1;ev_press = 1;wake_up_inte

9、rruptible( ,阳丁镰附瘦锌揽植潘掌骏裕攘枯分董肝靳氢义曰喂留虫钥游托顷桩开驼穿hello驱动hello驱动,static int keys_open(struct inode *inode,struct file *file) int num,i;for(i=0;isizeof(button_irqs)/sizeof(button_irqs0);i+)num=request_irq(button_irqsi.irq,interrupt_keys,IRQ_TYPE_EDGE_FALLING,button_irqsi.name,(void *) ,绵殆注秋堑矛惠清恨婉枢楞诱质奸卓多祥萎汪

10、挺有巴牧妻雪压理浩彩帛念hello驱动hello驱动,static struct file_operations dev_keys_fops = .owner = THIS_MODULE,.open = keys_open,.read = keys_read,.release = keys_close,; static struct miscdevice misc_keys = .minor = MISC_DYNAMIC_MINOR,.name = DEVICE_NAME,.fops = ,汞重翼脂责第硝饲壁愚蒸孽胡拿辰炎脓厚啮苗算俘奠泵梯克厚恿骚仅钾辟hello驱动hello驱动,编写驱动,

11、按照前面的步骤编译为模块,霸层娠赢淡值桃翁援仕阅坚拂杆侵莲俗重涂万透籍舆色简装宰塑鼓配仁浦hello驱动hello驱动,#include #include #include #include #include #include #include #include #include #include ,int main(void) int fd; int num,i; int press_num4=0,0,0,0;fd=open(“/dev/keys“,0);for(i=0;isizeof(press_num);i+) num=read(fd, ,编写应用程序,损努瓢特漓宿舶弦韩点枪藩永铰息菇随隶匆女灯维婴譬恰裂捡浊适苟崖吓hello驱动hello驱动,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报