• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ opt_i2c_write函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中opt_i2c_write函数的典型用法代码示例。如果您正苦于以下问题:C++ opt_i2c_write函数的具体用法?C++ opt_i2c_write怎么用?C++ opt_i2c_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了opt_i2c_write函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: lightsensor_onoff

static int lightsensor_onoff(u8 onoff, struct gp2a_data *data)
{
	u8 value;

	if (onoff) {
		/*in calling, must turn on proximity sensor */
		if (data->proximity_enabled == 0) {
			value = 0x01;
			opt_i2c_write(COMMAND4, &value);
			value = 0x63;
			opt_i2c_write(COMMAND2, &value);
			/*OP3 : 1(operating mode) OP2 :1
			   (coutinuous operating mode)
			   OP1 : 01(ALS mode) TYPE=0(auto) */
			value = 0xD0;
			opt_i2c_write(COMMAND1, &value);
			/* other setting have defualt value. */
		}
	} else {
		/*in calling, must turn on proximity sensor */
		if (data->proximity_enabled == 0) {
			value = 0x00;	/*shutdown mode */
			opt_i2c_write((u8) (COMMAND1), &value);
		}
	}

	return 0;
}
开发者ID:PsychoGame,项目名称:android_kernel_samsung_royss_old,代码行数:28,代码来源:gp2ap030.c


示例2: gp2a_on

static void gp2a_on(struct gp2a_data *gp2a, int type)
{
	u8 value;
	printk(KERN_INFO "[OPTICAL] gp2a_on(%d)\n",type);
	if(type == PROXIMITY)
	{
		gprintk("[PROXIMITY] go nomal mode : power on \n");
		value = 0x18;
		opt_i2c_write((u8)(REGS_CON),&value);

		value = 0x40;
		opt_i2c_write((u8)(REGS_HYS),&value);

		value = 0x03;
		opt_i2c_write((u8)(REGS_OPMOD),&value);

		gprintk("enable irq for proximity\n");
		enable_irq(gp2a ->irq);

		value = 0x00;
		opt_i2c_write((u8)(REGS_CON),&value);
	

		proximity_enable =1;
	}
	if(type == LIGHT)
	{
		light_enable = ON;
		printk(KERN_INFO "[LIGHT_SENSOR] timer start for light sensor\n");
	    hrtimer_start(&gp2a->timer,ktime_set(light_init_period/2,0),HRTIMER_MODE_REL);
	}
}
开发者ID:LouZiffer,项目名称:m900_kernel_cupcake-SDX,代码行数:32,代码来源:gp2a.c


示例3: gp2a_opt_resume

static int gp2a_opt_resume( struct platform_device* pdev )
{

	struct gp2a_data *gp2a = platform_get_drvdata(pdev);
	u8 value;
	
	printk("[%s] : \n",__func__);
	/* wake_up source handler */
	if(proximity_enable)
	{
		value = 0x18;
		opt_i2c_write((u8)(REGS_CON),&value);

		value = 0x40;
		opt_i2c_write((u8)(REGS_HYS),&value);

		value = 0x03;
		opt_i2c_write((u8)(REGS_OPMOD),&value);


		enable_irq(gp2a->irq);


		value = 0x00;
		opt_i2c_write((u8)(REGS_CON),&value);

		

	    wake_lock_timeout(&prx_wake_lock,3 * HZ);
		timeA = ktime_get();
		printk("[%s] : wake_lock_timeout 3 Sec \n",__func__);

		/*
		if(!gpio_get_value(GPIO_PS_VOUT))
		{
			printk("[%s] : call irq_handler forcely \n",__func__);
			gp2a_irq_handler(gp2a->irq,gp2a);
			

		}
		*/

	
	}

	cur_state = STATE_INIT;
	light_init_check = false;
	
	if(light_enable)
	{
		gprintk("[%s] : hrtimer_start \n",__func__);
	    hrtimer_start(&gp2a->timer,ktime_set(light_init_period/2,0),HRTIMER_MODE_REL);
	}

	return 0;
}
开发者ID:LouZiffer,项目名称:m900_kernel_cupcake-SDX,代码行数:56,代码来源:gp2a.c


