Linux字符设备驱动-毕业论文.doc

上传人:滴答 文档编号:1272882 上传时间:2019-01-26 格式:DOC 页数:42 大小:360KB
下载 相关 举报
Linux字符设备驱动-毕业论文.doc_第1页
第1页 / 共42页
Linux字符设备驱动-毕业论文.doc_第2页
第2页 / 共42页
Linux字符设备驱动-毕业论文.doc_第3页
第3页 / 共42页
Linux字符设备驱动-毕业论文.doc_第4页
第4页 / 共42页
Linux字符设备驱动-毕业论文.doc_第5页
第5页 / 共42页
点击查看更多>>
资源描述

1、 本科毕业论文 (科研训练、毕业设计 ) 题 目: Linux 字符设备驱动 姓 名: 学 院:软件学院 系: 专 业:软件工程 年 级: 学 号: 指导教师(校内): 职称: 指导教师(校外): 职称: 年 月 摘 要 驱动程序在 Linux 内核里扮演着特殊的角色,它们完全隐藏了设备工作的细节。用户通过一套标准化的调用来 操作设备 ,这些调用 是 与特 定 的驱动 相互独立的;设备驱 动的 任务 就是将这些调用映射到作用于实际硬件的 相关 设备操作上。这个编程接口使得驱动可以与内核的其他部分分开建立,并在需要的时候“插入”。这种模块化 的方法 使得 Linux 驱动易写,易于修改。 本文通

2、过在嵌入式 Linux 上实现一个模块化的 RTC 设备驱动实例, 分析了Linux 内核中字符设备驱动的运行机制,并着重介绍了 Linux 字符设备驱动的关键过程,包括基本字符设备驱动, I2C 总线驱动,设备底层操作等。 同时 也展示了通过交叉编译来 开发 和调试 的全过程。 关键词 : 字符设备 ; 设备驱动 ; I2C; 实时时钟 ; 交叉编译 。 Abstract Device drivers take on a special role in the Linux kernel; they hide completely the details of how the device w

3、orks. User activities are performed by means of a set of standardized calls that are independent of the specific driver; mapping those calls to device-specific operations that act on real hardware is then the role of the device driver. This programming interface is such that drivers can be built sep

4、arately from the rest of the kernel and “plugged in“ at runtime when needed. This modularity makes Linux drivers easy to write, easy to modify. Through an instance of realizing a modularized driver of the RTC device in the embedded Linux, this paper analyzes the function mechanism of the char device

5、 driver in detail, and pay more attention on the key process during the development of the Linux char device drivers, including the basic char device driver, the i2c bus driver, the device bottom operation and so on. The paper also presents the whole debug and development process with the cross comp

6、ile method Key words: char device; device driver; I2C; RTC; cross compile. 目 录 第 1 章 引 言 . 1 1.1 Linux 简介 . 1 1.2 设备驱动 . 1 1.3 Linux 驱动 . 2 1.4 选题背景 . 3 第 2 章 字符设备驱动框架 . 4 2.1 注册设备文件 . 4 2.1.1 设备号 . 4 2.1.2 注册设 备号 . 4 2.1.3 释放设备号 . 5 2.1.4 创建设备节点 . 5 2.2 内核设备注册 . 6 2.3 设备操作索引 . 6 2.4 设备操作函数 . 7 2.4.

7、1 Open() . 7 2.4.2 Release(). 7 2.4.3 Read(). 7 2.4.4 Write() . 8 2.4.5 ioctl() . 8 第 3 章 设计与实现 . 9 3.1 设计思路 . 9 3.1.1 设计目标 . 9 3.1.2 解决方案 . 9 3.1.3 最终方案 . 9 3.1.4 细节 . 10 3.1.5 数据流图 . 10 3.2 I2C 总线驱动 . 11 3.2.1 I2C 背景 . 11 3.2.2 传输格式 . 11 3.2.3 标志位 START & STOP. 12 3.2.4 响应 . 13 3.2.5 传输流图 . 14 3.2

8、.6 引脚 地址 . 14 3.2.7 电平设置 . 14 3.2.8 引脚初始化 . 15 3.2.9 I2C 写数据 . 15 3.2.10 写入从机地址 . 16 3.2.11 I2C 读数据 . 16 3.3 RTC 设备驱动 . 17 3.3.1 从机地址 . 18 3.3.2 设备数据地址 . 18 3.3.3 数据编码 . 18 3.3.4 读寄存器数据 . 19 3.3.5 写寄存器数据 . 19 3.3.6 读取时间 . 20 3.3.7 设置时间 . 20 第 4 章 编译调试 . 22 4.1 交叉编译 . 22 4.2 模块 Makefile 设计 . 22 4.3 测

9、试设计 . 24 4.3.1 test.c 设计 . 24 4.3.2 Makefile 设计 . 25 4.4 调试脚本设计 . 26 4.5 调试流程 . 28 4.6 测试结果 . 29 结 论 . 30 致 谢 . 31 参考文献 . 32 Contents Chapter 1 Introduction . 1 1.1 Introduction to Linux . 1 1.2 Device driver. 1 1.3 Linux driver. 2 1.4 Background . 3 Chapter 2 Farmwork of char device driver . 4 2.1

10、Register device files . 4 2.1.1 Device numbers. 4 2.1.2 Register device numbers . 4 2.1.3 Free device numbers . 5 2.1.4 create device node . 5 2.2 Register device in the kernel . 6 2.3 Index of device operation. 6 2.4 Device operation function . 7 2.4.1 Open() . 7 2.4.2 Release(). 7 2.4.3 Read(). 7

11、2.4.4 Write() . 8 2.4.5 ioctl() . 8 Chapter 3 Design and implement. 9 3.1 Design thought . 9 3.1.1 Goal of design . 9 3.1.2 Solution . 9 3.1.3 Adopted solution . 9 3.1.4 Details . 10 3.1.5 Data flow chart. 10 3.2 I2C bus driver. 11 3.2.1 Background . 11 3.2.2 Transport format. 11 3.2.3 Flag bit STAR

12、T & STOP . 12 3.2.4 ACK . 13 3.2.5 Transport flow chart . 14 3.2.6 Address of pins. 14 3.2.7 Set High() . 14 3.2.8 Initialize pins. 15 3.2.9 Write() . 15 3.2.10 Write slave address. 16 3.2.11 Read() . 16 3.3 RTC device driver . 17 3.3.1 Slave address. 18 3.3.2 Device register address . 18 3.3.3 Data

13、 coding . 18 3.3.4 Read from registers . 19 3.3.5 Write to registers . 19 3.3.6 Read time . 20 3.3.7 Write time. 20 Chapter 4 Compile and test . 22 4.1 Cross compile. 22 4.2 Module Makefile. 22 4.3 Testing design. 24 4.3.1 design of test.c. 24 4.3.2 Test Makefile. 25 4.4 Shell design . 26 4.5 Flow o

14、f test. 28 4.6 Testing result . 29 Conclusion . 30 Appreciations . 31 References . 32 - 1 - 第 1章 引 言 1.1 Linux 简介 Linux 操作系统是 UNIX 操作系统的一种克隆系统 ,是一个免费发行的UNIX 操作系统在微机上的实现。它 诞生于 1991 年的 10 月 5 日(这是第一次正式向外公布的时间) ,由芬兰赫尔辛基大学的 Linus Torvalds 完成 。 Linux 的开发得到了遍布于 Internet 上的许多 UNIX 程序员和爱好者的帮助。借助于 Internet 网络, 任何

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文资料库 > 毕业论文

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。