易截截图软件、单文件、免安装、纯绿色、仅160KB

ARM嵌入式LINUX设备驱动设计入门学习

  经过一段时间的学习之后,也开发了一些小型的驱动,正如我之前一篇中写到得,现在我就来写一下在ARM嵌入式LINUX下如何设计驱动的框架。
        在这里我用的板子是micro2440板子,板子上的linux版本是2.6.13。因为我在前一篇介绍了驱动编程的两种框架设计,所以现在我就来分别写一下这两种框架设计的程序。
开发平台:RED HAT LINUX 9(Linux 2.4.18)
开发板:micro2440(友善之臂)(Linux 2.6.13)
交叉编译工具:arm-linux-gcc-3.4.1
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
2.4内核驱动框架:
static int __init leds_init(void)
{
 int result;
 int i;
 result = register_chrdev(LED_MAJOR, DEVICE_NAME, &leds_fops);
 if(result < 0){
  printk(DEVICE_NAME "can't register major number\n");
  return result;
 }
 
// static devfs_handle_t devfs_handle;
// devfs_handle = devfs_register(NULL, DEVICE_NAME, DEVFS_FL_DEFAULT, LED_MAJOR, &leds_fops, NULL);
/*
*之所以不用devfs_register,而用devfs_mk_cdev,原因是因为在linux2.6内核里没有devfs_register函数,而改用*devfs_mk_cdev
*/
 devfs_mk_cdev(MKDEV(LED_MAJOR, 0), S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, DEVICE_NAME);
 for(i = 0; i < 4; i++){
  s3c2410_gpio_cfgpin(led_table[i], led_cfg_table[i]);
  s3c2410_gpio_setpin(led_table[i], 1);
 }
 printk(DEVICE_NAME "initialized\n");
 return 0;
}
static void __exit leds_exit(void)
{
 devfs_remove(DEVICE_NAME);
 unregister_chrdev(LED_MAJOR, DEVICE_NAME);
}
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
2.6内核驱动框架:
static int __init leds_init(void)
{
 int result;
 int i;
&nbs


相关文档:

实战Linux Bluetooth编程(三) HCI层编程

1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI)  就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......

Linux设备模型之input子系统详解

一:前言
最近在研究android的sensor driver,主要是E-compass,其中用到了Linux input子系统.在网上也看了很多这方面的资料,感觉还是这篇分析的比较细致透彻,因此转载一下以便自己学习,同时和大家分享!
(这篇博客主要是以键盘驱动为例的,不过讲解的是Linux Input Subsystem,可以仔细的研究一下!)
键盘驱动将检 ......

linux下动态库与静态库

体验一下linux下编写和使用动态库与静态库,范例:helloworld程序。
首先编写静态库:
hellos.h
 #ifndef _HELLO_S_H
#define _HELLO_S_H
void prints(char *str);
#endif
 
hellos.c
#include "hellos.h"
#include <stdio.h>
void prints(char *str)
{
printf("print in sta ......

(转载)linux下loop device的使用

http://en.wikipedia.org/wiki/Loop_device
In Unix-like operating systems, a loop device, vnd (vnode disk), or lofi (loopback file interface) is a pseudo-device that makes a file accessible as a block device.
所谓loop device指的就是拿文件来模拟块设备。
Albert Woodhull语:"The Linux loop device can ......

Linux IP设置

Linux IP设置
修改ip:
编辑文件/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 //设备名称,不要修改
BOOTPROTO=static //不要修改
BROADCAST=10.10.22.255 //广播地址,一般为本网段的最后一个IP
IPADDR=10.10.22.145 //ip地址
NETMASK=255.255.255.0 //子网掩码
NETWORK=10.10.22.0 //网段地址
ONBOOT ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号