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

linux字符设备驱动学习

 今天学习了在linux2.6平台下的 char drvier ,在linux下推荐使用的是cdev结构体来实现对character设备的描述,代码如下
/*This module is desired for sunplusapp s3c2440_board */
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/cdev.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <asm/uaccess.h>
#include <linux/errno.h>
#include <mach/regs-gpio.h>
#include <mach/hardware.h>
#include <linux/platform_device.h>
#include <linux/mm.h>
#include <linux/sched.h>
#include <asm/io.h>
#include <asm/system.h>
#define DEVICE_NAME "LED_S3C2440"
struct LED_dev{
 struct cdev cdev;
 char name[10];
 /*...*/
}*LED_devp;
static dev_t LED_device_num;
static struct class *LED_class;
//struct class *LED_class;
static unsigned long LED_table[]={
 S3C2410_GPG0,
 S3C2410_GPG1,
 S3C2410_GPG2,
};
static unsigned int LED_cfg_table[]={
 S3C2410_GPG0_OUTP,
 S3C2410_GPG1_OUTP,
 S3C2410_GPG2_OUTP,
};
int LED_open(struct inode *inode, struct file *filp)
{
  /*将设备结构体指针赋值给文件私有数据指针*/
  filp->private_data = LED_devp;
  printk("Open OK\n");
  return 0;
}
/*文件释放函数*/
int LED_release(struct inode *inode, struct file *filp)
{
 printk("Release OK\n");
  return 0;
}
static ssize_t LED_write(struct file *filp,const char __user *buf,size_t size,loff_t *f_pos)
{
  unsigned char buff = 0;
  int ret;
  int i;
  /*用户空间->内核空间*/
  if (copy_from_user(&buff, buf, size))
    ret =  - EFAULT;
   
 printk("write:buff=0x%x,buff=0x%x,count=%d\n", buff, buf, size);
 buff-=0x30;
 for(i=0;i<3;i++)
 {
  if(i==buff)
   s3c2410_gpio_setpin(LED_table[i],1);
  else
   s3c2410_gpio_


相关文档:

实战Linux Bluetooth编程 (七) SDP协议

Service Discovery Protocol(SDP)提供一种能力,让应用程序有方法发现哪种服务可用以及这种服务的特性。
服务发现协议(SDP或Bluetooth SDP)在蓝牙协议栈中对蓝牙环境中的应用程序有特殊的含意,发现哪个服务是可用的和确定这些可用服务的特征。SDP定义了bluetooth client发现可用bluetooth server服务和它们的特征的方法。 ......

Linux下设置最大打开文件数

命令行级别 命令行中敲入 ulimit -n 12345 用户级别 编辑/etc/security/limits.conf: 文件,插入一行:userx hard nofile 12345 系统级别 在/etc/sysctl.conf文件中加入一行 fs.file-max=12345,然后在命令行中输入:sysctl -p ,使其生效 ......

Linux命令 du

转自:http://www.cnblogs.com/hopeworld/archive/2009/08/07/1541444.html
 统计总数大小
    du -sh xmldb/
    du -sm * | sort -n //统计当前目录大小 并安大小 排序
    du -sk * | sort -n
    du -sk * | grep guojf //看一个人的大小
&nb ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号