Lines Matching +full:channel +full:- +full:sens
5 * SPDX-License-Identifier: Apache-2.0
24 const struct ms5837_config *cfg = dev->config; in ms5837_get_measurement()
30 err = i2c_write_dt(&cfg->i2c, &cmd, 1); in ms5837_get_measurement()
37 err = i2c_burst_read_dt(&cfg->i2c, adc_read_cmd, ((uint8_t *)val) + 1, in ms5837_get_measurement()
52 struct ms5837_data *data = dev->data; in ms5837_compensate_30()
55 int64_t SENS; in ms5837_compensate_30() local
62 * (https://www.te.com/usa-en/product-CAT-BLPS0017.html) section in ms5837_compensate_30()
66 dT = adc_temperature - ((int32_t)(data->t_ref) << 8); in ms5837_compensate_30()
67 data->temperature = 2000 + (dT * data->tempsens) / (1ll << 23); in ms5837_compensate_30()
68 OFF = ((int64_t)(data->off_t1) << 16) + (dT * data->tco) / (1ll << 7); in ms5837_compensate_30()
69 SENS = ((int64_t)(data->sens_t1) << 15) + (dT * data->tcs) / (1ll << 8); in ms5837_compensate_30()
72 * (https://www.te.com/usa-en/product-CAT-BLPS0017.html) section in ms5837_compensate_30()
76 temp_sq = (int64_t)(data->temperature - 2000) * (data->temperature - 2000); in ms5837_compensate_30()
77 if (data->temperature < 2000) { in ms5837_compensate_30()
81 if (data->temperature < -1500) { in ms5837_compensate_30()
82 temp_sq = (data->temperature + 1500) * in ms5837_compensate_30()
83 (data->temperature + 1500); in ms5837_compensate_30()
93 OFF -= OFFi; in ms5837_compensate_30()
94 SENS -= SENSi; in ms5837_compensate_30()
96 data->temperature -= Ti; in ms5837_compensate_30()
97 data->pressure = in ms5837_compensate_30()
98 (((SENS * adc_pressure) / (1ll << 21)) - OFF) / (1ll << 13); in ms5837_compensate_30()
103 * MS5837-02B datasheet. (see "Pressure and Temperature Calculation", pages 6 and 7, REV a8 12/2019)
109 struct ms5837_data *data = dev->data; in ms5837_compensate_02()
112 int64_t SENS; in ms5837_compensate_02() local
118 dT = adc_temperature - ((int32_t)(data->t_ref) << 8); in ms5837_compensate_02()
119 data->temperature = 2000 + (dT * data->tempsens) / (1ll << 23); in ms5837_compensate_02()
120 OFF = ((int64_t)(data->off_t1) << 17) + (dT * data->tco) / (1ll << 6); in ms5837_compensate_02()
121 SENS = ((int64_t)(data->sens_t1) << 16) + (dT * data->tcs) / (1ll << 7); in ms5837_compensate_02()
123 temp_sq = (int64_t)(data->temperature - 2000) * (data->temperature - 2000); in ms5837_compensate_02()
124 if (data->temperature < 2000) { in ms5837_compensate_02()
134 OFF -= OFFi; in ms5837_compensate_02()
135 SENS -= SENSi; in ms5837_compensate_02()
137 data->temperature -= Ti; in ms5837_compensate_02()
138 data->pressure = (((SENS * adc_pressure) / (1ll << 21)) - OFF) / (1ll << 15); in ms5837_compensate_02()
142 enum sensor_channel channel) in ms5837_sample_fetch() argument
144 struct ms5837_data *data = dev->data; in ms5837_sample_fetch()
149 __ASSERT_NO_MSG(channel == SENSOR_CHAN_ALL); in ms5837_sample_fetch()
151 err = ms5837_get_measurement(dev, &adc_pressure, data->presure_conv_cmd, in ms5837_sample_fetch()
152 data->presure_conv_delay); in ms5837_sample_fetch()
158 data->temperature_conv_cmd, in ms5837_sample_fetch()
159 data->temperature_conv_delay); in ms5837_sample_fetch()
164 data->comp_func(dev, adc_temperature, adc_pressure); in ms5837_sample_fetch()
173 struct ms5837_data *data = dev->data; in ms5837_channel_get()
178 val->val1 = data->temperature / 100; in ms5837_channel_get()
179 val->val2 = data->temperature % 100 * 10000; in ms5837_channel_get()
183 val->val1 = data->pressure / 1000; in ms5837_channel_get()
184 val->val2 = data->pressure % 1000 * 1000; in ms5837_channel_get()
187 return -ENOTSUP; in ms5837_channel_get()
197 struct ms5837_data *data = dev->data; in ms5837_attr_set()
204 switch (val->val1) { in ms5837_attr_set()
236 LOG_ERR("invalid oversampling rate %d", val->val1); in ms5837_attr_set()
237 return -EINVAL; in ms5837_attr_set()
241 data->presure_conv_cmd = p_conv_cmd; in ms5837_attr_set()
242 data->presure_conv_delay = conv_delay; in ms5837_attr_set()
243 data->temperature_conv_cmd = t_conv_cmd; in ms5837_attr_set()
244 data->temperature_conv_delay = conv_delay; in ms5837_attr_set()
249 data->presure_conv_cmd = p_conv_cmd; in ms5837_attr_set()
250 data->presure_conv_delay = conv_delay; in ms5837_attr_set()
255 data->temperature_conv_cmd = t_conv_cmd; in ms5837_attr_set()
256 data->temperature_conv_delay = conv_delay; in ms5837_attr_set()
260 return -ENOTSUP; in ms5837_attr_set()
263 return -ENOTSUP; in ms5837_attr_set()
275 const struct ms5837_config *cfg = dev->config; in ms5837_read_prom()
278 err = i2c_burst_read_dt(&cfg->i2c, cmd, (uint8_t *)val, 2); in ms5837_read_prom()
290 struct ms5837_data *data = dev->data; in ms5837_init()
291 const struct ms5837_config *cfg = dev->config; in ms5837_init()
295 data->pressure = 0; in ms5837_init()
296 data->temperature = 0; in ms5837_init()
298 data->presure_conv_cmd = MS5837_CMD_CONV_P_256; in ms5837_init()
299 data->presure_conv_delay = 1U; in ms5837_init()
300 data->temperature_conv_cmd = MS5837_CMD_CONV_T_256; in ms5837_init()
301 data->temperature_conv_delay = 1U; in ms5837_init()
303 if (!device_is_ready(cfg->i2c.bus)) { in ms5837_init()
305 return -ENODEV; in ms5837_init()
309 err = i2c_write_dt(&cfg->i2c, &cmd, 1); in ms5837_init()
314 err = ms5837_read_prom(dev, MS5837_CMD_CONV_READ_CRC, &data->factory); in ms5837_init()
320 err = ms5837_read_prom(dev, MS5837_CMD_CONV_READ_SENS_T1, &data->sens_t1); in ms5837_init()
325 err = ms5837_read_prom(dev, MS5837_CMD_CONV_READ_OFF_T1, &data->off_t1); in ms5837_init()
330 err = ms5837_read_prom(dev, MS5837_CMD_CONV_READ_TCS, &data->tcs); in ms5837_init()
335 err = ms5837_read_prom(dev, MS5837_CMD_CONV_READ_TCO, &data->tco); in ms5837_init()
340 err = ms5837_read_prom(dev, MS5837_CMD_CONV_READ_T_REF, &data->t_ref); in ms5837_init()
346 &data->tempsens); in ms5837_init()
351 const int type_id = (data->factory >> 5) & 0x7f; in ms5837_init()
356 data->comp_func = ms5837_compensate_02; in ms5837_init()
359 data->comp_func = ms5837_compensate_30; in ms5837_init()
362 LOG_WRN(" unrecognized type: '%2x', defaulting to MS5837-30", type_id); in ms5837_init()
363 data->comp_func = ms5837_compensate_30; in ms5837_init()