Lines Matching +full:accel +full:- +full:odr
1 /* ST Microelectronics LIS2DU12 3-axis accelerometer sensor driver
5 * SPDX-License-Identifier: Apache-2.0
40 return -EINVAL; in lis2du12_freq_to_odr_val()
55 return -EINVAL; in lis2du12_accel_range_to_fs_val()
60 const struct lis2du12_config *cfg = dev->config; in lis2du12_reboot()
61 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2du12_reboot()
66 return -EIO; in lis2du12_reboot()
70 if (!--tries) { in lis2du12_reboot()
72 return -ETIMEDOUT; in lis2du12_reboot()
77 return -EIO; in lis2du12_reboot()
82 return -EIO; in lis2du12_reboot()
90 const struct lis2du12_config *cfg = dev->config; in lis2du12_accel_set_fs_raw()
91 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2du12_accel_set_fs_raw()
92 struct lis2du12_data *data = dev->data; in lis2du12_accel_set_fs_raw()
96 return -EIO; in lis2du12_accel_set_fs_raw()
101 return -EIO; in lis2du12_accel_set_fs_raw()
104 data->accel_fs = fs; in lis2du12_accel_set_fs_raw()
109 static int lis2du12_accel_set_odr_raw(const struct device *dev, uint8_t odr) in lis2du12_accel_set_odr_raw() argument
111 const struct lis2du12_config *cfg = dev->config; in lis2du12_accel_set_odr_raw()
112 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2du12_accel_set_odr_raw()
113 struct lis2du12_data *data = dev->data; in lis2du12_accel_set_odr_raw()
117 return -EIO; in lis2du12_accel_set_odr_raw()
120 mode.odr = odr; in lis2du12_accel_set_odr_raw()
122 return -EIO; in lis2du12_accel_set_odr_raw()
125 data->accel_freq = odr; in lis2du12_accel_set_odr_raw()
132 int odr; in lis2du12_accel_odr_set() local
134 odr = lis2du12_freq_to_odr_val(dev, freq); in lis2du12_accel_odr_set()
135 if (odr < 0) { in lis2du12_accel_odr_set()
136 return odr; in lis2du12_accel_odr_set()
139 if (lis2du12_accel_set_odr_raw(dev, odr) < 0) { in lis2du12_accel_odr_set()
141 return -EIO; in lis2du12_accel_odr_set()
150 struct lis2du12_data *data = dev->data; in lis2du12_accel_range_set()
158 LOG_ERR("failed to set accelerometer full-scale"); in lis2du12_accel_range_set()
159 return -EIO; in lis2du12_accel_range_set()
162 data->acc_gain = lis2du12_accel_fs_map[fs] * GAIN_UNIT_XL / 2; in lis2du12_accel_range_set()
175 return lis2du12_accel_odr_set(dev, val->val1); in lis2du12_accel_config()
177 LOG_WRN("Accel attribute %d not supported.", attr); in lis2du12_accel_config()
178 return -ENOTSUP; in lis2du12_accel_config()
194 return -ENOTSUP; in lis2du12_attr_set()
202 const struct lis2du12_config *cfg = dev->config; in lis2du12_sample_fetch_accel()
203 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2du12_sample_fetch_accel()
204 struct lis2du12_data *data = dev->data; in lis2du12_sample_fetch_accel()
208 md.fs = cfg->accel_range; in lis2du12_sample_fetch_accel()
211 return -EIO; in lis2du12_sample_fetch_accel()
214 data->acc[0] = xl_data.xl.raw[0]; in lis2du12_sample_fetch_accel()
215 data->acc[1] = xl_data.xl.raw[1]; in lis2du12_sample_fetch_accel()
216 data->acc[2] = xl_data.xl.raw[2]; in lis2du12_sample_fetch_accel()
232 return -ENOTSUP; in lis2du12_sample_fetch()
246 val->val1 = (int32_t)(dval / 1000000); in lis2du12_accel_convert()
247 val->val2 = (int32_t)(dval % 1000000); in lis2du12_accel_convert()
260 lis2du12_accel_convert(val, data->acc[0], sensitivity); in lis2du12_accel_get_channel()
263 lis2du12_accel_convert(val, data->acc[1], sensitivity); in lis2du12_accel_get_channel()
266 lis2du12_accel_convert(val, data->acc[2], sensitivity); in lis2du12_accel_get_channel()
270 lis2du12_accel_convert(val++, data->acc[i], sensitivity); in lis2du12_accel_get_channel()
274 return -ENOTSUP; in lis2du12_accel_get_channel()
284 return lis2du12_accel_get_channel(chan, val, data, data->acc_gain); in lis2du12_accel_channel_get()
291 struct lis2du12_data *data = dev->data; in lis2du12_channel_get()
301 return -ENOTSUP; in lis2du12_channel_get()
318 const struct lis2du12_config *cfg = dev->config; in lis2du12_init_chip()
319 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lis2du12_init_chip()
320 struct lis2du12_data *lis2du12 = dev->data; in lis2du12_init_chip()
322 uint8_t odr, fs; in lis2du12_init_chip() local
326 return -EIO; in lis2du12_init_chip()
333 return -EIO; in lis2du12_init_chip()
338 return -EIO; in lis2du12_init_chip()
342 fs = cfg->accel_range; in lis2du12_init_chip()
343 LOG_DBG("accel range is %d", fs); in lis2du12_init_chip()
346 return -EIO; in lis2du12_init_chip()
348 lis2du12->acc_gain = lis2du12_accel_fs_map[fs] * GAIN_UNIT_XL / 2; in lis2du12_init_chip()
350 /* set odr from DT (the only way to go in high performance) */ in lis2du12_init_chip()
351 odr = cfg->accel_odr; in lis2du12_init_chip()
352 LOG_DBG("accel odr is %d", odr); in lis2du12_init_chip()
353 if (lis2du12_accel_set_odr_raw(dev, odr) < 0) { in lis2du12_init_chip()
354 LOG_ERR("failed to set accelerometer odr %d", odr); in lis2du12_init_chip()
355 return -EIO; in lis2du12_init_chip()
364 const struct lis2du12_config *cfg = dev->config; in lis2du12_init()
366 struct lis2du12_data *data = dev->data; in lis2du12_init()
368 LOG_INF("Initialize device %s", dev->name); in lis2du12_init()
369 data->dev = dev; in lis2du12_init()
373 return -EIO; in lis2du12_init()
377 if (cfg->trig_enabled) { in lis2du12_init()
380 return -EIO; in lis2du12_init()
460 * bus-specific macro at preprocessor time.