Lines Matching +full:continuous +full:- +full:convert
5 * SPDX-License-Identifier: Apache-2.0
42 struct bmp581_config *conf = (struct bmp581_config *)dev->config; in set_power_mode()
48 return -EINVAL; in set_power_mode()
61 * mode or continuous mode. in set_power_mode()
64 ret = i2c_reg_read_byte_dt(&conf->i2c, BMP5_REG_ODR_CONFIG, &odr); in set_power_mode()
70 ret = i2c_reg_write_byte_dt(&conf->i2c, BMP5_REG_ODR_CONFIG, odr); in set_power_mode()
88 ret = -ENOTSUP; in set_power_mode()
95 ret = i2c_reg_write_byte_dt(&conf->i2c, BMP5_REG_ODR_CONFIG, odr); in set_power_mode()
99 ret = -EINVAL; in set_power_mode()
108 struct bmp581_config *conf = (struct bmp581_config *)dev->config; in get_power_mode()
112 return -EINVAL; in get_power_mode()
118 ret = i2c_reg_read_byte_dt(&conf->i2c, BMP5_REG_ODR_CONFIG, ®); in get_power_mode()
156 ret = -EINVAL; in get_power_mode()
170 return -EINVAL; in power_up_check()
180 rslt = -EFAULT; in power_up_check()
189 struct bmp581_config *conf = (struct bmp581_config *)dev->config; in get_interrupt_status()
192 return -EINVAL; in get_interrupt_status()
195 return i2c_reg_read_byte_dt(&conf->i2c, BMP5_REG_INT_STATUS, int_status); in get_interrupt_status()
200 struct bmp581_config *conf = (struct bmp581_config *)dev->config; in get_nvm_status()
203 return -EINVAL; in get_nvm_status()
206 return i2c_reg_read_byte_dt(&conf->i2c, BMP5_REG_STATUS, nvm_status); in get_nvm_status()
214 return -EINVAL; in validate_chip_id()
217 if ((drv->chip_id == BMP5_CHIP_ID_PRIM) || (drv->chip_id == BMP5_CHIP_ID_SEC)) { in validate_chip_id()
220 drv->chip_id = 0; in validate_chip_id()
221 rslt = -ENODEV; in validate_chip_id()
234 struct bmp581_config *conf = (struct bmp581_config *)dev->config; in get_osr_odr_press_config()
243 return -EINVAL; in get_osr_odr_press_config()
247 rslt = i2c_burst_read_dt(&conf->i2c, BMP5_REG_OSR_CONFIG, reg_data, 2); in get_osr_odr_press_config()
250 osr_odr_press_cfg->osr_t = BMP5_GET_BITS_POS_0(reg_data[0], BMP5_TEMP_OS); in get_osr_odr_press_config()
251 osr_odr_press_cfg->osr_p = BMP5_GET_BITSLICE(reg_data[0], BMP5_PRESS_OS); in get_osr_odr_press_config()
252 osr_odr_press_cfg->press_en = BMP5_GET_BITSLICE(reg_data[0], BMP5_PRESS_EN); in get_osr_odr_press_config()
253 osr_odr_press_cfg->odr = BMP5_GET_BITSLICE(reg_data[1], BMP5_ODR); in get_osr_odr_press_config()
263 return -EINVAL; in set_osr_config()
266 struct bmp581_data *drv = (struct bmp581_data *)dev->data; in set_osr_config()
267 struct bmp581_config *conf = (struct bmp581_config *)dev->config; in set_osr_config()
270 uint8_t oversampling = osr->val1; in set_osr_config()
271 uint8_t press_en = osr->val2 != 0; /* if it is not 0 then pressure is enabled */ in set_osr_config()
274 ret = i2c_reg_read_byte_dt(&conf->i2c, BMP5_REG_OSR_CONFIG, &osr_val); in set_osr_config()
290 ret = -ENOTSUP; in set_osr_config()
295 ret = i2c_reg_write_byte_dt(&conf->i2c, BMP5_REG_OSR_CONFIG, osr_val); in set_osr_config()
296 get_osr_odr_press_config(&drv->osr_odr_press_config, dev); in set_osr_config()
306 return -EINVAL; in set_odr_config()
309 struct bmp581_data *drv = (struct bmp581_data *)dev->data; in set_odr_config()
310 struct bmp581_config *conf = (struct bmp581_config *)dev->config; in set_odr_config()
314 ret = i2c_reg_read_byte_dt(&conf->i2c, BMP5_REG_ODR_CONFIG, &odr_val); in set_odr_config()
318 odr_val = BMP5_SET_BITSLICE(odr_val, BMP5_ODR, odr->val1); in set_odr_config()
319 ret = i2c_reg_write_byte_dt(&conf->i2c, BMP5_REG_ODR_CONFIG, odr_val); in set_odr_config()
320 get_osr_odr_press_config(&drv->osr_odr_press_config, dev); in set_odr_config()
327 struct bmp581_config *conf = (struct bmp581_config *)dev->config; in soft_reset()
333 return -EINVAL; in soft_reset()
336 ret = i2c_reg_write_byte_dt(&conf->i2c, BMP5_REG_CMD, reset_cmd); in soft_reset()
345 ret = -EFAULT; in soft_reset()
349 LOG_DBG("Failed perform soft-reset."); in soft_reset()
358 return -EINVAL; in bmp581_sample_fetch()
362 return -ENOTSUP; in bmp581_sample_fetch()
365 struct bmp581_data *drv = (struct bmp581_data *)dev->data; in bmp581_sample_fetch()
366 struct bmp581_config *conf = (struct bmp581_config *)dev->config; in bmp581_sample_fetch()
370 ret = i2c_burst_read_dt(&conf->i2c, BMP5_REG_TEMP_DATA_XLSB, data, 6); in bmp581_sample_fetch()
372 /* convert raw sensor data to sensor_value. Shift the decimal part by 1 decimal in bmp581_sample_fetch()
375 drv->last_sample.temperature.val1 = data[2]; in bmp581_sample_fetch()
376 drv->last_sample.temperature.val2 = (data[1] << 8 | data[0]) * 10; in bmp581_sample_fetch()
378 if (drv->osr_odr_press_config.press_en == BMP5_ENABLE) { in bmp581_sample_fetch()
381 /* convert raw sensor data to sensor_value. Shift the decimal part by in bmp581_sample_fetch()
385 drv->last_sample.pressure.val1 = raw_pressure >> 6; in bmp581_sample_fetch()
386 drv->last_sample.pressure.val2 = (raw_pressure & BIT_MASK(6)) * 10000; in bmp581_sample_fetch()
388 drv->last_sample.pressure.val1 = 0; in bmp581_sample_fetch()
389 drv->last_sample.pressure.val2 = 0; in bmp581_sample_fetch()
400 return -EINVAL; in bmp581_channel_get()
403 struct bmp581_data *drv = (struct bmp581_data *)dev->data; in bmp581_channel_get()
408 *val = drv->last_sample.pressure; in bmp581_channel_get()
412 *val = drv->last_sample.temperature; in bmp581_channel_get()
415 return -ENOTSUP; in bmp581_channel_get()
421 struct bmp581_config *conf = (struct bmp581_config *)dev->config; in set_iir_config()
425 return -EINVAL; in set_iir_config()
442 ret = i2c_burst_read_dt(&conf->i2c, BMP5_REG_DSP_CONFIG, dsp_config, 2); in set_iir_config()
452 dsp_config[1] = iir->val1; in set_iir_config()
453 dsp_config[1] = BMP5_SET_BITSLICE(dsp_config[1], BMP5_SET_IIR_PRESS, iir->val2); in set_iir_config()
456 ret = i2c_burst_write_dt(&conf->i2c, BMP5_REG_DSP_CONFIG, dsp_config, 2); in set_iir_config()
475 return -EINVAL; in bmp581_attr_set()
488 enum bmp5_powermode powermode = (enum bmp5_powermode)val->val1; in bmp581_attr_set()
497 ret = -ENOTSUP; in bmp581_attr_set()
506 return -EINVAL; in bmp581_init()
509 struct bmp581_data *drv = (struct bmp581_data *)dev->data; in bmp581_init()
510 struct bmp581_config *conf = (struct bmp581_config *)dev->config; in bmp581_init()
511 int ret = -1; in bmp581_init()
514 drv->chip_id = 0; in bmp581_init()
515 memset(&drv->osr_odr_press_config, 0, sizeof(drv->osr_odr_press_config)); in bmp581_init()
516 memset(&drv->last_sample, 0, sizeof(drv->last_sample)); in bmp581_init()
520 ret = i2c_reg_read_byte_dt(&conf->i2c, BMP5_REG_CHIP_ID, &drv->chip_id); in bmp581_init()
525 if (drv->chip_id != 0) { in bmp581_init()
531 drv->chip_id, BMP5_CHIP_ID_PRIM, BMP5_CHIP_ID_SEC); in bmp581_init()
536 LOG_ERR("Unexpected chip id (%x). Expected (%x or %x)", drv->chip_id, in bmp581_init()
538 return -EINVAL; in bmp581_init()