Lines Matching +full:accel +full:- +full:range
1 /* ST Microelectronics LIS2DE12 3-axis accelerometer sensor driver
5 * SPDX-License-Identifier: Apache-2.0
38 return -EINVAL; in lis2de12_freq_to_odr_val()
43 uint32_t gain; /* Accel sensor sensitivity in ug/LSB */
53 static int lis2de12_accel_range_to_fs_val(int32_t range) in lis2de12_accel_range_to_fs_val() argument
58 if (range == lis2de12_accel_fs_map[i].fs) { in lis2de12_accel_range_to_fs_val()
63 return -EINVAL; in lis2de12_accel_range_to_fs_val()
68 const struct lis2de12_config *cfg = dev->config; in lis2de12_accel_set_fs_raw()
69 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2de12_accel_set_fs_raw()
70 struct lis2de12_data *data = dev->data; in lis2de12_accel_set_fs_raw()
73 return -EIO; in lis2de12_accel_set_fs_raw()
76 data->accel_fs = fs; in lis2de12_accel_set_fs_raw()
83 const struct lis2de12_config *cfg = dev->config; in lis2de12_accel_set_odr_raw()
84 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2de12_accel_set_odr_raw()
85 struct lis2de12_data *data = dev->data; in lis2de12_accel_set_odr_raw()
88 return -EIO; in lis2de12_accel_set_odr_raw()
91 data->accel_freq = odr; in lis2de12_accel_set_odr_raw()
107 return -EIO; in lis2de12_accel_odr_set()
113 static int lis2de12_accel_range_set(const struct device *dev, int32_t range) in lis2de12_accel_range_set() argument
116 struct lis2de12_data *data = dev->data; in lis2de12_accel_range_set()
118 fs = lis2de12_accel_range_to_fs_val(range); in lis2de12_accel_range_set()
124 LOG_ERR("failed to set accelerometer full-scale"); in lis2de12_accel_range_set()
125 return -EIO; in lis2de12_accel_range_set()
128 data->acc_gain = lis2de12_accel_fs_map[fs].gain; in lis2de12_accel_range_set()
141 return lis2de12_accel_odr_set(dev, val->val1); in lis2de12_accel_config()
143 LOG_WRN("Accel attribute %d not supported.", attr); in lis2de12_accel_config()
144 return -ENOTSUP; in lis2de12_accel_config()
158 return -ENOTSUP; in lis2de12_attr_set()
164 const struct lis2de12_config *cfg = dev->config; in lis2de12_sample_fetch_accel()
165 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2de12_sample_fetch_accel()
166 struct lis2de12_data *data = dev->data; in lis2de12_sample_fetch_accel()
168 if (lis2de12_acceleration_raw_get(ctx, data->acc) < 0) { in lis2de12_sample_fetch_accel()
170 return -EIO; in lis2de12_sample_fetch_accel()
179 const struct lis2de12_config *cfg = dev->config; in lis2de12_sample_fetch_temp()
180 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2de12_sample_fetch_temp()
181 struct lis2de12_data *data = dev->data; in lis2de12_sample_fetch_temp()
183 if (lis2de12_temperature_raw_get(ctx, &data->temp_sample) < 0) { in lis2de12_sample_fetch_temp()
185 return -EIO; in lis2de12_sample_fetch_temp()
211 return -ENOTSUP; in lis2de12_sample_fetch()
225 val->val1 = (int32_t)(dval / 1000000); in lis2de12_accel_convert()
226 val->val2 = (int32_t)(dval % 1000000); in lis2de12_accel_convert()
239 lis2de12_accel_convert(val, data->acc[0], sensitivity); in lis2de12_accel_get_channel()
242 lis2de12_accel_convert(val, data->acc[1], sensitivity); in lis2de12_accel_get_channel()
245 lis2de12_accel_convert(val, data->acc[2], sensitivity); in lis2de12_accel_get_channel()
249 lis2de12_accel_convert(val++, data->acc[i], sensitivity); in lis2de12_accel_get_channel()
253 return -ENOTSUP; in lis2de12_accel_get_channel()
263 return lis2de12_accel_get_channel(chan, val, data, data->acc_gain); in lis2de12_accel_channel_get()
274 micro_c = ((int64_t)data->temp_sample * 1000000) / 256; in lis2de12_temp_channel_get()
276 val->val1 = micro_c / 1000000 + 25; in lis2de12_temp_channel_get()
277 val->val2 = micro_c % 1000000; in lis2de12_temp_channel_get()
285 struct lis2de12_data *data = dev->data; in lis2de12_channel_get()
300 return -ENOTSUP; in lis2de12_channel_get()
317 const struct lis2de12_config *cfg = dev->config; in lis2de12_init_chip()
318 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2de12_init_chip()
319 struct lis2de12_data *lis2de12 = dev->data; in lis2de12_init_chip()
325 return -EIO; in lis2de12_init_chip()
330 return -EIO; in lis2de12_init_chip()
337 return -EIO; in lis2de12_init_chip()
341 fs = cfg->accel_range; in lis2de12_init_chip()
342 LOG_DBG("accel range is %d", fs); in lis2de12_init_chip()
344 LOG_ERR("failed to set accelerometer range %d", fs); in lis2de12_init_chip()
345 return -EIO; in lis2de12_init_chip()
347 lis2de12->acc_gain = lis2de12_accel_fs_map[fs].gain; in lis2de12_init_chip()
350 odr = cfg->accel_odr; in lis2de12_init_chip()
351 LOG_DBG("accel odr is %d", odr); in lis2de12_init_chip()
354 return -EIO; in lis2de12_init_chip()
367 const struct lis2de12_config *cfg = dev->config; in lis2de12_init()
369 struct lis2de12_data *data = dev->data; in lis2de12_init()
371 LOG_INF("Initialize device %s", dev->name); in lis2de12_init()
372 data->dev = dev; in lis2de12_init()
376 return -EIO; in lis2de12_init()
380 if (cfg->trig_enabled) { in lis2de12_init()
383 return -EIO; in lis2de12_init()
460 * bus-specific macro at preprocessor time.