基于S3C2410A_D转换Linux驱动程序设计_饶少锋

合集下载

基于S3C2410芯片的嵌入式Linux系统开发环境设计与实现说明书

基于S3C2410芯片的嵌入式Linux系统开发环境设计与实现说明书

6th International Conference on Mechatronics, Materials, Biotechnology and Environment (ICMMBE 2016) Design and Implementation of Embedded LINUX System DevelopmentEnvironment based on S3C2410 ChipXiufang Zhang1, a1 Xi'an Eurasia University, Xi'an, Shaanxi, 710065a emailKeywords:S3C2410 Chip; Embedded; LINUX System DevelopmentAbstract. With the continuous development of China's science and technology, improve people's living standards in the field of electronic information have been developed, especially for the development of S3C2410 chip embedded LINUX system, but also get a lot of attention of enterprises, the following analysis of the development environment process design, to achieve the above, hoping to promote the development of this area, to improve the level of technology in this area.IntroductionIt is no stranger to computers and networks, and their lives are closely linked, with the combination of network technology and computer technology, it is entered into the P C era. In the research and development of embedded systems become the focus of development. Here's to the embedded linux operating system, and Samsung's S3C2410 embedded processor chip, for example, detailed analysis of its design, lay the foundation for future work.Related Part of Embedded SystemsIn a computer system, the host is the main hardware platform, in addition, also constituted by a number of peripheral devices, the computer functions to be accomplished is very strong, so the processor computing speed must be fast, but is separate from the processor and other parts Designed. The embedded processor is the core component of embedded systems, the use of paper S3C2410 embedded processor chip, which not only low energy consumption, and overall performance, low price, low-cost, low-power embedded systems is very good, in addition, there is an embedded software systems.Design and Implementation of Analysis S3C2410 Chip Embedded LINUX System Development EnvironmentFor embedded systems, their systems have a cross-development environment, when established will be used to host / target mode. To facilitate understanding, the following special drawings, reference analysis. For the host, refers to a general-purpose computer system, daily use of PC machine, said here the target development board, embedded system software last program run hardware environment, the host with Ethernet interface, or a string line port [1], it can be done and the target normal communication. For embedded development, it requires the host has a good development environment, so it can perform normal editing and debugging simulation for design work on the software. On this basis, after completion of compiled code, use the Ethernet interface, or a serial port can be decoded are transferred to the target machine, then use after cross debugger, the content analysis and debugging, and finally in a particular environment next, to complete the commissioning program run. CPU used in a computer system [2], are normally developed by Intel Corporation x86 series CPU, but the software needs of embedded operating environment is different, it uses chips are usually PowerPC, DragonBall, MIPS, ARM series, is a micro-processor. In operation, in order for it can be embedded in the hardware environment compiled execution. You should first establish a cross-development environment, and then use cross-developmentenvironment, its effective links and cross-compilation.Figure 1: Embedded Linux cross-development environment Take the arm-linux-gcc example for analysis, which is a source code that can be developed in linux operating system, and then can be compiled into binary code, such code can run on ARM architecture, but also belong to a species cross-compiler. Under normal circumstances all embedded microprocessor, its corresponding embedded system, not a single corresponding to a cross-compiler. In use, you can use the familiar cross-compiler. The computer system will be the preparation of their good [3], then this embedded software after cross-linked to form a new file, which is a binary file, you will be able to run on embedded hardware environment.Among the computer system, the boot program mainly involves two aspects, first, a resource allocation procedure, which solidified in the BIOS, and on the other hand, the extent of which is a guide, in which different boot drive, the embedded in terms of systematic and scientific personnel in order to simplify the hardware architecture, the CPU is embedded not only in curing initiator hardware platforms, many of them embedded hardware platform, do not provide start the program, and therefore its development process, first programming embedded hardware platform boot program. So this level is also known as BootLoader [4]. The section of the program is actually in front of a computer system, run the short main program, run this small program, and its role is very large, the memory space map can be established, the hardware device may be initialized, and then the system hardware and software environment to a proper state, to facilitate future system kernel debugging, it is ready to run needed the right environment. For now, Bootloader used by the program are the following, for example Redhat company developed Redboot program, developed from PPCBoot the U-Boot, and Compaq developed the Bootldr etc., not one will be described. For one of the boot program, the South Korean company developed a Mizi Vivi, which Bootloader is a program that can support S3C2410 processor. In this study, we analyze the S3C2410 processor, so by supporting the boot program uses Vivi. In the application process, we need to Mizi company VIVI guide members download the source code, and then modify the Makefile, on this basis, the operator should also establish a board support package, the rational allocation of development board. After completion of the above-mentioned aspects of the operation of head.s file effectively modified, but it is noteworthy that we must distinguish Nor Falsh and Nand Flash [5], then VIVI recompile the source code allowed to meet the binaries demand, the final step is to carry out programming.For Linux kernel porting, is to determine the specific embedded target platforms, it must effectively streamline Linux, and then mounted to the target platform, on this basis, should also be able to ensure its proper operation. The basic contents include the following items, following specific elaborate. First step, get a version of the Linux kernel source. The second step, combined with the objectives set before the platform, effectively streamlining the source, the main content of the work and structure of the system is to be modified, and then add the drives designed to meet a target platform of the new operating system. After the third step operation, cross-compile target platform for this system, so that it can generate a kernel image file. The fourth step, the image files obtained as described above, in strict accordance with the requirements of programming, can be installed after the completion of the target platform, and then use. Before programming the kernel, the operating system must be streamlined to do, if there are unwanted kernel may well be removed, to avoid system space is occupied, improve the efficiency of system operation and improve system storage space. After completing the streamlining of operations, designers also need to be recompiled, this will work out a new file, the file system used to meet our compressed kernel image file zImage.In the case of the above steps are operating without problems, you can transplant the Linux kernel programming, and ensure the quality of programming.For Linux, the use of the file system organization system in which documents and equipment to provide a uniform interface to the device, and the user program. In addition, it also supports J F F S 2 .RAMDISK, C R A M F S and many other file systems, when using the system, which can YAFFS2 root file system to read and write. For the root file system, which includes a lot of content, for example, the Linux operating system, and it needs at startup directory, key files. Here's an example, if you want to start Linux, will certainly use in the init file to a directory, if the operating system to mount a different partition, then the process is running, you must use the etc / fstab directory mount the file, all of the Linux operating system involved, during the startup process, used to file or directory, the technician can call it Linux system's root file system. For YAFFS2 file system, when the system is running, which can support NAND FLASH, and JFFS there are many similarities, and its role is to design embedded file system. But the Linux operating system and JFFS compared to the reduced part of the function, the operator can be found in actual use, the operating speed of the system is faster and uses less memory.ConclusionThrough the above design and realization of S3C2410 chip embedded LINUX system development environment analysis, analysis of some of its components, to understand the function of the boot program, in addition, also on the embedded linux operating system YAFFS2 file system, Linux kernel porting method carried out a detailed analysis in this regard so that the operator has an overall understanding, reducing the threshold arm embedded development application, promote the development of this technology in the future development, with the related art enhance national attention in this regard, it must be a better development.References[1] Zhu Xiaojun, Zhang Zhibin, Liu Huipeng. realization S3C2410 chip embedded linux systemdevelopment environment based design [J]. Automation and Instrumentation, 2012 (01): 112-113.[2] Zangjin Mei, Tao Xun, Hu Yunling. Realization based S3C2410 embedded Linux developmentenvironment [J]. Chinese e-commerce, 2012 (22): 49-49.[3] Zhu Xiaojun, Zhang Zhibin, Qu Chaocheng. Based design of embedded automotive GPSpositioning system S3C2410 chip [J]. Automation and Instrumentation, 2012 (02): 64-65. [4] Guo Guangming. Design S3C2410A embedded remote video monitoring system [J]. Scienceand Technology Management Research, 2010, 30 (14): 233-235.[5] Xu Min. design S3C2410 embedded video monitoring system [J]. Computer Knowledge andTechnology, 2014 (8): 1802-1803.。

