Lines Matching +full:calib +full:- +full:offset

4  * SPDX-License-Identifier: Apache-2.0
33 const struct scd4x_config *cfg = dev->config; in scd4x_write_command()
39 ret = i2c_write_dt(&cfg->bus, tx_buf, sizeof(tx_buf)); in scd4x_write_command()
50 const struct scd4x_config *cfg = dev->config; in scd4x_read_reg()
53 ret = i2c_read_dt(&cfg->bus, rx_buf, rx_buf_size); in scd4x_read_reg()
63 return -EIO; in scd4x_read_reg()
72 const struct scd4x_config *cfg = dev->config; in scd4x_write_reg()
86 ret = i2c_write_dt(&cfg->bus, tx_buf, sizeof(tx_buf)); in scd4x_write_reg()
117 /* Least significant 11 bits = 0 --> data not ready */ in scd4x_data_ready()
127 struct scd4x_data *data = dev->data; in scd4x_read_sample()
143 data->co2_sample = sys_get_be16(rx_data); in scd4x_read_sample()
144 data->temp_sample = sys_get_be16(&rx_data[3]); in scd4x_read_sample()
145 data->humi_sample = sys_get_be16(&rx_data[6]); in scd4x_read_sample()
152 const struct scd4x_config *cfg = dev->config; in scd4x_setup_measurement()
155 switch ((enum scd4x_mode_t)cfg->mode) { in scd4x_setup_measurement()
178 return -EINVAL; in scd4x_setup_measurement()
185 const struct scd4x_config *cfg = dev->config; in scd4x_set_idle_mode()
188 if (cfg->mode == SCD4X_MODE_SINGLE_SHOT) { in scd4x_set_idle_mode()
212 (float)(val->val1 + (val->val2 / 1000000.0)) * 0xFFFF / SCD4X_MAX_TEMP; in scd4x_set_temperature_offset()
226 uint16_t altitude = val->val1; in scd4x_set_sensor_altitude()
240 uint16_t ambient_pressure = val->val1; in scd4x_set_ambient_pressure()
255 uint16_t automatic_calib_enable = val->val1; in scd4x_set_automatic_calib_enable()
271 uint16_t initial_period = val->val1; in scd4x_set_self_calib_initial_period()
286 uint16_t standard_period = val->val1; in scd4x_set_self_calib_standard_period()
318 val->val1 = (int32_t)(temp / 0xFFFF); in scd4x_get_temperature_offset()
319 val->val2 = ((temp % 0xFFFF) * 1000000) / 0xFFFF; in scd4x_get_temperature_offset()
341 val->val1 = sys_get_be16(rx_buf); in scd4x_get_sensor_altitude()
342 val->val2 = 0; in scd4x_get_sensor_altitude()
364 val->val1 = sys_get_be16(rx_buf); in scd4x_get_ambient_pressure()
365 val->val2 = 0; in scd4x_get_ambient_pressure()
387 val->val1 = sys_get_be16(rx_buf); in scd4x_get_automatic_calib_enable()
388 val->val2 = 0; in scd4x_get_automatic_calib_enable()
410 val->val1 = sys_get_be16(rx_buf); in scd4x_get_self_calib_initial_period()
411 val->val2 = 0; in scd4x_get_self_calib_initial_period()
433 val->val1 = sys_get_be16(rx_buf); in scd4x_get_self_calib_standard_period()
434 val->val2 = 0; in scd4x_get_self_calib_standard_period()
468 return -EIO; in scd4x_forced_recalibration()
471 *frc_correction -= 0x8000; in scd4x_forced_recalibration()
509 return -EIO; in scd4x_self_test()
573 const struct scd4x_config *cfg = dev->config; in scd4x_sample_fetch()
579 return -ENOTSUP; in scd4x_sample_fetch()
582 if (cfg->mode == SCD4X_MODE_SINGLE_SHOT) { in scd4x_sample_fetch()
619 if (cfg->mode == SCD4X_MODE_SINGLE_SHOT) { in scd4x_sample_fetch()
632 const struct scd4x_data *data = dev->data; in scd4x_channel_get()
638 tmp_val = data->temp_sample * SCD4X_MAX_TEMP; in scd4x_channel_get()
639 val->val1 = (int32_t)(tmp_val / 0xFFFF) + SCD4X_MIN_TEMP; in scd4x_channel_get()
640 val->val2 = ((tmp_val % 0xFFFF) * 1000000) / 0xFFFF; in scd4x_channel_get()
644 tmp_val = data->humi_sample * 100; in scd4x_channel_get()
645 val->val1 = (int32_t)(tmp_val / 0xFFFF); in scd4x_channel_get()
646 val->val2 = ((tmp_val % 0xFFFF) * 1000000) / 0xFFFF; in scd4x_channel_get()
649 val->val1 = data->co2_sample; in scd4x_channel_get()
650 val->val2 = 0; in scd4x_channel_get()
653 return -ENOTSUP; in scd4x_channel_get()
661 const struct scd4x_config *cfg = dev->config; in scd4x_attr_set()
666 return -ENOTSUP; in scd4x_attr_set()
677 if (val->val1 < 0 || val->val2 < 0) { in scd4x_attr_set()
678 return -EINVAL; in scd4x_attr_set()
683 if (val->val1 > SCD4X_TEMPERATURE_OFFSET_IDX_MAX) { in scd4x_attr_set()
684 return -EINVAL; in scd4x_attr_set()
688 LOG_ERR("Failed to set temperature offset."); in scd4x_attr_set()
693 if (val->val1 > SCD4X_SENSOR_ALTITUDE_IDX_MAX) { in scd4x_attr_set()
694 return -EINVAL; in scd4x_attr_set()
703 if (val->val1 > SCD4X_AMBIENT_PRESSURE_IDX_MAX || val->val1 < 700) { in scd4x_attr_set()
704 return -EINVAL; in scd4x_attr_set()
714 if (val->val1 > SCD4X_BOOL_IDX_MAX) { in scd4x_attr_set()
715 return -EINVAL; in scd4x_attr_set()
719 LOG_ERR("Failed to set automatic calib enable."); in scd4x_attr_set()
724 if (val->val1 % 4) { in scd4x_attr_set()
725 return -EINVAL; in scd4x_attr_set()
727 if (cfg->model == SCD4X_MODEL_SCD40) { in scd4x_attr_set()
729 return -ENOTSUP; in scd4x_attr_set()
733 LOG_ERR("Failed to set self calib initial period."); in scd4x_attr_set()
738 if (val->val1 % 4) { in scd4x_attr_set()
739 return -EINVAL; in scd4x_attr_set()
741 if (cfg->model == SCD4X_MODEL_SCD40) { in scd4x_attr_set()
743 return -ENOTSUP; in scd4x_attr_set()
747 LOG_ERR("Failed to set self calib standard period."); in scd4x_attr_set()
752 return -ENOTSUP; in scd4x_attr_set()
767 const struct scd4x_config *cfg = dev->config; in scd4x_attr_get()
772 return -ENOTSUP; in scd4x_attr_get()
776 cfg->mode == SCD4X_MODE_SINGLE_SHOT) { in scd4x_attr_get()
788 LOG_ERR("Failed to get temperature offset."); in scd4x_attr_get()
810 LOG_ERR("Failed to get automatic calib."); in scd4x_attr_get()
815 if (cfg->model == SCD4X_MODEL_SCD40) { in scd4x_attr_get()
817 return -ENOTSUP; in scd4x_attr_get()
821 LOG_ERR("Failed to set get self calib initial period."); in scd4x_attr_get()
826 if (cfg->model == SCD4X_MODEL_SCD40) { in scd4x_attr_get()
828 return -ENOTSUP; in scd4x_attr_get()
832 LOG_ERR("Failed to set get self calib standard period."); in scd4x_attr_get()
837 return -ENOTSUP; in scd4x_attr_get()
851 const struct scd4x_config *cfg = dev->config; in scd4x_init()
854 if (!i2c_is_ready_dt(&cfg->bus)) { in scd4x_init()
856 return -ENODEV; in scd4x_init()