Пример #1
0
static ssize_t apds9130_store_run_calibration(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct apds9130_data *data = i2c_get_clientdata(client);

	int ret;

	ret = apds9130_Run_Cross_talk_Calibration(client);
	if(ret < 0)
	{
		printk(KERN_INFO"%s Fail error :  %d\n", __FUNCTION__, ret);
		data->ps_cal_result = 0;
	}
	else
	{
		printk(KERN_INFO"%s Succes cross-talk :  %d\n", __FUNCTION__, ret);
		data->ps_cal_result = 1;
	}

	return count;
}
static ssize_t apds9130_store_run_calibration(struct device *dev,
					struct device_attribute *attr, const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct apds9130_data *data = i2c_get_clientdata(client);
    int err;

	// start calibration
	apds9130_Run_Cross_talk_Calibration(client);

	// set threshold for near/far status
	data->ps_threshold = data->cross_talk + data->add_to_cross_talk;
	data->ps_hysteresis_threshold = data->ps_threshold - data->sub_from_ps_threshold;

	err = apds9130_set_piht(client, data->ps_threshold);
    if(err < 0) return err;
	err = apds9130_set_pilt(client, data->ps_hysteresis_threshold);
	if(err < 0) return err;

	printk("[ProximitySensor] %s: [piht][pilt][c_t] = [%d][%d][%d]\n",
				__func__, data->ps_threshold, data->ps_hysteresis_threshold, data->cross_talk);

	return count;
}