Lines Matching +full:mb +full:- +full:0 +full:- +full:15
5 * SPDX-License-Identifier: Apache-2.0
8 * https://www.mouser.hk/datasheet/2/783/BST-BMP180-DS000-1509579.pdf
45 int16_t mb; member
64 const struct bmp180_config *cfg = dev->config; in bmp180_bus_check()
66 return i2c_is_ready_dt(&cfg->i2c) ? 0 : -ENODEV; in bmp180_bus_check()
72 const struct bmp180_config *cfg = dev->config; in bmp180_reg_read()
74 return i2c_burst_read_dt(&cfg->i2c, start, buf, size); in bmp180_reg_read()
80 const struct bmp180_config *cfg = dev->config; in bmp180_reg_write()
82 return i2c_reg_write_byte_dt(&cfg->i2c, reg, val); in bmp180_reg_write()
89 struct bmp180_data *data = dev->data; in bmp180_attr_set_oversampling()
91 /* Value must be a positive value 0-3 */ in bmp180_attr_set_oversampling()
93 return -EINVAL; in bmp180_attr_set_oversampling()
96 data->osr_pressure = val; in bmp180_attr_set_oversampling()
98 return 0; in bmp180_attr_set_oversampling()
113 return -EBUSY; in bmp180_attr_set()
120 ret = bmp180_attr_set_oversampling(dev, chan, val->val1); in bmp180_attr_set()
125 ret = -EINVAL; in bmp180_attr_set()
141 * descripted in the data-sheet in case the register not yet ready wait again in bmp180_conv_ready()
152 if ((ctrlreg & BMP180_STATUS_CMD_RDY) == 0) { in bmp180_conv_ready()
156 --retry; in bmp180_conv_ready()
157 if (retry == 0) { in bmp180_conv_ready()
158 return -ETIMEDOUT; in bmp180_conv_ready()
162 return 0; in bmp180_conv_ready()
169 struct bmp180_data *data = dev->data; in read_raw_temperature()
188 data->raw_temp = (int32_t)(sys_get_be16(reg16)); in read_raw_temperature()
189 data->comp_temp = 0; in read_raw_temperature()
191 return 0; in read_raw_temperature()
201 struct bmp180_data *data = dev->data; in read_raw_pressure()
203 switch (data->osr_pressure) { in read_raw_pressure()
221 return -EINVAL; in read_raw_pressure()
241 pressure >>= (8 - data->osr_pressure); in read_raw_pressure()
242 data->raw_press = pressure; in read_raw_pressure()
244 return 0; in read_raw_pressure()
250 int ret = 0; in bmp180_sample_fetch()
259 return -EBUSY; in bmp180_sample_fetch()
266 if (ret < 0) { in bmp180_sample_fetch()
281 struct bmp180_cal_data *cal = &data->cal; in bmp180_compensate_temp()
283 partial_data1 = (data->raw_temp - cal->ac6) * cal->ac5 / 0x8000; in bmp180_compensate_temp()
284 partial_data2 = cal->mc * 0x800 / (partial_data1 + cal->md); in bmp180_compensate_temp()
287 data->comp_temp = (partial_data1 + partial_data2); in bmp180_compensate_temp()
293 struct bmp180_data *data = dev->data; in bmp180_temp_channel_get()
295 if (data->comp_temp == 0) { in bmp180_temp_channel_get()
299 float ftmp = ((data->comp_temp + 8) >> 4) / 10.0; in bmp180_temp_channel_get()
302 val->val1 = tmp / 1000000; in bmp180_temp_channel_get()
303 val->val2 = tmp % 1000000; in bmp180_temp_channel_get()
305 return 0; in bmp180_temp_channel_get()
318 int32_t raw_pressure = data->raw_press; in bmp180_compensate_press()
319 struct bmp180_cal_data *cal = &data->cal; in bmp180_compensate_press()
321 partial_B6 = data->comp_temp - 4000; in bmp180_compensate_press()
322 partial_X1 = cal->b2 * partial_B6 * (float)(1.0f * partial_B6 / 0x800000); in bmp180_compensate_press()
323 partial_X2 = (cal->ac2 * partial_B6) / 0x800; in bmp180_compensate_press()
325 partial_B3 = (((cal->ac1 * 4 + partial_X3) << data->osr_pressure) + 2) / 4; in bmp180_compensate_press()
327 partial_X1 = (cal->ac3 * partial_B6) / 0x2000; in bmp180_compensate_press()
328 partial_X2 = cal->b1 * partial_B6 * (float)(1.0f * partial_B6 / 0x8000000); in bmp180_compensate_press()
330 partial_B4 = (uint64_t)(cal->ac4 * ((int64_t)(partial_X3) + 32768)) >> 15; in bmp180_compensate_press()
331 partial_B7 = (uint64_t)(raw_pressure - partial_B3) * (50000 >> data->osr_pressure); in bmp180_compensate_press()
335 partial_X1 = comp_press * (float)(1.0f * comp_press / 0x10000); in bmp180_compensate_press()
336 partial_X1 = (partial_X1 * 3038) / 0x10000; in bmp180_compensate_press()
337 partial_X2 = ((int32_t)(-7357 * comp_press)) / 0x10000; in bmp180_compensate_press()
347 struct bmp180_data *data = dev->data; in bmp180_press_channel_get()
349 if (data->comp_temp == 0) { in bmp180_press_channel_get()
358 val->val1 = tmp / 1000; in bmp180_press_channel_get()
359 val->val2 = (tmp % 1000) * 1000; in bmp180_press_channel_get()
361 return 0; in bmp180_press_channel_get()
379 return -ENOTSUP; in bmp180_channel_get()
382 return 0; in bmp180_channel_get()
388 struct bmp180_data *data = dev->data; in bmp180_get_calibration_data()
389 struct bmp180_cal_data *cal = &data->cal; in bmp180_get_calibration_data()
392 sizeof(struct bmp180_cal_data)) < 0) { in bmp180_get_calibration_data()
393 return -EIO; in bmp180_get_calibration_data()
396 cal->ac1 = BSWAP_s16(cal->ac1); in bmp180_get_calibration_data()
397 cal->ac2 = BSWAP_s16(cal->ac2); in bmp180_get_calibration_data()
398 cal->ac3 = BSWAP_s16(cal->ac3); in bmp180_get_calibration_data()
399 cal->ac4 = BSWAP_u16(cal->ac4); in bmp180_get_calibration_data()
400 cal->ac5 = BSWAP_u16(cal->ac5); in bmp180_get_calibration_data()
401 cal->ac6 = BSWAP_u16(cal->ac6); in bmp180_get_calibration_data()
402 cal->b1 = BSWAP_s16(cal->b1); in bmp180_get_calibration_data()
403 cal->b2 = BSWAP_s16(cal->b2); in bmp180_get_calibration_data()
404 cal->mb = BSWAP_s16(cal->mb); in bmp180_get_calibration_data()
405 cal->mc = BSWAP_s16(cal->mc); in bmp180_get_calibration_data()
406 cal->md = BSWAP_s16(cal->md); in bmp180_get_calibration_data()
408 return 0; in bmp180_get_calibration_data()
416 return 0; in bmp180_pm_action()
428 uint8_t val = 0U; in bmp180_init()
430 if (bmp180_bus_check(dev) < 0) { in bmp180_init()
432 return -ENODEV; in bmp180_init()
436 if (bmp180_reg_write(dev, BMP180_REG_CMD, BMP180_CMD_SOFT_RESET) < 0) { in bmp180_init()
438 return -EIO; in bmp180_init()
443 if (bmp180_reg_read(dev, BMP180_REG_CHIPID, &val, 1) < 0) { in bmp180_init()
445 return -EIO; in bmp180_init()
449 LOG_ERR("Unsupported chip detected (0x%x)!", val); in bmp180_init()
450 return -ENODEV; in bmp180_init()
454 if (bmp180_get_calibration_data(dev) < 0) { in bmp180_init()
456 return -EIO; in bmp180_init()
459 return 0; in bmp180_init()