示例4: gp2a_work_func_prox

static void gp2a_work_func_prox(struct work_struct *work)
{
	struct gp2a_data *gp2a = container_of((struct work_struct *)work,
					      struct gp2a_data, proximity_work);

	unsigned char value;
	char result;
	int ret;

	if (gp2a->irq != 0) {
		disable_irq_wake(gp2a->irq);
		disable_irq(gp2a->irq);
	}
	/* 0 : proximity, 1 : away */
        result = gpio_get_value(gp2a->pdata->p_out);
	gp2a->proximity_detection = !result;

	input_report_abs(gp2a->proximity_input_dev, ABS_DISTANCE, result);
	input_sync(gp2a->proximity_input_dev);

        printk(KERN_INFO "[GP2A] proximity value = %d \n",result);

	value = 0x0C;
	ret = opt_i2c_write(COMMAND1, &value);	/*Software reset */

	if (result == 0) {	/* detection = Falling Edge */
		if (gp2a->lightsensor_mode == 0)	/* Low mode */
			value = 0x23;
		else		/* High mode */
			value = 0x27;
		ret = opt_i2c_write(COMMAND2, &value);
	} else {		/* none Detection */
		if (gp2a->lightsensor_mode == 0)	/* Low mode */
			value = 0x63;
		else		/* High mode */
			value = 0x67;
		ret = opt_i2c_write(COMMAND2, &value);
	}

	if (gp2a->irq != 0) {
	enable_irq(gp2a->irq);
		enable_irq_wake(gp2a->irq);
	}
	value = 0xCC;
	ret = opt_i2c_write(COMMAND1, &value);

	gp2a->prox_data = result;
    
}
开发者ID:PsychoGame,项目名称:android_kernel_samsung_royss_old,代码行数:49,代码来源:gp2ap030.c


示例5: gp2a_off

static void gp2a_off(struct gp2a_data *gp2a, int type)
{
	u8 value;

	printk(KERN_INFO "[OPTICAL] gp2a_off(%d)\n",type);
	if(type == PROXIMITY || type == ALL)
	{
	
		gprintk("[PROXIMITY] go power down mode  \n");
		
		gprintk("disable irq for proximity \n");
		disable_irq(gp2a ->irq);
		
		value = 0x02;
		opt_i2c_write((u8)(REGS_OPMOD),&value);
		
		proximity_enable =0;
		proximity_value = 0;
	}

	if(type ==LIGHT)
	{
		printk("[LIGHT_SENSOR] timer cancel for light sensor\n");
		hrtimer_cancel(&gp2a->timer);
		light_enable = OFF;
		cur_state = STATE_INIT;
		light_init_check = false;
		

	}

	
	

}
开发者ID:LouZiffer,项目名称:m900_kernel_cupcake-SDX,代码行数:35,代码来源:gp2a.c


示例6: proximity_onoff

static int proximity_onoff(u8 onoff)
{
	u8 value;
	int i;
	int err = 0;

#ifdef DEBUG
	gprintk("proximity turn on/off = %d\n", onoff);
#endif

	/* already on light sensor, so must simultaneously
	   turn on light sensor and proximity sensor */
	if (onoff) {
		for (i = 0; i < COL; i++) {
			if (is_gp2a030a())
				err =
				    opt_i2c_write(gp2a_original_image_030a[i][0]
					, &gp2a_original_image_030a[i][1]);
			else
				err =
				    opt_i2c_write(gp2a_original_image[i][0],
						  &gp2a_original_image[i][1]);
			if (err < 0)
				printk(KERN_ERR
				      "%s : turnning on error i = %d, err=%d\n",
				       __func__, i, err);
			lightsensor_mode = 0;
		}
	} else { /* light sensor turn on and proximity turn off */
		if (lightsensor_mode)
			value = 0x67; /*resolution :16bit, range: *8(HIGH) */
		else
			value = 0x63; /* resolution :16bit, range: *128(LOW) */
		opt_i2c_write(COMMAND2, &value);
		/* OP3 : 1(operating mode)
		   OP2 :1(coutinuous operating mode) OP1 : 01(ALS mode) */
		value = 0xD0;
		opt_i2c_write(COMMAND1, &value);
	}

	return 0;
}
开发者ID:ameswilliam,项目名称:starkissed-kernel-ekgc100,代码行数:42,代码来源:gp2a_proximity.c


