Lines Matching +full:chip +full:- +full:id
4 * SPDX-License-Identifier: Apache-2.0
64 val->val1 = conv_val / 1000000; in mpu9250_convert_accel()
65 val->val2 = conv_val % 1000000; in mpu9250_convert_accel()
76 val->val1 = conv_val / 1000000; in mpu9250_convert_gyro()
77 val->val2 = conv_val % 1000000; in mpu9250_convert_gyro()
85 val->val1 = (raw_val / MPU0259_TEMP_SENSITIVITY) + MPU9250_TEMP_OFFSET; in mpu9250_convert_temp()
86 val->val2 = (((int64_t)(raw_val % MPU0259_TEMP_SENSITIVITY) * 1000000) in mpu9250_convert_temp()
89 if (val->val2 < 0) { in mpu9250_convert_temp()
90 val->val1--; in mpu9250_convert_temp()
91 val->val2 += 1000000; in mpu9250_convert_temp()
92 } else if (val->val2 >= 1000000) { in mpu9250_convert_temp()
93 val->val1++; in mpu9250_convert_temp()
94 val->val2 -= 1000000; in mpu9250_convert_temp()
102 struct mpu9250_data *drv_data = dev->data; in mpu9250_channel_get()
109 mpu9250_convert_accel(val, drv_data->accel_x, in mpu9250_channel_get()
110 drv_data->accel_sensitivity_shift); in mpu9250_channel_get()
111 mpu9250_convert_accel(val + 1, drv_data->accel_y, in mpu9250_channel_get()
112 drv_data->accel_sensitivity_shift); in mpu9250_channel_get()
113 mpu9250_convert_accel(val + 2, drv_data->accel_z, in mpu9250_channel_get()
114 drv_data->accel_sensitivity_shift); in mpu9250_channel_get()
117 mpu9250_convert_accel(val, drv_data->accel_x, in mpu9250_channel_get()
118 drv_data->accel_sensitivity_shift); in mpu9250_channel_get()
121 mpu9250_convert_accel(val, drv_data->accel_y, in mpu9250_channel_get()
122 drv_data->accel_sensitivity_shift); in mpu9250_channel_get()
125 mpu9250_convert_accel(val, drv_data->accel_z, in mpu9250_channel_get()
126 drv_data->accel_sensitivity_shift); in mpu9250_channel_get()
129 mpu9250_convert_gyro(val, drv_data->gyro_x, in mpu9250_channel_get()
130 drv_data->gyro_sensitivity_x10); in mpu9250_channel_get()
131 mpu9250_convert_gyro(val + 1, drv_data->gyro_y, in mpu9250_channel_get()
132 drv_data->gyro_sensitivity_x10); in mpu9250_channel_get()
133 mpu9250_convert_gyro(val + 2, drv_data->gyro_z, in mpu9250_channel_get()
134 drv_data->gyro_sensitivity_x10); in mpu9250_channel_get()
137 mpu9250_convert_gyro(val, drv_data->gyro_x, in mpu9250_channel_get()
138 drv_data->gyro_sensitivity_x10); in mpu9250_channel_get()
141 mpu9250_convert_gyro(val, drv_data->gyro_y, in mpu9250_channel_get()
142 drv_data->gyro_sensitivity_x10); in mpu9250_channel_get()
145 mpu9250_convert_gyro(val, drv_data->gyro_z, in mpu9250_channel_get()
146 drv_data->gyro_sensitivity_x10); in mpu9250_channel_get()
150 ret = ak8963_convert_magn(val, drv_data->magn_x, in mpu9250_channel_get()
151 drv_data->magn_scale_x, in mpu9250_channel_get()
152 drv_data->magn_st2); in mpu9250_channel_get()
156 ret = ak8963_convert_magn(val + 1, drv_data->magn_y, in mpu9250_channel_get()
157 drv_data->magn_scale_y, in mpu9250_channel_get()
158 drv_data->magn_st2); in mpu9250_channel_get()
162 ret = ak8963_convert_magn(val + 2, drv_data->magn_z, in mpu9250_channel_get()
163 drv_data->magn_scale_z, in mpu9250_channel_get()
164 drv_data->magn_st2); in mpu9250_channel_get()
167 return ak8963_convert_magn(val, drv_data->magn_x, in mpu9250_channel_get()
168 drv_data->magn_scale_x, in mpu9250_channel_get()
169 drv_data->magn_st2); in mpu9250_channel_get()
171 return ak8963_convert_magn(val, drv_data->magn_y, in mpu9250_channel_get()
172 drv_data->magn_scale_y, in mpu9250_channel_get()
173 drv_data->magn_st2); in mpu9250_channel_get()
175 return ak8963_convert_magn(val, drv_data->magn_z, in mpu9250_channel_get()
176 drv_data->magn_scale_z, in mpu9250_channel_get()
177 drv_data->magn_st2); in mpu9250_channel_get()
179 mpu9250_convert_temp(val, drv_data->temp); in mpu9250_channel_get()
183 return -ENOTSUP; in mpu9250_channel_get()
192 struct mpu9250_data *drv_data = dev->data; in mpu9250_sample_fetch()
193 const struct mpu9250_config *cfg = dev->config; in mpu9250_sample_fetch()
197 ret = i2c_burst_read_dt(&cfg->i2c, in mpu9250_sample_fetch()
205 drv_data->accel_x = sys_be16_to_cpu(buf[0]); in mpu9250_sample_fetch()
206 drv_data->accel_y = sys_be16_to_cpu(buf[1]); in mpu9250_sample_fetch()
207 drv_data->accel_z = sys_be16_to_cpu(buf[2]); in mpu9250_sample_fetch()
208 drv_data->temp = sys_be16_to_cpu(buf[3]); in mpu9250_sample_fetch()
209 drv_data->gyro_x = sys_be16_to_cpu(buf[4]); in mpu9250_sample_fetch()
210 drv_data->gyro_y = sys_be16_to_cpu(buf[5]); in mpu9250_sample_fetch()
211 drv_data->gyro_z = sys_be16_to_cpu(buf[6]); in mpu9250_sample_fetch()
213 drv_data->magn_x = sys_le16_to_cpu(buf[7]); in mpu9250_sample_fetch()
214 drv_data->magn_y = sys_le16_to_cpu(buf[8]); in mpu9250_sample_fetch()
215 drv_data->magn_z = sys_le16_to_cpu(buf[9]); in mpu9250_sample_fetch()
216 drv_data->magn_st2 = ((uint8_t *)buf)[20]; in mpu9250_sample_fetch()
217 LOG_DBG("magn_st2: %u", drv_data->magn_st2); in mpu9250_sample_fetch()
238 struct mpu9250_data *drv_data = dev->data; in mpu9250_init()
239 const struct mpu9250_config *cfg = dev->config; in mpu9250_init()
240 uint8_t id; in mpu9250_init() local
243 if (!device_is_ready(cfg->i2c.bus)) { in mpu9250_init()
244 LOG_ERR("I2C dev %s not ready", cfg->i2c.bus->name); in mpu9250_init()
245 return -ENODEV; in mpu9250_init()
248 /* check chip ID */ in mpu9250_init()
249 ret = i2c_reg_read_byte_dt(&cfg->i2c, MPU9250_REG_CHIP_ID, &id); in mpu9250_init()
251 LOG_ERR("Failed to read chip ID."); in mpu9250_init()
255 if (id != MPU9250_CHIP_ID) { in mpu9250_init()
256 LOG_ERR("Invalid chip ID."); in mpu9250_init()
257 return -ENOTSUP; in mpu9250_init()
260 /* wake up chip */ in mpu9250_init()
261 ret = i2c_reg_update_byte_dt(&cfg->i2c, in mpu9250_init()
265 LOG_ERR("Failed to wake up chip."); in mpu9250_init()
269 if (cfg->accel_fs > MPU9250_ACCEL_FS_MAX) { in mpu9250_init()
270 LOG_ERR("Accel FS is too big: %d", cfg->accel_fs); in mpu9250_init()
271 return -EINVAL; in mpu9250_init()
274 ret = i2c_reg_write_byte_dt(&cfg->i2c, MPU9250_REG_ACCEL_CFG, in mpu9250_init()
275 cfg->accel_fs << MPU9250_ACCEL_FS_SHIFT); in mpu9250_init()
277 LOG_ERR("Failed to write accel full-scale range."); in mpu9250_init()
280 drv_data->accel_sensitivity_shift = 14 - cfg->accel_fs; in mpu9250_init()
282 if (cfg->gyro_fs > MPU9250_GYRO_FS_MAX) { in mpu9250_init()
283 LOG_ERR("Gyro FS is too big: %d", cfg->gyro_fs); in mpu9250_init()
284 return -EINVAL; in mpu9250_init()
287 ret = i2c_reg_write_byte_dt(&cfg->i2c, MPU9250_REG_GYRO_CFG, in mpu9250_init()
288 cfg->gyro_fs << MPU9250_GYRO_FS_SHIFT); in mpu9250_init()
290 LOG_ERR("Failed to write gyro full-scale range."); in mpu9250_init()
294 if (cfg->gyro_dlpf > MPU9250_GYRO_DLPF_MAX) { in mpu9250_init()
295 LOG_ERR("Gyro DLPF is too big: %d", cfg->gyro_dlpf); in mpu9250_init()
296 return -EINVAL; in mpu9250_init()
299 ret = i2c_reg_write_byte_dt(&cfg->i2c, MPU9250_REG_CONFIG, in mpu9250_init()
300 cfg->gyro_dlpf); in mpu9250_init()
306 if (cfg->accel_dlpf > MPU9250_ACCEL_DLPF_MAX) { in mpu9250_init()
307 LOG_ERR("Accel DLPF is too big: %d", cfg->accel_dlpf); in mpu9250_init()
308 return -EINVAL; in mpu9250_init()
311 ret = i2c_reg_write_byte_dt(&cfg->i2c, MPU9250_REG_ACCEL_CFG2, in mpu9250_init()
312 cfg->accel_dlpf); in mpu9250_init()
318 ret = i2c_reg_write_byte_dt(&cfg->i2c, MPU9250_REG_SR_DIV, in mpu9250_init()
319 cfg->gyro_sr_div); in mpu9250_init()
325 drv_data->gyro_sensitivity_x10 = in mpu9250_init()
326 mpu9250_gyro_sensitivity_x10[cfg->gyro_fs]; in mpu9250_init()