static int lis3dh_config(void *mlsl_handle,
			 struct ext_slave_descr *slave,
			 struct ext_slave_platform_data *pdata,
			 struct ext_slave_config *data)
{
	struct lis3dh_private_data *private_data = pdata->private_data;
	if (!data->data)
		return INV_ERROR_INVALID_PARAMETER;

	switch (data->key) {
	case MPU_SLAVE_CONFIG_ODR_SUSPEND:
		return lis3dh_set_odr(mlsl_handle, pdata,
				      &private_data->suspend,
				      data->apply, *((long *)data->data));
	case MPU_SLAVE_CONFIG_ODR_RESUME:
		return lis3dh_set_odr(mlsl_handle, pdata,
				      &private_data->resume,
				      data->apply, *((long *)data->data));
	case MPU_SLAVE_CONFIG_FSR_SUSPEND:
		return lis3dh_set_fsr(mlsl_handle, pdata,
				      &private_data->suspend,
				      data->apply, *((long *)data->data));
	case MPU_SLAVE_CONFIG_FSR_RESUME:
		return lis3dh_set_fsr(mlsl_handle, pdata,
				      &private_data->resume,
				      data->apply, *((long *)data->data));
	case MPU_SLAVE_CONFIG_MOT_THS:
		return lis3dh_set_ths(mlsl_handle, pdata,
				      &private_data->suspend,
				      data->apply, *((long *)data->data));
	case MPU_SLAVE_CONFIG_NMOT_THS:
		return lis3dh_set_ths(mlsl_handle, pdata,
				      &private_data->resume,
				      data->apply, *((long *)data->data));
	case MPU_SLAVE_CONFIG_MOT_DUR:
		return lis3dh_set_dur(mlsl_handle, pdata,
				      &private_data->suspend,
				      data->apply, *((long *)data->data));
	case MPU_SLAVE_CONFIG_NMOT_DUR:
		return lis3dh_set_dur(mlsl_handle, pdata,
				      &private_data->resume,
				      data->apply, *((long *)data->data));
	case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
		return lis3dh_set_irq(mlsl_handle, pdata,
				      &private_data->suspend,
				      data->apply, *((long *)data->data));
	case MPU_SLAVE_CONFIG_IRQ_RESUME:
		return lis3dh_set_irq(mlsl_handle, pdata,
				      &private_data->resume,
				      data->apply, *((long *)data->data));
	default:
		return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
	};
	return INV_SUCCESS;
}
Пример #2
0
static int lis3dh_init(void *mlsl_handle,
		       struct ext_slave_descr *slave,
		       struct ext_slave_platform_data *pdata)
{
	inv_error_t result;
	long range;
	struct lis3dh_private_data *private_data;
	private_data = (struct lis3dh_private_data *)
	    inv_malloc(sizeof(struct lis3dh_private_data));

	if (!private_data)
		return INV_ERROR_MEMORY_EXAUSTED;

	pdata->private_data = private_data;

	private_data->resume.ctrl_reg1 = 0x67;
	private_data->suspend.ctrl_reg1 = 0x18;
	private_data->resume.mot_int1_cfg = 0x95;
	private_data->suspend.mot_int1_cfg = 0x2a;

	lis3dh_set_odr(mlsl_handle, pdata, &private_data->suspend, FALSE, 0);
	lis3dh_set_odr(mlsl_handle, pdata, &private_data->resume,
		       FALSE, 200000);

	range = RANGE_FIXEDPOINT_TO_LONG_MG(slave->range);
	lis3dh_set_fsr(mlsl_handle, pdata, &private_data->suspend,
			FALSE, range);
	lis3dh_set_fsr(mlsl_handle, pdata, &private_data->resume,
			FALSE, range);

	lis3dh_set_ths(mlsl_handle, pdata, &private_data->suspend,
			FALSE, 80);
	lis3dh_set_ths(mlsl_handle, pdata, &private_data->resume,
			FALSE, 40);

	lis3dh_set_dur(mlsl_handle, pdata, &private_data->suspend,
			FALSE, 1000);
	lis3dh_set_dur(mlsl_handle, pdata, &private_data->resume,
			FALSE, 2540);

	lis3dh_set_irq(mlsl_handle, pdata, &private_data->suspend,
			FALSE, MPU_SLAVE_IRQ_TYPE_NONE);
	lis3dh_set_irq(mlsl_handle, pdata, &private_data->resume,
			FALSE, MPU_SLAVE_IRQ_TYPE_NONE);

