- 1、本文档共17页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
第一步:在 Linux 下编写驱动程序
1,在 Linux3.0/driver/ -mkdir hello_me
2,在 hello_me 目录下,新建编写 makefiel 和 Kconfig
makefile 如下:
[csharp] view plaincopyprint?
1. #
2. # Makefile for HELLO_ME_LEDS
3. #
4.
5. # SPI testing only for (using spidev driver)
6. # \file - spi_test.c
7.
8. # \version 1.0.0
9.
10. # \date 2014 年04 月23 日
11.
12. # \author jiangdou jiangdouu88@126.com
13.
14. # Copyright (c) 2014 jiangdou. All Rights Reserved.
15.
16. obj-$(CONFIG_HELLO_ME_LEDS) += leds.o
Kconfig 如下:
[cpp] view plaincopyprint?
1. #
2. # HSI driver configuration
3. #
4.
5.
6.
7. config HELLO_ME_LEDS
8. tristate HELLO_ME LEDS Driver
9.
10. help
11. Say Y here if you want to support the LEDS device
leds.c 如下:
[cpp] view plaincopyprint?
1. #include linux/module.h
2. #include linux/kernel.h
3. #include linux/errno.h
4. #include linux/fs.h
5. #include linux/init.h
6. #include linux/delay.h
7. #include linux/device.h
8. #include asm/uaccess.h
9. #include asm/irq.h
10. #include asm/io.h
11.
12.
13. #if 1
14. #define GPIO_BASE 0x01C20800
15. #define GPE_CFG0 (GPIO_BASE + 0x90) //PE CFG0
16. #define GPE06_CFG (1 24) //配置PE06 为输出模式
17. #define GPE_DATA (GPIO_BASE + 0xA0)
18. #endif
19.
20. /*自动创建设备节点结构体*/
21. static struct class *leddrv_class;
22. /*cfg0 里面有PE06*/
23. volatile unsigned long *gpe_cfg0 = NULL;
24. volatile unsigned long *gpe_date = NULL;
25.
26.
27. /*设备打开函数,当你在应用程序里面对led 执行open 函数这个函数就会被执行*/
28. static int led_
您可能关注的文档
- 第六节 系统结构.ppt
- 第六节.Android操作文件-XML-SD卡-ContentProvider.pptx
- _成渝两地户外LED显示屏设置和亮度的现状调研和分析评价.pdf
- _红楼梦_中的习语与其翻译研究.pdf
- 第六节:自助银行支付.ppt
- Google earth手册课件.pdf
- _胡克_Hooke_定律_的革新_省略_理论及实验数据的格式化整理及应用_罗培林.pdf
- _两重真理说_和人类两难处境.pdf
- 第六节_宴会的礼仪.ppt
- _平面化_表征的提出与产生语境_金哲.pdf
- 2024至2030年中国羚羊角类饮片行业深度调查与前景预测分析报告.docx
- 重庆市面向中国农业大学定向选调2024届大学毕业生2024年国家公务员考试考试大纲历年真题14笔试历.docx
- 重庆市面向西北工业大学定向选调2024届大学毕业生00笔试历年典型考题及解题思路附答案详解.docx
- 中国不动杆菌感染治疗药行业市场现状分析及竞争格局与投资发展研究报告2024-2029版.docx
- 2024至2030年全球与中国ETL软件市场现状及未来发展趋势.docx
- 初中八年级(初二)生物下册期末考试1含答案解析.docx
- 干簧式继电器项目申请报告.docx
- 2024至2030年中国左氧氟沙星片行业深度调查与前景预测分析报告.docx
- 菜籽项目申请报告.docx
- 2024至2030年中国八角钢行业深度调查与前景预测分析报告.docx
文档评论(0)