示例7: gp2a_opt_ioctl

static long gp2a_opt_ioctl(struct file *file, unsigned int cmd,  unsigned long arg)
{	
    int ret = 0;
    short data = 0;
    u8 thrd = 0;

    switch (cmd)
    {
	case PROX_IOC_SET_CALIBRATION:
        {
		printk(KERN_INFO "[GP2A] PROX_IOC_SET_CALIBRATION\n");                
		if (copy_from_user(&data, (void __user *)arg, sizeof(data)))
			return -EFAULT;

		ret = proximity_open_offset(gp2a_opt_data);
		if (ret < 0 && ret != -ENOENT)
		{
			printk(KERN_INFO "[GP2A] proximity_open_offset() failed\n");
		}else {
			thrd = gp2a_original_image[3][1]+(gp2a_opt_data->offset_value);
			opt_i2c_write(gp2a_original_image[3][0], &thrd);
			thrd = gp2a_original_image[5][1]+(gp2a_opt_data->offset_value);
			opt_i2c_write(gp2a_original_image[5][0], &thrd);
		}
		break;
	}
	case PROX_IOC_GET_CALIBRATION:
        {
		printk(KERN_INFO "[GP2A] PROX_IOC_GET_CALIBRATION\n");      
                data = gp2a_opt_data->offset_value;
		if (copy_to_user((void __user *)arg, &data, sizeof(data)))
			return -EFAULT;
		break;
	}
	default:
            printk(KERN_ERR "Unknown IOCTL command");
            ret = -ENOTTY;
            break;
    }
    return ret;
}
开发者ID:PsychoGame,项目名称:android_kernel_samsung_royss_old,代码行数:41,代码来源:gp2ap030.c


示例8: gp2a_update_threshold

static int gp2a_update_threshold(u8 (*selected_image)[2],
				unsigned long new_threshold, bool update_reg)
{
	int i, err = 0;
	u8 set_value;

	for (i = 0; i < COL; i++) {
		switch (selected_image[i][0]) {
		case PS_LOW_THD_L:
			/*PS mode LTH(Loff) for low 8bit*/
			set_value = new_threshold & 0x00FF;
			break;

		case PS_LOW_THD_H:
			/*PS mode LTH(Loff) for high 8bit*/
			set_value = (new_threshold & 0xFF00) >> 8;
			break;

		case PS_HIGH_THD_L:
			/*PS mode HTH(Lon) for low 8bit*/
			set_value = (new_threshold+1) & 0x00FF;
			break;

		case PS_HIGH_THD_H:
			/* PS mode HTH(Lon) for high 8bit*/
			set_value = ((new_threshold+1) & 0xFF00) >> 8;
			break;

		default:
			continue;
		}

		if (update_reg)
			err = opt_i2c_write(selected_image[i][0], &set_value);

		if (err) {
			pr_err("%s : setting error i = %d, err=%d\n",
			 __func__, i, err);
			return err;
		} else
			selected_image[i][1] = set_value;
	}

	return err;
}
开发者ID:ameswilliam,项目名称:starkissed-kernel-ekgc100,代码行数:45,代码来源:gp2a_proximity.c



注:本文中的opt_i2c_write函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ opt_init函数代码示例发布时间:2022-05-30
下一篇:
C++ opt_format函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap