Lines Matching +full:full +full:- +full:scale
1 /* lsm6ds0.c - Driver for LSM6DS0 accelerometer, gyroscope and
8 * SPDX-License-Identifier: Apache-2.0
27 const struct lsm6ds0_config *config = dev->config; in lsm6ds0_reboot()
29 if (i2c_reg_update_byte_dt(&config->i2c, LSM6DS0_REG_CTRL_REG8, in lsm6ds0_reboot()
32 return -EIO; in lsm6ds0_reboot()
43 const struct lsm6ds0_config *config = dev->config; in lsm6ds0_accel_axis_ctrl()
48 return i2c_reg_update_byte_dt(&config->i2c, LSM6DS0_REG_CTRL_REG5_XL, in lsm6ds0_accel_axis_ctrl()
57 const struct lsm6ds0_config *config = dev->config; in lsm6ds0_accel_set_fs_raw()
59 if (i2c_reg_update_byte_dt(&config->i2c, LSM6DS0_REG_CTRL_REG6_XL, in lsm6ds0_accel_set_fs_raw()
62 return -EIO; in lsm6ds0_accel_set_fs_raw()
70 const struct lsm6ds0_config *config = dev->config; in lsm6ds0_accel_set_odr_raw()
72 if (i2c_reg_update_byte_dt(&config->i2c, LSM6DS0_REG_CTRL_REG6_XL, in lsm6ds0_accel_set_odr_raw()
75 return -EIO; in lsm6ds0_accel_set_odr_raw()
85 const struct lsm6ds0_config *config = dev->config; in lsm6ds0_gyro_axis_ctrl()
90 return i2c_reg_update_byte_dt(&config->i2c, LSM6DS0_REG_CTRL_REG4, in lsm6ds0_gyro_axis_ctrl()
99 const struct lsm6ds0_config *config = dev->config; in lsm6ds0_gyro_set_fs_raw()
101 if (i2c_reg_update_byte_dt(&config->i2c, LSM6DS0_REG_CTRL_REG1_G, in lsm6ds0_gyro_set_fs_raw()
104 return -EIO; in lsm6ds0_gyro_set_fs_raw()
112 const struct lsm6ds0_config *config = dev->config; in lsm6ds0_gyro_set_odr_raw()
114 if (i2c_reg_update_byte_dt(&config->i2c, LSM6DS0_REG_CTRL_REG1_G, in lsm6ds0_gyro_set_odr_raw()
117 return -EIO; in lsm6ds0_gyro_set_odr_raw()
125 struct lsm6ds0_data *data = dev->data; in lsm6ds0_sample_fetch_accel()
126 const struct lsm6ds0_config *config = dev->config; in lsm6ds0_sample_fetch_accel()
129 if (i2c_burst_read_dt(&config->i2c, LSM6DS0_REG_OUT_X_L_XL, buf, sizeof(buf)) < 0) { in lsm6ds0_sample_fetch_accel()
131 return -EIO; in lsm6ds0_sample_fetch_accel()
135 data->accel_sample_x = (int16_t)((uint16_t)(buf[0]) | in lsm6ds0_sample_fetch_accel()
139 data->accel_sample_y = (int16_t)((uint16_t)(buf[2]) | in lsm6ds0_sample_fetch_accel()
143 data->accel_sample_z = (int16_t)((uint16_t)(buf[4]) | in lsm6ds0_sample_fetch_accel()
152 struct lsm6ds0_data *data = dev->data; in lsm6ds0_sample_fetch_gyro()
153 const struct lsm6ds0_config *config = dev->config; in lsm6ds0_sample_fetch_gyro()
156 if (i2c_burst_read_dt(&config->i2c, LSM6DS0_REG_OUT_X_L_G, buf, sizeof(buf)) < 0) { in lsm6ds0_sample_fetch_gyro()
158 return -EIO; in lsm6ds0_sample_fetch_gyro()
162 data->gyro_sample_x = (int16_t)((uint16_t)(buf[0]) | in lsm6ds0_sample_fetch_gyro()
166 data->gyro_sample_y = (int16_t)((uint16_t)(buf[2]) | in lsm6ds0_sample_fetch_gyro()
170 data->gyro_sample_z = (int16_t)((uint16_t)(buf[4]) | in lsm6ds0_sample_fetch_gyro()
180 struct lsm6ds0_data *data = dev->data; in lsm6ds0_sample_fetch_temp()
181 const struct lsm6ds0_config *config = dev->config; in lsm6ds0_sample_fetch_temp()
184 if (i2c_burst_read_dt(&config->i2c, LSM6DS0_REG_OUT_TEMP_L, buf, sizeof(buf)) < 0) { in lsm6ds0_sample_fetch_temp()
186 return -EIO; in lsm6ds0_sample_fetch_temp()
189 data->temp_sample = (int16_t)((uint16_t)(buf[0]) | in lsm6ds0_sample_fetch_temp()
226 return -ENOTSUP; in lsm6ds0_sample_fetch()
233 float scale) in lsm6ds0_accel_convert() argument
237 dval = (double)(raw_val) * (double)scale / 32767.0; in lsm6ds0_accel_convert()
238 val->val1 = (int32_t)dval; in lsm6ds0_accel_convert()
239 val->val2 = ((int32_t)(dval * 1000000)) % 1000000; in lsm6ds0_accel_convert()
245 float scale) in lsm6ds0_accel_get_channel() argument
250 lsm6ds0_accel_convert(val, data->accel_sample_x, scale); in lsm6ds0_accel_get_channel()
255 lsm6ds0_accel_convert(val, data->accel_sample_y, scale); in lsm6ds0_accel_get_channel()
260 lsm6ds0_accel_convert(val, data->accel_sample_z, scale); in lsm6ds0_accel_get_channel()
265 lsm6ds0_accel_convert(val, data->accel_sample_x, scale); in lsm6ds0_accel_get_channel()
268 lsm6ds0_accel_convert(val + 1, data->accel_sample_y, scale); in lsm6ds0_accel_get_channel()
271 lsm6ds0_accel_convert(val + 2, data->accel_sample_z, scale); in lsm6ds0_accel_get_channel()
275 return -ENOTSUP; in lsm6ds0_accel_get_channel()
295 val->val1 = (int32_t)dval; in lsm6ds0_gyro_convert()
296 val->val2 = ((int32_t)(dval * 1000000)) % 1000000; in lsm6ds0_gyro_convert()
307 lsm6ds0_gyro_convert(val, data->gyro_sample_x, numerator); in lsm6ds0_gyro_get_channel()
312 lsm6ds0_gyro_convert(val, data->gyro_sample_y, numerator); in lsm6ds0_gyro_get_channel()
317 lsm6ds0_gyro_convert(val, data->gyro_sample_z, numerator); in lsm6ds0_gyro_get_channel()
322 lsm6ds0_gyro_convert(val, data->gyro_sample_x, numerator); in lsm6ds0_gyro_get_channel()
325 lsm6ds0_gyro_convert(val + 1, data->gyro_sample_y, numerator); in lsm6ds0_gyro_get_channel()
328 lsm6ds0_gyro_convert(val + 2, data->gyro_sample_z, numerator); in lsm6ds0_gyro_get_channel()
332 return -ENOTSUP; in lsm6ds0_gyro_get_channel()
351 val->val1 = data->temp_sample / 16 + 25; in lsm6ds0_gyro_channel_get_temp()
352 val->val2 = (data->temp_sample % 16) * (1000000 / 16); in lsm6ds0_gyro_channel_get_temp()
360 struct lsm6ds0_data *data = dev->data; in lsm6ds0_channel_get()
381 return -ENOTSUP; in lsm6ds0_channel_get()
394 const struct lsm6ds0_config *config = dev->config; in lsm6ds0_init_chip()
399 return -EIO; in lsm6ds0_init_chip()
402 if (i2c_reg_read_byte_dt(&config->i2c, LSM6DS0_REG_WHO_AM_I, &chip_id) < 0) { in lsm6ds0_init_chip()
404 return -EIO; in lsm6ds0_init_chip()
408 return -EIO; in lsm6ds0_init_chip()
416 return -EIO; in lsm6ds0_init_chip()
421 LOG_DBG("failed to set accelerometer full-scale"); in lsm6ds0_init_chip()
422 return -EIO; in lsm6ds0_init_chip()
428 return -EIO; in lsm6ds0_init_chip()
435 return -EIO; in lsm6ds0_init_chip()
440 LOG_DBG("failed to set gyroscope full-scale"); in lsm6ds0_init_chip()
441 return -EIO; in lsm6ds0_init_chip()
447 return -EIO; in lsm6ds0_init_chip()
450 if (i2c_reg_update_byte_dt(&config->i2c, LSM6DS0_REG_CTRL_REG8, in lsm6ds0_init_chip()
459 return -EIO; in lsm6ds0_init_chip()
467 const struct lsm6ds0_config * const config = dev->config; in lsm6ds0_init()
469 if (!device_is_ready(config->i2c.bus)) { in lsm6ds0_init()
471 return -ENODEV; in lsm6ds0_init()
476 return -EIO; in lsm6ds0_init()