Lines Matching +full:reset +full:- +full:val
1 /* ST Microelectronics IIS2MDC 3-axis magnetometer sensor
5 * SPDX-License-Identifier: Apache-2.0
26 const struct sensor_value *val) in iis2mdc_set_odr() argument
28 struct iis2mdc_data *iis2mdc = dev->data; in iis2mdc_set_odr()
31 switch (val->val1) { in iis2mdc_set_odr()
45 return -EINVAL; in iis2mdc_set_odr()
48 if (iis2mdc_data_rate_set(iis2mdc->ctx, odr)) { in iis2mdc_set_odr()
49 return -EIO; in iis2mdc_set_odr()
58 const struct sensor_value *val) in iis2mdc_set_hard_iron() argument
60 struct iis2mdc_data *iis2mdc = dev->data; in iis2mdc_set_hard_iron()
65 offset[i] = val->val1; in iis2mdc_set_hard_iron()
66 val++; in iis2mdc_set_hard_iron()
69 return iis2mdc_mag_user_offset_set(iis2mdc->ctx, offset); in iis2mdc_set_hard_iron()
74 struct sensor_value *val) in iis2mdc_channel_get_mag() argument
79 struct iis2mdc_data *iis2mdc = dev->data; in iis2mdc_channel_get_mag()
80 struct sensor_value *pval = val; in iis2mdc_channel_get_mag()
98 cval = iis2mdc->mag[i] * 1500; in iis2mdc_channel_get_mag()
99 pval->val1 = cval / 1000000; in iis2mdc_channel_get_mag()
100 pval->val2 = cval % 1000000; in iis2mdc_channel_get_mag()
107 struct sensor_value *val) in iis2mdc_channel_get_temp() argument
109 struct iis2mdc_data *drv_data = dev->data; in iis2mdc_channel_get_temp()
111 val->val1 = drv_data->temp_sample / 100; in iis2mdc_channel_get_temp()
112 val->val2 = (drv_data->temp_sample % 100) * 10000; in iis2mdc_channel_get_temp()
117 struct sensor_value *val) in iis2mdc_channel_get() argument
124 iis2mdc_channel_get_mag(dev, chan, val); in iis2mdc_channel_get()
127 iis2mdc_channel_get_temp(dev, val); in iis2mdc_channel_get()
131 return -ENOTSUP; in iis2mdc_channel_get()
139 const struct sensor_value *val) in iis2mdc_config() argument
144 return iis2mdc_set_odr(dev, val); in iis2mdc_config()
147 return iis2mdc_set_hard_iron(dev, chan, val); in iis2mdc_config()
150 return -ENOTSUP; in iis2mdc_config()
159 const struct sensor_value *val) in iis2mdc_attr_set() argument
167 return iis2mdc_config(dev, chan, attr, val); in iis2mdc_attr_set()
170 return -ENOTSUP; in iis2mdc_attr_set()
178 struct iis2mdc_data *iis2mdc = dev->data; in iis2mdc_sample_fetch_mag()
182 if (iis2mdc_magnetic_raw_get(iis2mdc->ctx, raw_mag) < 0) { in iis2mdc_sample_fetch_mag()
184 return -EIO; in iis2mdc_sample_fetch_mag()
187 iis2mdc->mag[0] = raw_mag[0]; in iis2mdc_sample_fetch_mag()
188 iis2mdc->mag[1] = raw_mag[1]; in iis2mdc_sample_fetch_mag()
189 iis2mdc->mag[2] = raw_mag[2]; in iis2mdc_sample_fetch_mag()
196 struct iis2mdc_data *iis2mdc = dev->data; in iis2mdc_sample_fetch_temp()
201 if (iis2mdc_temperature_raw_get(iis2mdc->ctx, &raw_temp) < 0) { in iis2mdc_sample_fetch_temp()
203 return -EIO; in iis2mdc_sample_fetch_temp()
208 iis2mdc->temp_sample = 2500 + (temp * 100) / 8; in iis2mdc_sample_fetch_temp()
231 return -ENOTSUP; in iis2mdc_sample_fetch()
248 const struct iis2mdc_dev_config *const cfg = dev->config; in iis2mdc_init()
249 struct iis2mdc_data *iis2mdc = dev->data; in iis2mdc_init()
252 iis2mdc->dev = dev; in iis2mdc_init()
254 if (cfg->bus_init(dev) < 0) { in iis2mdc_init()
255 return -EINVAL; in iis2mdc_init()
259 if (iis2mdc_device_id_get(iis2mdc->ctx, &wai) < 0) { in iis2mdc_init()
260 return -EIO; in iis2mdc_init()
265 return -EINVAL; in iis2mdc_init()
268 /* reset sensor configuration */ in iis2mdc_init()
269 if (iis2mdc_reset_set(iis2mdc->ctx, PROPERTY_ENABLE) < 0) { in iis2mdc_init()
270 LOG_DBG("s/w reset failed\n"); in iis2mdc_init()
271 return -EIO; in iis2mdc_init()
277 if (iis2mdc_block_data_update_set(iis2mdc->ctx, PROPERTY_ENABLE) < 0) { in iis2mdc_init()
279 return -EIO; in iis2mdc_init()
283 if (iis2mdc_data_rate_set(iis2mdc->ctx, IIS2MDC_ODR_10Hz)) { in iis2mdc_init()
285 return -EIO; in iis2mdc_init()
288 /* Set / Reset sensor mode */ in iis2mdc_init()
289 if (iis2mdc_set_rst_mode_set(iis2mdc->ctx, in iis2mdc_init()
291 LOG_DBG("reset sensor mode failed\n"); in iis2mdc_init()
292 return -EIO; in iis2mdc_init()
296 if (iis2mdc_offset_temp_comp_set(iis2mdc->ctx, PROPERTY_ENABLE)) { in iis2mdc_init()
298 return -EIO; in iis2mdc_init()
302 if (iis2mdc_operating_mode_set(iis2mdc->ctx, IIS2MDC_CONTINUOUS_MODE)) { in iis2mdc_init()
304 return -EIO; in iis2mdc_init()
310 return -EIO; in iis2mdc_init()
374 * bus-specific macro at preprocessor time.