Lines Matching +full:chip +full:- +full:id
4 * SPDX-License-Identifier: Apache-2.0
25 val->val1 = raw_val / divider; in hmc5883l_convert()
26 val->val2 = (((int64_t)raw_val % divider) * 1000000L) / divider; in hmc5883l_convert()
33 struct hmc5883l_data *drv_data = dev->data; in hmc5883l_channel_get()
36 hmc5883l_convert(val, drv_data->x_sample, in hmc5883l_channel_get()
37 hmc5883l_gain[drv_data->gain_idx]); in hmc5883l_channel_get()
39 hmc5883l_convert(val, drv_data->y_sample, in hmc5883l_channel_get()
40 hmc5883l_gain[drv_data->gain_idx]); in hmc5883l_channel_get()
42 hmc5883l_convert(val, drv_data->z_sample, in hmc5883l_channel_get()
43 hmc5883l_gain[drv_data->gain_idx]); in hmc5883l_channel_get()
45 hmc5883l_convert(val, drv_data->x_sample, in hmc5883l_channel_get()
46 hmc5883l_gain[drv_data->gain_idx]); in hmc5883l_channel_get()
47 hmc5883l_convert(val + 1, drv_data->y_sample, in hmc5883l_channel_get()
48 hmc5883l_gain[drv_data->gain_idx]); in hmc5883l_channel_get()
49 hmc5883l_convert(val + 2, drv_data->z_sample, in hmc5883l_channel_get()
50 hmc5883l_gain[drv_data->gain_idx]); in hmc5883l_channel_get()
52 return -ENOTSUP; in hmc5883l_channel_get()
61 struct hmc5883l_data *drv_data = dev->data; in hmc5883l_sample_fetch()
62 const struct hmc5883l_config *config = dev->config; in hmc5883l_sample_fetch()
68 if (i2c_burst_read_dt(&config->i2c, HMC5883L_REG_DATA_START, in hmc5883l_sample_fetch()
71 return -EIO; in hmc5883l_sample_fetch()
74 drv_data->x_sample = sys_be16_to_cpu(buf[0]); in hmc5883l_sample_fetch()
75 drv_data->z_sample = sys_be16_to_cpu(buf[1]); in hmc5883l_sample_fetch()
76 drv_data->y_sample = sys_be16_to_cpu(buf[2]); in hmc5883l_sample_fetch()
91 struct hmc5883l_data *drv_data = dev->data; in hmc5883l_init()
92 const struct hmc5883l_config *config = dev->config; in hmc5883l_init()
93 uint8_t chip_cfg[3], id[3], idx; in hmc5883l_init() local
95 if (!device_is_ready(config->i2c.bus)) { in hmc5883l_init()
97 return -ENODEV; in hmc5883l_init()
100 /* check chip ID */ in hmc5883l_init()
101 if (i2c_burst_read_dt(&config->i2c, HMC5883L_REG_CHIP_ID, id, 3) < 0) { in hmc5883l_init()
102 LOG_ERR("Failed to read chip ID."); in hmc5883l_init()
103 return -EIO; in hmc5883l_init()
106 if (id[0] != HMC5883L_CHIP_ID_A || id[1] != HMC5883L_CHIP_ID_B || in hmc5883l_init()
107 id[2] != HMC5883L_CHIP_ID_C) { in hmc5883l_init()
108 LOG_ERR("Invalid chip ID."); in hmc5883l_init()
109 return -EINVAL; in hmc5883l_init()
120 LOG_ERR("Invalid full-scale range value."); in hmc5883l_init()
121 return -EINVAL; in hmc5883l_init()
124 drv_data->gain_idx = idx; in hmc5883l_init()
135 return -EINVAL; in hmc5883l_init()
140 chip_cfg[1] = drv_data->gain_idx << HMC5883L_GAIN_SHIFT; in hmc5883l_init()
143 if (i2c_burst_write_dt(&config->i2c, HMC5883L_REG_CONFIG_A, in hmc5883l_init()
145 LOG_ERR("Failed to configure chip."); in hmc5883l_init()
146 return -EIO; in hmc5883l_init()
150 if (config->int_gpio.port) { in hmc5883l_init()
153 return -EIO; in hmc5883l_init()