linux红外对管(距离传感器)驱动 分析

 

头文件:

/*
* filename: rohm_scm_proximity.h
*/
#ifndef __ROHM_SCM_PROXIMTIY__
#define __ROHM_SCM_PROXIMTIY__


#define ROHM_PROXIMITY "rohm_proximity"
#define PROXIMITY_DEVICE "rohm_proximity"

#include <linux/types.h>
#include <linux/ioctl.h>

#define ROHM_PROXIMITY_IOCTL_MAGIC 				'r'
#define ROHM_PROXIMITY_IOCTL_GET_ENABLED  		_IOR(ROHM_PROXIMITY_IOCTL_MAGIC, 1, int *)
#define ROHM_PROXIMITY_IOCTL_ENABLE   			_IOW(ROHM_PROXIMITY_IOCTL_MAGIC, 2, int *)

#endif


 

/*
 * File:         rohm_scm_proximity.c
 * Based on:
 * Author:       Yunlong Wang <Yunlong.Wang@spreadtrum.com>
 *
 * Created:   2011-04-08
 * Description:  Rohm Proximity Sensor Driver
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/gpio.h>
#include <linux/input.h>
#include <linux/platform_device.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/miscdevice.h>
#include <linux/delay.h>
#include <linux/wakelock.h>
#include <mach/mfp.h>
#include <mach/adc_drvapi.h>

#include "rohm_scm_proximity.h"

#define PS_DEBUG 1
#define RHOM_PROXIMITY_DATA_POLL_TIMER      100
#define RHOM_PROXIMITY_THRESHOLD            500
#define RHOM_PROXIMITY_ADC_CHANNEL          1

//static int debug_level=0;
static int debug_level=1;

#if PS_DEBUG
#define PS_DBG(format, ...) \
    if(debug_level == 1) \
        printk(KERN_INFO "PROXIMITY: " format , ## __VA_ARGS__)
#else
#define PS_DBG(format, ...)
#endif

extern int sprd_3rdparty_gpio_proximity_trans;
extern int sprd_3rdparty_gpio_proximity_recv;


struct rohm_proximity_platform_data {
        int gpio_trans; /*control transmit light*/
        int gpio_recv;  /*control recevie light*/
};

static struct rohm_proximity_platform_data proximity_platform_data;
static struct wake_lock prox_delayed_work_wake_lock;


static struct rohm_proximity_data {
    struct input_dev *input_dev;
    struct rohm_proximity_platform_data *pdata;
    struct delayed_work work;
    struct workqueue_struct *work_queue;
    int enabled;
} proximity_data;

static int misc_opened;
static int p

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值