Lines Matching +full:xyz +full:- +full:measurement
4 * SPDX-License-Identifier: Apache-2.0
23 * Use values for low-power mode in DS "Mechanical (Sensor) characteristics",
40 * max(raw_val >> 4) = +/- 2^11 in lis2dh_convert()
45 val->val1 = converted_val / 1000000; in lis2dh_convert()
46 val->val2 = converted_val % 1000000; in lis2dh_convert()
51 int ret = -ENOTSUP; in lis2dh_sample_fetch_temp()
54 struct lis2dh_data *lis2dh = dev->data; in lis2dh_sample_fetch_temp()
55 const struct lis2dh_config *cfg = dev->config; in lis2dh_sample_fetch_temp()
58 ret = lis2dh->hw_tf->read_data(dev, cfg->temperature.dout_addr, raw, in lis2dh_sample_fetch_temp()
63 ret = -EIO; in lis2dh_sample_fetch_temp()
72 lis2dh->temperature.val1 = (int32_t)((int8_t)raw[1]); in lis2dh_sample_fetch_temp()
73 if (cfg->temperature.fractional_bits == 0) { in lis2dh_sample_fetch_temp()
74 lis2dh->temperature.val2 = 0; in lis2dh_sample_fetch_temp()
76 lis2dh->temperature.val2 = in lis2dh_sample_fetch_temp()
77 (raw[0] >> (8 - cfg->temperature.fractional_bits)); in lis2dh_sample_fetch_temp()
78 lis2dh->temperature.val2 = (lis2dh->temperature.val2 * 1000000); in lis2dh_sample_fetch_temp()
79 lis2dh->temperature.val2 >>= cfg->temperature.fractional_bits; in lis2dh_sample_fetch_temp()
80 if (lis2dh->temperature.val1 < 0) { in lis2dh_sample_fetch_temp()
81 lis2dh->temperature.val2 *= -1; in lis2dh_sample_fetch_temp()
86 LOG_WRN("Temperature measurement disabled"); in lis2dh_sample_fetch_temp()
96 struct lis2dh_data *lis2dh = dev->data; in lis2dh_channel_get()
117 memcpy(val, &lis2dh->temperature, sizeof(*val)); in lis2dh_channel_get()
121 return -ENOTSUP; in lis2dh_channel_get()
125 lis2dh_convert(lis2dh->sample.xyz[i], lis2dh->scale, val); in lis2dh_channel_get()
134 struct lis2dh_data *lis2dh = dev->data; in lis2dh_fetch_xyz()
135 int status = -ENODATA; in lis2dh_fetch_xyz()
141 status = lis2dh->hw_tf->read_data(dev, LIS2DH_REG_STATUS, in lis2dh_fetch_xyz()
142 lis2dh->sample.raw, in lis2dh_fetch_xyz()
143 sizeof(lis2dh->sample.raw)); in lis2dh_fetch_xyz()
151 (int16_t *)&lis2dh->sample.raw[1 + i]; in lis2dh_fetch_xyz()
156 if (lis2dh->sample.status & LIS2DH_STATUS_DRDY_MASK) { in lis2dh_fetch_xyz()
166 int status = -ENODATA; in lis2dh_sample_fetch()
201 return -EINVAL; in lis2dh_freq_to_odr_val()
209 struct lis2dh_data *data = dev->data; in lis2dh_acc_odr_set()
216 status = data->hw_tf->read_reg(dev, LIS2DH_REG_CTRL1, &value); in lis2dh_acc_odr_set()
223 return -ENOTSUP; in lis2dh_acc_odr_set()
229 odr--; in lis2dh_acc_odr_set()
232 return data->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1, in lis2dh_acc_odr_set()
253 return -EINVAL; in lis2dh_range_to_reg_val()
258 struct lis2dh_data *lis2dh = dev->data; in lis2dh_acc_range_set()
266 lis2dh->scale = lis2dh_reg_val_to_scale[fs]; in lis2dh_acc_range_set()
268 return lis2dh->hw_tf->update_reg(dev, LIS2DH_REG_CTRL4, in lis2dh_acc_range_set()
286 return lis2dh_acc_odr_set(dev, val->val1); in lis2dh_acc_config()
295 return lis2dh_acc_hp_filter_set(dev, val->val1); in lis2dh_acc_config()
299 return -ENOTSUP; in lis2dh_acc_config()
317 return -ENOTSUP; in lis2dh_attr_set()
334 struct lis2dh_data *lis2dh = dev->data; in lis2dh_init()
335 const struct lis2dh_config *cfg = dev->config; in lis2dh_init()
340 status = cfg->bus_init(dev); in lis2dh_init()
345 status = lis2dh->hw_tf->read_reg(dev, LIS2DH_REG_WAI, &id); in lis2dh_init()
353 return -EINVAL; in lis2dh_init()
357 if (cfg->hw.is_lsm303agr_dev) { in lis2dh_init()
364 if (cfg->hw.disc_pull_up) { in lis2dh_init()
365 status = lis2dh->hw_tf->update_reg(dev, LIS2DH_REG_CTRL0, in lis2dh_init()
369 LOG_ERR("Failed to disconnect SDO/SA0 pull-up."); in lis2dh_init()
382 status = lis2dh->hw_tf->write_data(dev, LIS2DH_REG_CTRL1, raw, in lis2dh_init()
391 lis2dh->scale = lis2dh_reg_val_to_scale[LIS2DH_FS_IDX]; in lis2dh_init()
393 status = lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL4, in lis2dh_init()
396 status = lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL4, LIS2DH_FS_BITS | LIS2DH_HR_BIT); in lis2dh_init()
405 status = lis2dh->hw_tf->update_reg(dev, cfg->temperature.cfg_addr, in lis2dh_init()
406 cfg->temperature.enable_mask, in lis2dh_init()
407 cfg->temperature.enable_mask); in lis2dh_init()
410 LOG_ERR("Failed to enable temperature measurement"); in lis2dh_init()
416 if (cfg->gpio_drdy.port != NULL || cfg->gpio_int.port != NULL) { in lis2dh_init()
426 (uint8_t)LIS2DH_LP_EN_BIT, lis2dh->scale); in lis2dh_init()
429 return lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1, in lis2dh_init()
439 struct lis2dh_data *lis2dh = dev->data; in lis2dh_pm_action()
445 status = lis2dh->hw_tf->read_reg(dev, LIS2DH_REG_REFERENCE, ®data); in lis2dh_pm_action()
452 status = lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1, in lis2dh_pm_action()
453 lis2dh->reg_ctrl1_active_val); in lis2dh_pm_action()
461 status = lis2dh->hw_tf->read_reg(dev, LIS2DH_REG_CTRL1, in lis2dh_pm_action()
462 &lis2dh->reg_ctrl1_active_val); in lis2dh_pm_action()
467 status = lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1, in lis2dh_pm_action()
475 return -ENOTSUP; in lis2dh_pm_action()
610 * bus-specific macro at preprocessor time.