Lines Matching +full:measurement +full:- +full:mode
4 * SPDX-License-Identifier: Apache-2.0
25 * @brief Perform the bus transaction to start measurement.
28 * @param chan Channel ID for starting the measurement
33 struct akm09918c_data *data = dev->data; in akm09918c_start_measurement()
34 const struct akm09918c_config *cfg = dev->config; in akm09918c_start_measurement()
39 return -EINVAL; in akm09918c_start_measurement()
42 if (data->mode == AKM09918C_CNTL2_PWR_DOWN) { in akm09918c_start_measurement()
43 if (i2c_reg_write_byte_dt(&cfg->i2c, AKM09918C_REG_CNTL2, in akm09918c_start_measurement()
45 LOG_ERR("Failed to start measurement."); in akm09918c_start_measurement()
46 return -EIO; in akm09918c_start_measurement()
64 const struct akm09918c_config *cfg = dev->config; in akm09918c_fetch_measurement()
68 if (i2c_burst_read_dt(&cfg->i2c, AKM09918C_REG_ST1, buf, ARRAY_SIZE(buf)) != 0) { in akm09918c_fetch_measurement()
70 return -EIO; in akm09918c_fetch_measurement()
75 return -EBUSY; in akm09918c_fetch_measurement()
87 struct akm09918c_data *data = dev->data; in akm09918c_sample_fetch()
98 return akm09918c_fetch_measurement(dev, &data->x_sample, &data->y_sample, &data->z_sample); in akm09918c_sample_fetch()
105 val->val1 = conv_val / 1000000; in akm09918c_convert()
106 val->val2 = conv_val - (val->val1 * 1000000); in akm09918c_convert()
112 struct akm09918c_data *data = dev->data; in akm09918c_channel_get()
115 akm09918c_convert(val, data->x_sample); in akm09918c_channel_get()
116 akm09918c_convert(val + 1, data->y_sample); in akm09918c_channel_get()
117 akm09918c_convert(val + 2, data->z_sample); in akm09918c_channel_get()
119 akm09918c_convert(val, data->x_sample); in akm09918c_channel_get()
121 akm09918c_convert(val, data->y_sample); in akm09918c_channel_get()
123 akm09918c_convert(val, data->z_sample); in akm09918c_channel_get()
126 return -ENOTSUP; in akm09918c_channel_get()
135 struct akm09918c_data *data = dev->data; in akm09918c_attr_get()
144 return -EINVAL; in akm09918c_attr_get()
146 akm09918c_reg_to_hz(data->mode, val); in akm09918c_attr_get()
150 return -EINVAL; in akm09918c_attr_get()
158 const struct akm09918c_config *cfg = dev->config; in akm09918c_attr_set()
159 struct akm09918c_data *data = dev->data; in akm09918c_attr_set()
169 return -EINVAL; in akm09918c_attr_set()
172 uint8_t mode = akm09918c_hz_to_reg(val); in akm09918c_attr_set() local
174 res = i2c_reg_write_byte_dt(&cfg->i2c, AKM09918C_REG_CNTL2, mode); in akm09918c_attr_set()
177 return -EIO; in akm09918c_attr_set()
179 data->mode = mode; in akm09918c_attr_set()
183 return -EINVAL; in akm09918c_attr_set()
196 LOG_ERR("Failed to read who-am-i register (rc=%d)", rc); in akm09918c_check_who_am_i()
197 return -EIO; in akm09918c_check_who_am_i()
201 LOG_ERR("Wrong who-am-i value"); in akm09918c_check_who_am_i()
202 return -EINVAL; in akm09918c_check_who_am_i()
210 const struct akm09918c_config *cfg = dev->config; in akm09918c_init()
211 struct akm09918c_data *data = dev->data; in akm09918c_init()
214 if (!i2c_is_ready_dt(&cfg->i2c)) { in akm09918c_init()
216 return -ENODEV; in akm09918c_init()
220 rc = i2c_reg_write_byte_dt(&cfg->i2c, AKM09918C_REG_CNTL3, in akm09918c_init()
224 return -EIO; in akm09918c_init()
228 rc = akm09918c_check_who_am_i(&cfg->i2c); in akm09918c_init()
232 data->mode = AKM09918C_CNTL2_PWR_DOWN; in akm09918c_init()
234 /* init work for fetching after measurement has completed */ in akm09918c_init()
235 k_work_init_delayable(&data->work_ctx.async_fetch_work, akm09918_async_fetch); in akm09918c_init()