	result = inv_serial_single_write(mlsl_handle, pdata->address,
					 LIS3DH_CTRL_REG1, 0x07);
	inv_sleep(6);

	return INV_SUCCESS;
}
static int lis3dh_init(void *mlsl_handle,
		       struct ext_slave_descr *slave,
		       struct ext_slave_platform_data *pdata)
{
	int result;
	long range;
	struct lis3dh_private_data *private_data;
	private_data = (struct lis3dh_private_data *)
	    kzalloc(sizeof(struct lis3dh_private_data), GFP_KERNEL);

	if (!private_data)
		return INV_ERROR_MEMORY_EXAUSTED;

	pdata->private_data = private_data;

	private_data->resume.ctrl_reg1 = 0x67;
	private_data->suspend.ctrl_reg1 = 0x18;
	private_data->resume.mot_int1_cfg = 0x95;
	private_data->suspend.mot_int1_cfg = 0x2a;

	lis3dh_set_odr(mlsl_handle, pdata, &private_data->suspend, false, 0);
	lis3dh_set_odr(mlsl_handle, pdata, &private_data->resume,
		       false, 200000L);

	range = range_fixedpoint_to_long_mg(slave->range);
	lis3dh_set_fsr(mlsl_handle, pdata, &private_data->suspend,
			false, range);
	lis3dh_set_fsr(mlsl_handle, pdata, &private_data->resume,
			false, range);

	lis3dh_set_ths(mlsl_handle, pdata, &private_data->suspend,
			false, 80);
	lis3dh_set_ths(mlsl_handle, pdata, &private_data->resume,
			false, 40);

	lis3dh_set_dur(mlsl_handle, pdata, &private_data->suspend,
			false, 1000);
	lis3dh_set_dur(mlsl_handle, pdata, &private_data->resume,
			false, 2540);

	lis3dh_set_irq(mlsl_handle, pdata, &private_data->suspend,
			false, MPU_SLAVE_IRQ_TYPE_NONE);
	lis3dh_set_irq(mlsl_handle, pdata, &private_data->resume,
			false, MPU_SLAVE_IRQ_TYPE_NONE);

	result = inv_serial_single_write(mlsl_handle, pdata->address,
					 LIS3DH_CTRL_REG1, 0x07);
	msleep(6);

	return INV_SUCCESS;
}
Пример #4
0
static int lis3dh_init(void *mlsl_handle,
			  struct ext_slave_descr *slave,
			  struct ext_slave_platform_data *pdata)
{
	tMLError result;

	struct lis3dh_private_data *private_data;
	private_data = (struct lis3dh_private_data *)
		MLOSMalloc(sizeof(struct lis3dh_private_data));

	if (!private_data)
		return ML_ERROR_MEMORY_EXAUSTED;

	pdata->private_data = private_data;

	private_data->resume.ctrl_reg1 = 0x67;
	private_data->suspend.ctrl_reg1 = 0x18;
	private_data->resume.mot_int1_cfg = 0x95;
	private_data->suspend.mot_int1_cfg = 0x2a;

	lis3dh_set_odr(mlsl_handle, pdata, &private_data->suspend,
			FALSE, 0);
	lis3dh_set_odr(mlsl_handle, pdata, &private_data->resume,
			FALSE, 200000);
	lis3dh_set_fsr(mlsl_handle, pdata, &private_data->suspend,
			FALSE, 2048);
	lis3dh_set_fsr(mlsl_handle, pdata, &private_data->resume,
			FALSE, 2048);
	lis3dh_set_ths(mlsl_handle, pdata, &private_data->suspend,
			FALSE, 80);
	lis3dh_set_ths(mlsl_handle, pdata, &private_data->resume,
			FALSE, 40);
	lis3dh_set_dur(mlsl_handle, pdata, &private_data->suspend,
			FALSE, 1000);
	lis3dh_set_dur(mlsl_handle, pdata, &private_data->resume,
			FALSE,  2540);
	lis3dh_set_irq(mlsl_handle, pdata, &private_data->suspend,
			FALSE,
			MPU_SLAVE_IRQ_TYPE_NONE);
	lis3dh_set_irq(mlsl_handle, pdata, &private_data->resume,
			FALSE,
			MPU_SLAVE_IRQ_TYPE_NONE);

	result = MLSLSerialWriteSingle(mlsl_handle, pdata->address,
				       LIS3DH_CTRL_REG1, 0x07);
	MLOSSleep(6);

	return ML_SUCCESS;
}