Lines Matching +full:chip +full:- +full:id

4  * SPDX-License-Identifier: Apache-2.0
26 val->val1 = conv_val / 1000000; in mpu6050_convert_accel()
27 val->val2 = conv_val % 1000000; in mpu6050_convert_accel()
38 val->val1 = conv_val / 1000000; in mpu6050_convert_gyro()
39 val->val2 = conv_val % 1000000; in mpu6050_convert_gyro()
59 val->val1 = tmp_val / 1000000; in mpu6050_convert_temp()
60 val->val2 = tmp_val % 1000000; in mpu6050_convert_temp()
67 struct mpu6050_data *drv_data = dev->data; in mpu6050_channel_get()
71 mpu6050_convert_accel(val, drv_data->accel_x, in mpu6050_channel_get()
72 drv_data->accel_sensitivity_shift); in mpu6050_channel_get()
73 mpu6050_convert_accel(val + 1, drv_data->accel_y, in mpu6050_channel_get()
74 drv_data->accel_sensitivity_shift); in mpu6050_channel_get()
75 mpu6050_convert_accel(val + 2, drv_data->accel_z, in mpu6050_channel_get()
76 drv_data->accel_sensitivity_shift); in mpu6050_channel_get()
79 mpu6050_convert_accel(val, drv_data->accel_x, in mpu6050_channel_get()
80 drv_data->accel_sensitivity_shift); in mpu6050_channel_get()
83 mpu6050_convert_accel(val, drv_data->accel_y, in mpu6050_channel_get()
84 drv_data->accel_sensitivity_shift); in mpu6050_channel_get()
87 mpu6050_convert_accel(val, drv_data->accel_z, in mpu6050_channel_get()
88 drv_data->accel_sensitivity_shift); in mpu6050_channel_get()
91 mpu6050_convert_gyro(val, drv_data->gyro_x, in mpu6050_channel_get()
92 drv_data->gyro_sensitivity_x10); in mpu6050_channel_get()
93 mpu6050_convert_gyro(val + 1, drv_data->gyro_y, in mpu6050_channel_get()
94 drv_data->gyro_sensitivity_x10); in mpu6050_channel_get()
95 mpu6050_convert_gyro(val + 2, drv_data->gyro_z, in mpu6050_channel_get()
96 drv_data->gyro_sensitivity_x10); in mpu6050_channel_get()
99 mpu6050_convert_gyro(val, drv_data->gyro_x, in mpu6050_channel_get()
100 drv_data->gyro_sensitivity_x10); in mpu6050_channel_get()
103 mpu6050_convert_gyro(val, drv_data->gyro_y, in mpu6050_channel_get()
104 drv_data->gyro_sensitivity_x10); in mpu6050_channel_get()
107 mpu6050_convert_gyro(val, drv_data->gyro_z, in mpu6050_channel_get()
108 drv_data->gyro_sensitivity_x10); in mpu6050_channel_get()
111 mpu6050_convert_temp(drv_data->device_type, val, drv_data->temp); in mpu6050_channel_get()
114 return -ENOTSUP; in mpu6050_channel_get()
123 struct mpu6050_data *drv_data = dev->data; in mpu6050_sample_fetch()
124 const struct mpu6050_config *cfg = dev->config; in mpu6050_sample_fetch()
127 if (i2c_burst_read_dt(&cfg->i2c, MPU6050_REG_DATA_START, (uint8_t *)buf, in mpu6050_sample_fetch()
130 return -EIO; in mpu6050_sample_fetch()
133 drv_data->accel_x = sys_be16_to_cpu(buf[0]); in mpu6050_sample_fetch()
134 drv_data->accel_y = sys_be16_to_cpu(buf[1]); in mpu6050_sample_fetch()
135 drv_data->accel_z = sys_be16_to_cpu(buf[2]); in mpu6050_sample_fetch()
136 drv_data->temp = sys_be16_to_cpu(buf[3]); in mpu6050_sample_fetch()
137 drv_data->gyro_x = sys_be16_to_cpu(buf[4]); in mpu6050_sample_fetch()
138 drv_data->gyro_y = sys_be16_to_cpu(buf[5]); in mpu6050_sample_fetch()
139 drv_data->gyro_z = sys_be16_to_cpu(buf[6]); in mpu6050_sample_fetch()
154 struct mpu6050_data *drv_data = dev->data; in mpu6050_init()
155 const struct mpu6050_config *cfg = dev->config; in mpu6050_init()
156 uint8_t id, i; in mpu6050_init() local
158 if (!device_is_ready(cfg->i2c.bus)) { in mpu6050_init()
160 return -ENODEV; in mpu6050_init()
163 /* check chip ID */ in mpu6050_init()
164 if (i2c_reg_read_byte_dt(&cfg->i2c, MPU6050_REG_CHIP_ID, &id) < 0) { in mpu6050_init()
165 LOG_ERR("Failed to read chip ID."); in mpu6050_init()
166 return -EIO; in mpu6050_init()
169 if (id == MPU6050_CHIP_ID || id == MPU9250_CHIP_ID || id == MPU6880_CHIP_ID) { in mpu6050_init()
171 drv_data->device_type = DEVICE_TYPE_MPU6050; in mpu6050_init()
172 } else if (id == MPU6500_CHIP_ID) { in mpu6050_init()
174 drv_data->device_type = DEVICE_TYPE_MPU6500; in mpu6050_init()
176 LOG_ERR("Invalid chip ID."); in mpu6050_init()
177 return -EINVAL; in mpu6050_init()
180 /* wake up chip */ in mpu6050_init()
181 if (i2c_reg_update_byte_dt(&cfg->i2c, MPU6050_REG_PWR_MGMT1, in mpu6050_init()
183 LOG_ERR("Failed to wake up chip."); in mpu6050_init()
184 return -EIO; in mpu6050_init()
187 /* set accelerometer full-scale range */ in mpu6050_init()
195 LOG_ERR("Invalid value for accel full-scale range."); in mpu6050_init()
196 return -EINVAL; in mpu6050_init()
199 if (i2c_reg_write_byte_dt(&cfg->i2c, MPU6050_REG_ACCEL_CFG, in mpu6050_init()
201 LOG_ERR("Failed to write accel full-scale range."); in mpu6050_init()
202 return -EIO; in mpu6050_init()
205 drv_data->accel_sensitivity_shift = 14 - i; in mpu6050_init()
207 /* set gyroscope full-scale range */ in mpu6050_init()
215 LOG_ERR("Invalid value for gyro full-scale range."); in mpu6050_init()
216 return -EINVAL; in mpu6050_init()
219 if (i2c_reg_write_byte_dt(&cfg->i2c, MPU6050_REG_GYRO_CFG, in mpu6050_init()
221 LOG_ERR("Failed to write gyro full-scale range."); in mpu6050_init()
222 return -EIO; in mpu6050_init()
225 drv_data->gyro_sensitivity_x10 = mpu6050_gyro_sensitivity_x10[i]; in mpu6050_init()
228 if (cfg->int_gpio.port) { in mpu6050_init()
231 return -EIO; in mpu6050_init()