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

4  * SPDX-License-Identifier: Apache-2.0
25 val->val1 = raw_val / divider; in lis3mdl_convert()
26 val->val2 = (((int64_t)raw_val % divider) * 1000000L) / divider; in lis3mdl_convert()
33 struct lis3mdl_data *drv_data = dev->data; in lis3mdl_channel_get()
37 lis3mdl_convert(val, drv_data->x_sample, in lis3mdl_channel_get()
39 lis3mdl_convert(val + 1, drv_data->y_sample, in lis3mdl_channel_get()
41 lis3mdl_convert(val + 2, drv_data->z_sample, in lis3mdl_channel_get()
44 lis3mdl_convert(val, drv_data->x_sample, in lis3mdl_channel_get()
47 lis3mdl_convert(val, drv_data->y_sample, in lis3mdl_channel_get()
50 lis3mdl_convert(val, drv_data->z_sample, in lis3mdl_channel_get()
54 lis3mdl_convert(val, drv_data->temp_sample, 8); in lis3mdl_channel_get()
55 val->val1 += 25; in lis3mdl_channel_get()
57 return -ENOTSUP; in lis3mdl_channel_get()
65 struct lis3mdl_data *drv_data = dev->data; in lis3mdl_sample_fetch()
66 const struct lis3mdl_config *config = dev->config; in lis3mdl_sample_fetch()
72 if (i2c_burst_read_dt(&config->i2c, LIS3MDL_REG_SAMPLE_START, in lis3mdl_sample_fetch()
75 return -EIO; in lis3mdl_sample_fetch()
79 * the chip doesn't allow fetching temperature data in in lis3mdl_sample_fetch()
83 if (i2c_burst_read_dt(&config->i2c, LIS3MDL_REG_SAMPLE_START + 6, in lis3mdl_sample_fetch()
86 return -EIO; in lis3mdl_sample_fetch()
89 drv_data->x_sample = sys_le16_to_cpu(buf[0]); in lis3mdl_sample_fetch()
90 drv_data->y_sample = sys_le16_to_cpu(buf[1]); in lis3mdl_sample_fetch()
91 drv_data->z_sample = sys_le16_to_cpu(buf[2]); in lis3mdl_sample_fetch()
92 drv_data->temp_sample = sys_le16_to_cpu(buf[3]); in lis3mdl_sample_fetch()
107 const struct lis3mdl_config *config = dev->config; in lis3mdl_init()
109 uint8_t id, idx; in lis3mdl_init() local
111 if (!device_is_ready(config->i2c.bus)) { in lis3mdl_init()
113 return -ENODEV; in lis3mdl_init()
116 /* check chip ID */ in lis3mdl_init()
117 if (i2c_reg_read_byte_dt(&config->i2c, LIS3MDL_REG_WHO_AM_I, &id) < 0) { in lis3mdl_init()
118 LOG_ERR("Failed to read chip ID."); in lis3mdl_init()
119 return -EIO; in lis3mdl_init()
122 if (id != LIS3MDL_CHIP_ID) { in lis3mdl_init()
123 LOG_ERR("Invalid chip ID."); in lis3mdl_init()
124 return -EINVAL; in lis3mdl_init()
136 return -EINVAL; in lis3mdl_init()
148 if (i2c_write_dt(&config->i2c, chip_cfg, 6) < 0) { in lis3mdl_init()
149 LOG_DBG("Failed to configure chip."); in lis3mdl_init()
150 return -EIO; in lis3mdl_init()
154 if (config->irq_gpio.port) { in lis3mdl_init()
157 return -EIO; in lis3mdl_init()