Lines Matching +full:high +full:- +full:gain

1 /* ST Microelectronics LIS2DW12 3-axis accelerometer driver
5 * SPDX-License-Identifier: Apache-2.0
30 * lis2dw12_set_range - set full scale range for acc
37 struct lis2dw12_data *lis2dw12 = dev->data; in lis2dw12_set_range()
38 const struct lis2dw12_device_config *cfg = dev->config; in lis2dw12_set_range()
39 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2dw12_set_range()
44 if (cfg->pm == LIS2DW12_CONT_LOW_PWR_12bit) { in lis2dw12_set_range()
49 /* save internally gain for optimization */ in lis2dw12_set_range()
50 lis2dw12->gain = in lis2dw12_set_range()
58 * lis2dw12_set_odr - set new sampling frequency
64 const struct lis2dw12_device_config *cfg = dev->config; in lis2dw12_set_odr()
65 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2dw12_set_odr()
66 struct lis2dw12_data *lis2dw12 = dev->data; in lis2dw12_set_odr()
76 LOG_ERR("ODR too high"); in lis2dw12_set_odr()
77 return -ENOTSUP; in lis2dw12_set_odr()
79 lis2dw12->odr = odr; in lis2dw12_set_odr()
84 float gain) in lis2dw12_convert() argument
88 /* Gain is in ug/LSB */ in lis2dw12_convert()
90 dval = ((int64_t)raw_val * gain * SENSOR_G) / 1000000LL; in lis2dw12_convert()
91 val->val1 = dval / 1000000LL; in lis2dw12_convert()
92 val->val2 = dval % 1000000LL; in lis2dw12_convert()
97 struct lis2dw12_data *lis2dw12 = dev->data; in lis2dw12_channel_get_temp()
101 dval_uc = ((lis2dw12->temp >> LIS2DW12_SHIFT_TEMP) * LIS2DW12_TEMP_SCALE_FACTOR); in lis2dw12_channel_get_temp()
105 val->val1 = dval_uc / 1000000LL; in lis2dw12_channel_get_temp()
106 val->val2 = dval_uc % 1000000LL; in lis2dw12_channel_get_temp()
115 struct lis2dw12_data *lis2dw12 = dev->data; in lis2dw12_channel_get_acc()
134 lis2dw12_convert(pval++, lis2dw12->acc[i], lis2dw12->gain); in lis2dw12_channel_get_acc()
141 const struct lis2dw12_device_config *cfg = dev->config; in lis2dw12_channel_get_status()
142 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2dw12_channel_get_status()
147 val->val1 = (int32_t)*(uint8_t *)&status; in lis2dw12_channel_get_status()
172 return -ENOTSUP; in lis2dw12_channel_get()
184 return lis2dw12_set_odr(dev, val->val1); in lis2dw12_config()
190 return -ENOTSUP; in lis2dw12_config()
196 int64_t nano_ms2 = (ms2->val1 * 1000000LL + ms2->val2) * 1000LL; in sensor_ms2_to_mg()
201 return (nano_ms2 - SENSOR_G / 2) / SENSOR_G; in sensor_ms2_to_mg()
207 /* Converts a lis2dw12_fs_t range to its value in milli-g
233 const struct lis2dw12_device_config *cfg = dev->config; in lis2dw12_attr_set_thresh()
234 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2dw12_attr_set_thresh()
240 return -EINVAL; in lis2dw12_attr_set_thresh()
255 return -EINVAL; in lis2dw12_attr_set_thresh()
259 * for a wake-up interrupt generation at least one of the three axes must be in lis2dw12_attr_set_thresh()
265 LOG_DBG("Threshold %d mg -> fs: %u mg -> reg = %d LSBs", in lis2dw12_attr_set_thresh()
281 const struct lis2dw12_device_config *cfg = dev->config; in lis2dw12_attr_set_ff_dur()
282 struct lis2dw12_data *lis2dw12 = dev->data; in lis2dw12_attr_set_ff_dur()
283 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2dw12_attr_set_ff_dur()
289 return -EINVAL; in lis2dw12_attr_set_ff_dur()
296 duration = (lis2dw12->odr * (uint16_t)sensor_value_to_double(val)) / 1000; in lis2dw12_attr_set_ff_dur()
302 return -EIO; in lis2dw12_attr_set_ff_dur()
314 const struct lis2dw12_device_config *cfg = dev->config; in lis2dw12_attr_set_act_mode()
315 struct lis2dw12_data *lis2dw12 = dev->data; in lis2dw12_attr_set_act_mode()
316 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2dw12_attr_set_act_mode()
317 lis2dw12_sleep_on_t sleep_val = val->val1 & 0x03U; in lis2dw12_attr_set_act_mode()
321 return -EINVAL; in lis2dw12_attr_set_act_mode()
364 return -ENOTSUP; in lis2dw12_attr_set()
369 struct lis2dw12_data *lis2dw12 = dev->data; in lis2dw12_sample_fetch_accel()
370 const struct lis2dw12_device_config *cfg = dev->config; in lis2dw12_sample_fetch_accel()
371 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2dw12_sample_fetch_accel()
378 return -EIO; in lis2dw12_sample_fetch_accel()
382 if (cfg->pm == LIS2DW12_CONT_LOW_PWR_12bit) { in lis2dw12_sample_fetch_accel()
388 lis2dw12->acc[0] = buf[0] >> shift; in lis2dw12_sample_fetch_accel()
389 lis2dw12->acc[1] = buf[1] >> shift; in lis2dw12_sample_fetch_accel()
390 lis2dw12->acc[2] = buf[2] >> shift; in lis2dw12_sample_fetch_accel()
397 const struct lis2dw12_device_config *cfg = dev->config; in lis2dw12_sample_fetch_temp()
398 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2dw12_sample_fetch_temp()
399 struct lis2dw12_data *data = dev->data; in lis2dw12_sample_fetch_temp()
402 if (lis2dw12_temperature_raw_get(ctx, &data->temp) < 0) { in lis2dw12_sample_fetch_temp()
404 return -EIO; in lis2dw12_sample_fetch_temp()
425 return -ENOTSUP; in lis2dw12_sample_fetch()
443 const struct lis2dw12_device_config *cfg = dev->config; in lis2dw12_set_power_mode()
444 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2dw12_set_power_mode()
465 const struct lis2dw12_device_config *cfg = dev->config; in lis2dw12_set_low_noise()
466 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2dw12_set_low_noise()
480 const struct lis2dw12_device_config *cfg = dev->config; in lis2dw12_init()
481 struct lis2dw12_data *lis2dw12 = dev->data; in lis2dw12_init()
482 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2dw12_init()
495 return -EINVAL; in lis2dw12_init()
513 LOG_DBG("power-mode is %d", cfg->pm); in lis2dw12_init()
514 ret = lis2dw12_set_power_mode(dev, cfg->pm); in lis2dw12_init()
519 LOG_DBG("low noise is %d", cfg->low_noise); in lis2dw12_init()
520 ret = lis2dw12_set_low_noise(dev, cfg->low_noise); in lis2dw12_init()
526 ret = lis2dw12_set_odr(dev, cfg->odr); in lis2dw12_init()
528 LOG_ERR("odr init error %d", cfg->odr); in lis2dw12_init()
532 lis2dw12->odr = cfg->odr; in lis2dw12_init()
534 LOG_DBG("range is %d", cfg->range); in lis2dw12_init()
535 ret = lis2dw12_set_range(dev, LIS2DW12_FS_TO_REG(cfg->range)); in lis2dw12_init()
537 LOG_ERR("range init error %d", cfg->range); in lis2dw12_init()
541 LOG_DBG("bandwidth filter is %u", (int)cfg->bw_filt); in lis2dw12_init()
542 lis2dw12_filter_bandwidth_set(ctx, cfg->bw_filt); in lis2dw12_init()
552 LOG_DBG("high pass reference mode is %d", (int)cfg->hp_ref_mode); in lis2dw12_init()
553 ret = lis2dw12_reference_mode_set(ctx, cfg->hp_ref_mode); in lis2dw12_init()
555 LOG_ERR("high pass reference mode config error %d", (int)cfg->hp_ref_mode); in lis2dw12_init()
559 LOG_DBG("high pass filter path is %d", (int)cfg->hp_filter_path); in lis2dw12_init()
560 lis2dw12_fds_t fds = cfg->hp_filter_path ? in lis2dw12_init()
564 LOG_ERR("filter path config error %d", (int)cfg->hp_filter_path); in lis2dw12_init()
569 ret = lis2dw12_wkup_dur_set(ctx, cfg->wakeup_duration); in lis2dw12_init()
576 ret = lis2dw12_act_sleep_dur_set(ctx, cfg->sleep_duration); in lis2dw12_init()
697 * bus-specific macro at preprocessor time.