收藏 分销(赏)

《Arm驱动程序设计》PPT课件.ppt

上传人:精*** 文档编号:2576364 上传时间:2024-06-01 格式:PPT 页数:19 大小:403.50KB
下载 相关 举报
《Arm驱动程序设计》PPT课件.ppt_第1页
第1页 / 共19页
《Arm驱动程序设计》PPT课件.ppt_第2页
第2页 / 共19页
《Arm驱动程序设计》PPT课件.ppt_第3页
第3页 / 共19页
《Arm驱动程序设计》PPT课件.ppt_第4页
第4页 / 共19页
《Arm驱动程序设计》PPT课件.ppt_第5页
第5页 / 共19页
点击查看更多>>
资源描述

1、Arm驱动程序设计LED灯驱动1可整理ppt任务要求要求:对开发板上的LED灯点亮实现:两部分1、驱动设计(在linux内核中加入LED驱动)2、应用程序实现(应用程序调用驱动实现点亮)2可整理ppt硬件原理图3可整理ppt驱动编写第一步:解压源码我们要编写的驱动是对应于LED第二步:进入drivers目录cd driversLED属于字符设备cd char进入char目录第三步:编写led-test.c驱动源程序gedit led-test.c4可整理ppt第一步、编写驱动包括6部分1头文件2注册函数3卸载函数找一个类似的驱动打开,编写首先把头文件全部copy4定义设备名#define DE

2、VICE_NAME leds“5硬件引脚定义6模块信息#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include 5可整理ppt1加入硬件引脚static unsigned long gpio_table =S3C2410_GPB5,S3C2410_GPB6,S3C2410_GPB7,S3C2410_GPB8,;static int leds_init

3、(void)static void leds_exit(void)2编写注册函数3编写卸载函数4加入模块信息module_init(leds_init);module_exit(leds_exit);MODULE_LICENSE(GPL);MODULE_AUTHOR(zjl);static unsigned int gpio_cfg_table =S3C2410_GPB5_OUTP,S3C2410_GPB6_OUTP,S3C2410_GPB7_OUTP,S3C2410_GPB8_OUTP,;说明引脚功能,输出6可整理pptstatic int leds_init(void)int ret;re

4、t=misc_register(&misc_leds);if(ret 4)return-EINVAL;s3c2410_gpio_setpin(gpio_tablearg,cmd);return 0;default:return-EINVAL;10可整理ppt完整的驱动程序#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#inc

5、lude#include#include#define DEVICE_NAME leds/*用来指定用来指定LED所用的所用的GPIO引脚引脚*/static unsigned long gpio_table =S3C2410_GPB5,S3C2410_GPB6,S3C2410_GPB7,S3C2410_GPB8,;/*用来指定用来指定GPIO引脚的功能:输出引脚的功能:输出*/static unsigned int gpio_cfg_table =S3C2410_GPB5_OUTP,S3C2410_GPB6_OUTP,S3C2410_GPB7_OUTP,S3C2410_GPB8_OUTP,;

6、11可整理pptstatic struct file_operations dev_leds_fops=.owner=THIS_MODULE,.open =leds_open,.ioctl=leds_ioctl,;static struct miscdevice misc_leds=.minor=MISC_DYNAMIC_MINOR,.name =DEVICE_NAME,.fops =&dev_leds_fops,;static int leds_init(void)int ret;ret=misc_register(&misc_leds);if(ret 4)return-EINVAL;s3c

7、2410_gpio_setpin(gpio_tablearg,cmd);return 0;default:return-EINVAL;12可整理ppt第二步、修改配置文件Kconfiggedit Kconfig,添加驱动选项13可整理ppt第三步、修改Makefileogedit Makefileo添加名字与.c文件名一致14可整理ppt第四步、make menuconfigo退到根目录o执行make menuconfigDevice drivers Character devices找到你新添加的设备15可整理ppt选择o三种空白不选*内核选择M作为模块选择16可整理ppt第五步 编译o执行

8、make zImageo下载新的内核文件o驱动制作完成17可整理ppt下一步、编写应用程序#include#include#include#include int main(int argc,char*arg)int fd;fd=open(/dev/leds,0);if(fd 0)printf(TQ2440 leds open failed!n);ioctl(fd,1,0);ioctl(fd,0,1);ioctl(fd,1,2);ioctl(fd,1,3);close(fd);return 0;调用驱动18可整理ppt调试,运行o第一步,下载zImageo第二步,运行应用程序o效果很好!19可整理ppt

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 教育专区 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服