基于S3C2410的嵌入式LINUX下OLED模块驱动设计

基于S3C2410的嵌入式LINUX下OLED模块驱动设计
sizeof (oled_buffer) ) ; for (page = 0 ;page < 8 ;page + + ) { co mmand_o ut ( 0xb0 + i) ; / / 设置
页地址 co mmand_o ut (0x00) ; / / 设置列地
址的低 4 位字节 co mmand_o ut (o x10) ; / / 设置列地
确立 。L CD 具有低辐射 、低能耗 、节省空间等诸 多优点 ,但也存在视角窄 、响应速度慢 、温度范围 小等缺点 。有机电致发光显示器 ( Organic Light Emit ting Display , OL ED) 是一种新型显示器件 , 它的发光层是有机材料层 ,当有电流通过时 ,这些 有机材料就会发光 。与 L CD 相比 ,OL ED 具有自 发光 、功耗小 、显示亮度高 、视角宽 (超过 160°) 、 厚度薄 、- 40 ℃的低温下仍可以正常工作等优 点[1 ,2 ] ,被视为 21 世纪最有可能取代液晶显示器 的平面显示器技术 。现在 ,OL ED 已广泛应用于 手持设备 、通信终端 、仪器仪表等领域 。
owner : T H IS_MODUL E ,
open : oled_open ,
writes : oled_write ,
ioctl : oled_ioctl ,
releases : oled_release , } ; oled_open 操作是打开 OL ED 显示屏 ,oled_ ioctl 用于实现对 OL ED 的各种控制命令 ,oled_ release 操作是关闭 OL ED 显示屏 ,oled_write 操 作是将要显示的数据显示到 OL ED 屏上 。oled_ write 代码如下 : static ssize _ t oled _ write ( st ruct file 3 filp , co nst char 3 buffer ,size_t co unt ,loff_t 3 f_op s) { unsigned char page , j ,oled_buffer[1024] ; cop y_f ro m_user (oled_buffer ,buffer ,

基于S3C2440和Linux的嵌入式驱动程序设计的开题报告

基于S3C2440和Linux的嵌入式驱动程序设计的开题报告

基于S3C2440和Linux的嵌入式驱动程序设计的开题报告一、题目意义S3C2440是指三星公司开发的一款嵌入式微处理器,其性能稳定、功耗低、体积小巧,因此广泛应用于各种嵌入式设备中。

而Linux是目前应用最广泛的开源操作系统之一,其优秀的稳定性和可扩展性,使其成为嵌入式设备的首选操作系统之一。

本课题旨在基于S3C2440和Linux,设计开发一种嵌入式驱动程序,以满足嵌入式设备在使用过程中对于驱动程序的需求。

二、研究内容和目标本课题研究内容主要包括以下方面:1.设计S3C2440与Linux的嵌入式开发环境,包括编译器、调试器和开发板等。

2.研究嵌入式驱动程序的设计原理,包括驱动程序框架、驱动程序接口和驱动程序逻辑等。

3.设计并实现S3C2440和Linux下的嵌入式驱动程序,包括对设备的初始化、操作、控制和数据传输等。

4.测试驱动程序的正确性和稳定性,以及对系统的性能进行优化。

本课题的研究目标是:1.设计开发一种基于S3C2440和Linux的嵌入式驱动程序,使其可以良好地与各种设备进行交互,完成设备的配置和数据传输等相关操作。

2.使得驱动程序的设计和实现更具有可重用性和可扩展性,以适应不同的应用需求。

3.保证驱动程序的稳定性和正确性,通过对系统的性能进行优化,提高系统的响应速度和效率。

三、研究方法和技术路线本课题主要采用以下研究方法和技术路线:1.文献调研法:通过查阅相关的文献,了解嵌入式驱动程序的设计原理和实现方法。

2.实验法:通过实验,测试驱动程序的性能和稳定性,并对系统进行优化。

3.程序设计法:通过程序设计,实现嵌入式驱动程序,并改进其可重用性和可扩展性。

本课题的技术路线如下:1.搭建基于S3C2440和Linux的嵌入式开发环境。

2.设计嵌入式驱动程序的框架和接口,并实现设备的初始化、操作、控制和数据传输等相关操作。

3.进行驱动程序的调试和测试,优化系统的性能和稳定性。

四、预期成果及意义本课题的预期成果包括:1.设计开发一种基于S3C2440和Linux的嵌入式驱动程序,能够满足嵌入式设备在使用过程中对于驱动程序的需求。

基于S3C2440嵌入式Linux的伺服电机控制

基于S3C2440嵌入式Linux的伺服电机控制
操作 。
t c f g 0 1 = ( 5 0 -1 ) ; / / 设 置预 分频 率为 5 0
赫 兹
t c f gl &= ̄ S3 C2 4 1 o _ TCFGI _ _ M UX 1 _ M ASK ;
1 . 1 伺 服 电机的 驱动 与控 制 直 流 伺服 电机 速度 由P WM 的 占空 比来 决定 , 占空 比越 大 电机 转 速 越 大 , 设 置
作。
2. 3主 函数
主 函 数 中循 环 检 测 有 无 按 键 按 下 , 并
2 详细设计
2 . 1 P W M 驱 动
判 断是 哪个 按 键 , 调 用i o c t l 函数 调用 各设 备
高 新 技 术
S C I E N C E &T E C H N 0 L O G Y .
墨圆
基于 ¥ 3 C2 4 4 0嵌 入 式 L i n u x的伺 服 电机控 制
刘 亚 茹 王 贵 山
( 国 防科学 技术 大学 机 电工 程 与 自动化学 院 湖南 长沙
4 1 0 0 0 3 )
c md ) ; //设 置 引脚 状态 o u t — t a b l e [ a r g ] 为 需要 设 置状态 的 引脚 ,
主 函数 主 要 完 成 的 工 作 为 检 测 判 断 按 图 1 嵌入式 L i n u x 的硬件设备驱动过程
下的按键 , 并 调用相应的i o c t l 函数 进 行 操 c md 为 状 态值 。
摘 要: 介 绍一 种基 于¥ 3 C2 4 4 0 微 处理 器 的伺服 电机控 制 方案 。 AR M微 处理 器几乎 已经 深入 到工 业控 制 、 无 线通 讯 、 网络 应 用、 消 费类 电子 产品 , 威像 和安 全 产品各个 领 域 。 本文 实现 基于¥ 3 C 2 4 4 0 的L i f l U X 的 伺服 电机 的按键 控 制 , 控 制 伺服 电机转 动方 向及速 度 , 并通 过 L ED指示 灯 . 蜂 鸣 器等表 征 伺服 电机 的工 作状 态 。 关键 词 : AR M ¥ 3 C 2 4 4 0 L i n u x 伺服 电机 中图分类 号 : T P 2 7 4 文献标识码 : A 文 章编 号 : I 6 7 2 — 3 7 9 I ( 2 o I 3 ) 1 0 ( a ) 一0 0 0 7 — 0 I

嵌入式Linux之我行——S3C2440上MMCSD卡驱动实例开发讲解(二)-内核、驱动开发篇-

嵌入式Linux之我行——S3C2440上MMCSD卡驱动实例开发讲解(二)-内核、驱动开发篇-

嵌入式Linux之我行——S3C2440上MMCSD卡驱动实例开发讲解(二)-内核、驱动开发篇-嵌入式Linux之我行,主要讲述和总结了本人在学习嵌入式linux 中的每个步骤。

一为总结经验,二希望能给想入门嵌入式Linux的朋友提供方便。

如有错误之处,谢请指正。

•共享资源,欢迎转载:一、开发环境•主机:VMWare--Fedora 9•开发板:Mini2440--64MB Nand, Kernel:2.6.30.4•编译器:arm-linux-gcc-4.3.2上接:S3C2440上MMC/SD卡驱动实例开发讲解(一)6. s3cmci_ops SDI主机控制器操作接口函数功能分析:mmc_host_ops结构体定义了对host主机进行操作的各种方法,其定义在Core核心层的host.h中,也就是Core核心层对Host主机层提供的接口函数。

这里各种方法的函数原型如下:从各函数原型上看,他们都将mmc_host结构体作为参数,所以我在刚开始的时候就说过mmc_host结构体是MMC/SD卡驱动中比较重要的数据结构。

可以这样说,他是Core层与Host层进行数据交换的载体。

那么,这些接口函数何时会被调用呢?答案可以在Core 层的core.c和sd.c中找到,我们可以看到如下部分代码:{......//导致s3cmci_card_present被调用if(host->ops->get_cd && host->ops->get_cd(host)== 0)goto out;......}static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, struct mmc_card *oldcard){....../* Check if read-only switch is active.*/if(!oldcard){ //导致s3cmci_get_ro被调用if(!host->ops->get_ro || host->ops->get_ro(host) < 0){printk(KERN_WARNING "%s: host does not ""support reading read-only ""switch. assuming write-enable.\n",mmc_hostname(host));}else{好了,我们开始分析每个接口函数的具体实现吧,从简单的开始吧。

S3C2410GPIO及AD转换

S3C2410GPIO及AD转换

总结与展望
● 优 势 : . 性 能 稳 定 :S3C2410 GPIO及D转 换具 有较 高的 稳定 性能 够保 证数 据的 准确 性和 可靠 性。 b . 兼 容 性 强 : S3C2410 GPIO及D转 换支 持多 种接 口可 以方 便地 与其 他设 备进 行通 信。 c . 功 耗 低 :S3C2410 GPIO及D转换 的功 耗 较低可以降低设备的能耗提高设备的续航能力。
D转换器的精度和速度取决 于其内部结构和算法
工作原理:将模拟信号转 换为数字信号
转换精度:12位
转换速度:100kHz
应用领域:工业控制、医 疗设备、通信设备等
温度测量:通过D转换获取温度传感器的输出信号实现温度测量 压力测量:通过D转换获取压力传感器的输出信号实现压力测量 电流测量:通过D转换获取电流传感器的输出信号实现电流测量 电压测量:通过D转换获取电压传感器的输出信号实现电压测量
S3C2410 GPIO寄存器:用于控 制GPIO引脚的状态和功能
S3C2410 D转换寄存器:用于 控制D转换器的工作模式和数据 读取
S3C2410 GPIO控制寄存器: 用于设置GPIO引脚的输入输 出模式、中断触发方式等
S3C2410 D转换控制寄存器: 用于设置D转换器的采样频率、 分辨率等
GPIO在S3C2410芯 片中的作用
GPIO的基本操作
GPIO的应用场景
GPIO的常见问题及 解决方案
D转换(模数转换)
添加标题
D转换:将模拟信号 转换为数字信号的过 程
添加标题
主要应用:传感器、 音频、视频等领域
添加标题
转换方式:逐次比较、 双积分、逐次逼近等
添加标题
转换精度:取决于DC 的分辨率和采样频率

基于S3c2410和嵌入式Linux的ADC驱动程序实现与应用

基于S3c2410和嵌入式Linux的ADC驱动程序实现与应用

基于S3c2410和嵌入式Linux的ADC驱动程序实现与应用作者:靳光明杜文平来源:《数字技术与应用》2012年第09期摘要:详细介绍s3c2410芯片ADC模块以及Linux的驱动模型,并且通过s3c2410内置的ADC驱动程序设计说明字符型设备驱动开发方法;将驱动编译为模块的方式,单独加载入内核,便于调试。

以超级终端为操作台,控制驱动模块的加载和应用程序的运行。

并通过实例介绍ADC驱动程序在电压测试中的实际应用,从实验结果可以看出ADC驱动可以被成功加载和调用,可以测试电压,或作为工业传感器接口的一部分对现场标准工程量信号进行采集处理。

关键词:S3C2410 ADC Linux 字符设备驱动程序中图分类号:TP311 文献标识码:A 文章编号:1007-9416(2012)09-0094-031、引言近年来,传感测试技术正朝着多功能、微型化、智能化、网络化、无线化方向发展。

无线传感器作为其中的新技术,是目前国内外研究的热点[1]。

随着电子产业数字化程度的不断成熟,目前的控制电路以ARM系统为主体,同时在ARM系统下包含了很多数字电路和模拟电路的混合电路。

所以作为模拟和数字电路的接口A/D、A/D转换器,越来越受到关注。

S3C2410是韩国三星电子公司推出的一款基于ARM920T内核的16/32位RISC嵌入式微处理器[2],s3c2410配合SDRAM、FLASH、网口和串口就构成了基本的ARM嵌入式硬件平台。

嵌入式设备种类繁多的特点决定了不同的嵌入式产品在开发时都必须设计和开发自己的设备驱动程序,使得嵌入式Linux设备驱动程序的开发在整个嵌入式系统开发工作中占有非常重要的地位。

下面分析Linux字符设备驱动程序的结构以及ADC驱动程序的开发方法,本驱动可以测试电压信号,或着作为工业传感器接口的一部分对现场标准工程量信号进行采集处理,本文的硬件平台基于北京博创嵌入式经典平台(UP-S3C2410)。

基于s3c2410和嵌入式Linux的D_A转换的实现

基于s3c2410和嵌入式Linux的D_A转换的实现

技术创新中文核心期刊《微计算机信息》(嵌入式与SOC)2007年第23卷第7-2期360元/年邮局订阅号:82-946《现场总线技术应用200例》ARM开发与应用基于s3c2410和嵌入式Linux的D/A转换的实现ImplementofD/AConversionBasedons3c2410andEmbeddedLinux(鲁东大学)潘辉贾世祥PANHUIJIASHIXIANG摘要:A/D转换和D/A转换是控制系统的基本组成部分。

本文首先介绍了s3c2410如何外接MAX504扩展D/A转换功能,详细的阐述了基于嵌入式Linux操作系统的D/A驱动设计,最后通过实例说明了D/A转换的应用开发方法。

对于基于Linux的嵌入式系统中小型外设的开发具有借鉴意义。

关键字:s3c2410;嵌入式Linux;MAX504;D/A转换;驱动程序中图分类号:TP368.1文献标识码:AAbstract:ADCandDACistheessentialpartofcontrolsystem.ThispaperfirstlyintroduceshowtoextendtheDACfunctionofs3c2410withMax504,thenparticularlyexpoundsthedesignofDACdriverbasedonembeddedLinux,lastlyexplainsthemethodtodeveloptheapplicationofDAC.Sothat,ithavethereferencepurposeforthedevelopmentofmediumandmintypesperipheralofembeddedsystembasedonLinux.Keywords:s3c2410,EmbeddedLinux,MAX504,DAC,Driver文章编号:1008-0570(2007)07-2-0128-021引言在嵌入式应用系统中,特别是智能仪器、仪表、机电设备及装置控制中,需要使用A/D转换将模拟的电量信号转换为数字信号进行处理,而后再将处理的结果通过D/A转换为模拟量实现对被控过程和对象的控制。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

换结束。
PRSCEN: A/D 转换器预分频器使能;0:频器数值;数据值范围:1~255 。
SEL_MUX:
模拟输入通道选择;从 000~111 依次为
通道 AIN0~AIN1。
STDBM: Standby 静 态 模 式 选 择 ;0: 普 通 模 式 ,1:
备等;网络设备是通过套接字来访问的特殊设备。无论是什么
类型的设备,Linux 系统都是通过在内核中维护特殊的设备控制
块来与设备驱动程序接口的。在字符设备和块设备的控制块中,
有一个重要的数据结构 file_operations, 该结构中提供给应用程
序访问硬件设备的各种方法。
该结构实际就是声明了针对各种设备不同操作的函数指
星的 S3C2410X 嵌入式 ARM 微处理器,介绍了在 Linux 操作系统下,对 S3C2410X 微处理器内部 A/D 转换器的驱动方法;通过编写该 A/
D 转换驱动程序,总结出一种在嵌入式 Linux 操作系统下快速方便的开发驱动程序的方法。
关键词: 嵌入式系统; Linux 操作系统; 设备驱动; A/D 转换
Standby 模式。
READ_ START:通过读取来启 动 A/D 转换;0:停止通过读
取启动,1:使能通过读取启动。
ENABLE_START:通过设置该位来启动 A/D 操作;0:无操
作,1:启动转换。
ADCDAT0 为 A/D 转换数据寄存器,16 位寄存器,其中[9: 0] 位 为 转 换 结 果 ,在 此 驱 动 程 序 中 ,只 要 在 转 换 结 束 后 ,读 取 ADCDAT0 的低 10 位就可以得到转换结果。
来完成设备驱动程序的注册和卸载 (其中 mydev_init 和 my-
dev_cleanup 函数即为用 __init 和 __exit 声明的初始化函数和清
除函数)。本驱动程序程序是使用后一种方法。
在本驱动程序中初始化函数为 adc_init 主要完成一些初始
化的工作,它完成硬件设备的初始化和向操作系统内核注册该
通过查阅 S3C2410X 芯片资料,A/D 转换驱动程序中主要用 的寄存器有两个 ADCCON 和 ADCDAT0。其基本的描述如下表:
饶少锋: 硕士研究生
ADCCON 是 A/D 转换的控制寄存器,它是一个 16 位的寄存器, 寄存器的功能位定义如下:
ECFLG: A/D 转换结束标志;0:表示转换中,1:表示转
{
int ret;
ret =register_chrdev (DEVICE_MAJOR,DEV_NAME,
&adc_fops);
if (ret<0)
{ printk(DEV_NAME "cannot get major number! \n"); return ret; } printk("adc device register success! \n"); ADCCON=(1<<14)|(19<<6)|(4<<3)|(0<<2); return 0; } 其中 ADCCON=(1<<14)|(19<<6)|(4<<3)|(0<<2); 就是对 ADC 控制器的硬件初始化,1<<14 是转换预分频器 PRSCEN 使能; 19<<6 指设置预分频值 PRSCVL, 本驱动程序预分频值设置为 19, 若 PCLK 频率是 50MHz 且 ADCCON 寄存器中预分频器的 设置值是 19 时,转换得到 10 位数字量时间: A/D 转换器频率= 50 MHz/(19+1) = 2.5 MHz , 转换时间= 1/(2.5MHz / 5 周期) = 2 us ; 4<<3 指 A/D 转换通道的选择通道 AIN4,即 SEL_MUX 为[1 0 0];0<<2 A/D 转换模式的选择,0 即选择普通模式。 adc_read 函数为应用程序系统调用 read 时调用的函数,也 是 A/D 转换驱动程序的关键方法,在应用程序使用 read 系统调 用时,adc_read 函数被调用,它会通过设置 ADCCON 的第 0 位 ENABLE_START 为 1 来启动 A/D 转换,该位会 A/D 转换开始 后又硬件自动清零。然后程序等待 A/D 转换结束,通过查询 A/D 转换结束标志 ECFLG,即 ADCCON 的第 15 位,若该位为 1 表 示结束,为 0 表示正在转换中。A/D 转换结束后,即可读取 ADC 数据寄存器 ADCDAT0 的低 10 位到 ADC 设备的缓冲区中,应 用程序就是通过该缓冲区接口得到 A/D 转换数据的,该函数的 代码如下: static ssize_t adc_read (struct file *filp,char *buffer,size_t count,loff_t* ppos) { int adc_data=0; ADCCON|=0x1; while(ADCCON&0x1); while(! (ADCCON&0x8000)); adc_data=ADCDAT0&0x3ff; udelay(100); copy_to_user(buffer,(char *)&adc_data,sizeof(int)); return sizeof(char); }
中图分类号: TP368.1
文献标识码: A
Abstract: Embedded operating system such as the applications of ARM -Linux have become more and more popular. Because all kinds of embedded devices are different each other, we should design and develop its own device driver in the developing of the different embedded products.This makes embedded Linux device driver development occupy a heavy proportion in the whole cycle of embedded systems development. In this paper, the interface method of internal A/D converter was presented based on the Samsung S3C2410X embedded ARM microprocessor. In the preparation of A/D converter driver programming, the hardware-driven approach in Linux operating system was introduced, and a rapid and convenient development driver approach in embedded Linux operating system was also summed up in this paper. Key words: embedded systems; Linux operating system; device driver; A/D convert
3 驱动程序的设计
linux 驱动程序为应用程序屏蔽了硬件的细节, 它为应用程
《P LC 技术应用 200 例》
邮局订阅号:82-946 360 元 / 年 - 177 -
ARM开 发 与 应 用
中文核心期刊《微计算机信息》(嵌入式与 S OC )2008 年第 24 卷第 11-2 期
序提供了一组典型的操作接口。通过这个接口,用户可以像处
您的论文得到两院院士关注 文 章 编 号 :1008-0570(2008)11-2-0177-03
ARM开 发 与 应 用
基于 S3C2410 A/D 转换 Linux 驱动程序设计
The Linux Driver Programming Based on S3C2410 A/D Converter
转换的硬件驱动,它在 file_operations 结构中的初始化代码如
下:

static struct file_operations adc_fops={
owner: THIS_MODULE,

open: adc_open,
release:adc_release,

read: adc_read,
技 术 创 新
1 引言
随着电子和计算机技术的不断发展,嵌入式系统已经被广 泛的应用于很多领域中,从智能玩具到航空航天,嵌入式系统的 应用在某程度上可以说是无处不在,但是随着信息化的发展,又 给嵌入式系统的开发和应用带来了新的挑战。在嵌入式 Linux 系统的开发中,嵌入式设备种类繁多的特点决定了不同的嵌入 式产品在开发时都必须设计和开发自己的设备驱动程序,使得 嵌入式 Linux 设备驱动程序的开发在整个嵌入式系统开发工作 中占有举足轻重的地位。而基于 ARM 架构的中高档的嵌入式 系统应用已经非常广泛,本文针对现在非常流行的一款三星公 司生产的 ARM9 嵌入式微处理器—S3C2410X,在 Linux 操作系 统下实现了对 AD 转换的驱动,通过该驱动程序实例,介绍在 Linux 系统下驱动程序编写的一般方法,包括驱动程序和测试程 序的编写。
设备驱动程序的主设备号和设备名称,每一个设备驱动程序都
有唯一的一个主设备号,对于同一个驱动程序可以驱动同一类
型不同的设备,而这些设备之间是通过驱动程序的次设备号来
区分的。对于字符设备驱动程序,是通过 register_chrdev 函数来
相关文档
最新文档