Lines Matching +full:accel +full:- +full:fs

4  * SPDX-License-Identifier: Apache-2.0
42 const struct lsm9ds1_config *cfg = dev->config; in lsm9ds1_reboot()
43 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm9ds1_reboot()
76 return -EINVAL; in lsm9ds1_accel_range_to_fs_val()
90 return -EINVAL; in lsm9ds1_gyro_range_to_fs_val()
94 static int lsm9ds1_accel_fs_val_to_gain(int fs) in lsm9ds1_accel_fs_val_to_gain() argument
96 return lsm9ds1_accel_fs_sens[fs]; in lsm9ds1_accel_fs_val_to_gain()
109 return -EINVAL; in lsm9ds1_accel_freq_to_odr_val()
122 return -EINVAL; in lsm9ds1_gyro_freq_to_odr_val()
127 const struct lsm9ds1_config *cfg = dev->config; in lsm9ds1_accel_set_odr_raw()
128 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm9ds1_accel_set_odr_raw()
129 struct lsm9ds1_data *data = dev->data; in lsm9ds1_accel_set_odr_raw()
146 data->accel_odr = odr; in lsm9ds1_accel_set_odr_raw()
153 const struct lsm9ds1_config *cfg = dev->config; in lsm9ds1_gyro_set_odr_raw()
154 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm9ds1_gyro_set_odr_raw()
155 struct lsm9ds1_data *data = dev->data; in lsm9ds1_gyro_set_odr_raw()
172 data->gyro_odr = odr; in lsm9ds1_gyro_set_odr_raw()
178 struct lsm9ds1_data *data = dev->data; in lsm9ds1_gyro_odr_set()
184 if (odr == data->gyro_odr) { in lsm9ds1_gyro_odr_set()
212 const struct lsm9ds1_config *cfg = dev->config; in lsm9ds1_accel_odr_set()
213 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm9ds1_accel_odr_set()
214 struct lsm9ds1_data *data = dev->data; in lsm9ds1_accel_odr_set()
231 if (odr == data->gyro_odr) { in lsm9ds1_accel_odr_set()
254 if (odr == data->accel_odr) { in lsm9ds1_accel_odr_set()
273 int fs; in lsm9ds1_accel_range_set() local
274 struct lsm9ds1_data *data = dev->data; in lsm9ds1_accel_range_set()
275 const struct lsm9ds1_config *cfg = dev->config; in lsm9ds1_accel_range_set()
276 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm9ds1_accel_range_set()
279 fs = lsm9ds1_accel_range_to_fs_val(range); in lsm9ds1_accel_range_set()
280 if (fs < 0) { in lsm9ds1_accel_range_set()
282 return fs; in lsm9ds1_accel_range_set()
285 ret = lsm9ds1_xl_full_scale_set(ctx, fs); in lsm9ds1_accel_range_set()
287 LOG_DBG("failed to set accelerometer full-scale"); in lsm9ds1_accel_range_set()
291 data->acc_gain = lsm9ds1_accel_fs_val_to_gain(fs); in lsm9ds1_accel_range_set()
297 int fs; in lsm9ds1_gyro_range_set() local
298 struct lsm9ds1_data *data = dev->data; in lsm9ds1_gyro_range_set()
299 const struct lsm9ds1_config *cfg = dev->config; in lsm9ds1_gyro_range_set()
300 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm9ds1_gyro_range_set()
303 fs = lsm9ds1_gyro_range_to_fs_val(range); in lsm9ds1_gyro_range_set()
304 if (fs < 0) { in lsm9ds1_gyro_range_set()
305 return fs; in lsm9ds1_gyro_range_set()
308 ret = lsm9ds1_gy_full_scale_set(ctx, fs); in lsm9ds1_gyro_range_set()
310 LOG_DBG("failed to set gyroscope full-scale"); in lsm9ds1_gyro_range_set()
314 data->gyro_gain = (lsm9ds1_gyro_fs_sens[fs] * GAIN_UNIT_G); in lsm9ds1_gyro_range_set()
325 return lsm9ds1_accel_odr_set(dev, val->val1); in lsm9ds1_accel_config()
327 LOG_DBG("Accel attribute not supported."); in lsm9ds1_accel_config()
328 return -ENOTSUP; in lsm9ds1_accel_config()
341 return lsm9ds1_gyro_odr_set(dev, val->val1); in lsm9ds1_gyro_config()
344 return -ENOTSUP; in lsm9ds1_gyro_config()
360 return -ENOTSUP; in lsm9ds1_attr_set()
367 const struct lsm9ds1_config *cfg = dev->config; in lsm9ds1_sample_fetch_accel()
368 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm9ds1_sample_fetch_accel()
369 struct lsm9ds1_data *data = dev->data; in lsm9ds1_sample_fetch_accel()
372 ret = lsm9ds1_acceleration_raw_get(ctx, data->acc); in lsm9ds1_sample_fetch_accel()
383 const struct lsm9ds1_config *cfg = dev->config; in lsm9ds1_sample_fetch_gyro()
384 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm9ds1_sample_fetch_gyro()
385 struct lsm9ds1_data *data = dev->data; in lsm9ds1_sample_fetch_gyro()
388 ret = lsm9ds1_angular_rate_raw_get(ctx, data->gyro); in lsm9ds1_sample_fetch_gyro()
399 const struct lsm9ds1_config *cfg = dev->config; in lsm9ds1_sample_fetch_temp()
400 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm9ds1_sample_fetch_temp()
401 struct lsm9ds1_data *data = dev->data; in lsm9ds1_sample_fetch_temp()
404 ret = lsm9ds1_temperature_raw_get(ctx, &data->temp_sample); in lsm9ds1_sample_fetch_temp()
436 return -ENOTSUP; in lsm9ds1_sample_fetch()
456 lsm9ds1_accel_convert(val, data->acc[0], sensitivity); in lsm9ds1_accel_get_channel()
459 lsm9ds1_accel_convert(val, data->acc[1], sensitivity); in lsm9ds1_accel_get_channel()
462 lsm9ds1_accel_convert(val, data->acc[2], sensitivity); in lsm9ds1_accel_get_channel()
466 lsm9ds1_accel_convert(val++, data->acc[i], sensitivity); in lsm9ds1_accel_get_channel()
470 return -ENOTSUP; in lsm9ds1_accel_get_channel()
479 return lsm9ds1_accel_get_channel(chan, val, data, data->acc_gain); in lsm9ds1_accel_channel_get()
496 lsm9ds1_gyro_convert(val, data->gyro[0], sensitivity); in lsm9ds1_gyro_get_channel()
499 lsm9ds1_gyro_convert(val, data->gyro[1], sensitivity); in lsm9ds1_gyro_get_channel()
502 lsm9ds1_gyro_convert(val, data->gyro[2], sensitivity); in lsm9ds1_gyro_get_channel()
506 lsm9ds1_gyro_convert(val++, data->gyro[i], sensitivity); in lsm9ds1_gyro_get_channel()
510 return -ENOTSUP; in lsm9ds1_gyro_get_channel()
519 return lsm9ds1_gyro_get_channel(chan, val, data, data->gyro_gain); in lsm9ds1_gyro_channel_get()
525 val->val1 = data->temp_sample / TEMP_SENSITIVITY + TEMP_OFFSET; in lsm9ds1_temp_channel_get()
526 val->val2 = (data->temp_sample % TEMP_SENSITIVITY) * (1000000 / TEMP_SENSITIVITY); in lsm9ds1_temp_channel_get()
533 struct lsm9ds1_data *data = dev->data; in lsm9ds1_channel_get()
554 return -ENOTSUP; in lsm9ds1_channel_get()
568 const struct lsm9ds1_config *cfg = dev->config; in lsm9ds1_init()
569 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm9ds1_init()
570 struct lsm9ds1_data *lsm9ds1 = dev->data; in lsm9ds1_init()
571 uint8_t chip_id, fs; in lsm9ds1_init() local
588 return -EIO; in lsm9ds1_init()
592 LOG_DBG("output data rate is %d\n", cfg->imu_odr); in lsm9ds1_init()
593 ret = lsm9ds1_imu_data_rate_set(ctx, cfg->imu_odr); in lsm9ds1_init()
599 fs = cfg->accel_range; in lsm9ds1_init()
600 LOG_DBG("accel range is %d\n", fs); in lsm9ds1_init()
601 ret = lsm9ds1_xl_full_scale_set(ctx, fs); in lsm9ds1_init()
603 LOG_ERR("failed to set accelerometer range %d", fs); in lsm9ds1_init()
607 lsm9ds1->acc_gain = lsm9ds1_accel_fs_val_to_gain(fs); in lsm9ds1_init()
609 fs = cfg->gyro_range; in lsm9ds1_init()
610 LOG_DBG("gyro range is %d", fs); in lsm9ds1_init()
611 ret = lsm9ds1_gy_full_scale_set(ctx, fs); in lsm9ds1_init()
613 LOG_ERR("failed to set gyroscope range %d\n", fs); in lsm9ds1_init()
616 lsm9ds1->gyro_gain = (lsm9ds1_gyro_fs_sens[fs] * GAIN_UNIT_G); in lsm9ds1_init()