Lines Matching +full:crc +full:- +full:enabled

4  * SPDX-License-Identifier: Apache-2.0
15 #include <zephyr/sys/crc.h>
37 * CRC algorithm parameters were taken from the
48 /* val = -45 + 175 * sample / (2^16) */
53 tmp = (int32_t)raw * 175U - (45 << 16); in shtcx_temperature_from_raw()
54 val->val1 = tmp / 0x10000; in shtcx_temperature_from_raw()
56 val->val2 = ((tmp % 0x10000) * 15625) / 1024; in shtcx_temperature_from_raw()
65 val->val1 = tmp / 0x10000; in shtcx_humidity_from_raw()
67 val->val2 = (tmp % 0x10000) * 15625U / 1024; in shtcx_humidity_from_raw()
72 const struct shtcx_config *cfg = dev->config; in shtcx_write_command()
76 return i2c_write_dt(&cfg->i2c, tx_buf, sizeof(tx_buf)); in shtcx_write_command()
82 const struct shtcx_config *cfg = dev->config; in shtcx_read_words()
92 return -EIO; in shtcx_read_words()
95 if (!cfg->clock_stretching) { in shtcx_read_words()
99 status = i2c_read_dt(&cfg->i2c, rx_buf, raw_len); in shtcx_read_words()
102 return -EIO; in shtcx_read_words()
108 LOG_DBG("invalid received invalid crc"); in shtcx_read_words()
109 return -EIO; in shtcx_read_words()
121 return -EIO; in shtcx_sleep()
130 return -EIO; in shtcx_wakeup()
140 struct shtcx_data *data = dev->data; in shtcx_sample_fetch()
141 const struct shtcx_config *cfg = dev->config; in shtcx_sample_fetch()
145 if (cfg->chip == SHTC3) { in shtcx_sample_fetch()
147 return -EIO; in shtcx_sample_fetch()
152 measure_cmd[cfg->measure_mode][cfg->clock_stretching], in shtcx_sample_fetch()
153 (uint16_t *)&data->sample, 2, in shtcx_sample_fetch()
154 measure_wait_us[cfg->chip][cfg->measure_mode]) < 0) { in shtcx_sample_fetch()
156 return -EIO; in shtcx_sample_fetch()
159 if (cfg->chip == SHTC3) { in shtcx_sample_fetch()
162 return -EIO; in shtcx_sample_fetch()
173 const struct shtcx_data *data = dev->data; in shtcx_channel_get()
176 shtcx_temperature_from_raw(data->sample.temp, val); in shtcx_channel_get()
178 shtcx_humidity_from_raw(data->sample.humidity, val); in shtcx_channel_get()
180 return -ENOTSUP; in shtcx_channel_get()
193 const struct shtcx_config *cfg = dev->config; in shtcx_init()
196 if (!device_is_ready(cfg->i2c.bus)) { in shtcx_init()
198 return -ENODEV; in shtcx_init()
202 if (cfg->chip == SHTC3) { in shtcx_init()
205 return -EIO; in shtcx_init()
211 return -EIO; in shtcx_init()
217 return -EIO; in shtcx_init()
220 if (cfg->chip == SHTC1) { in shtcx_init()
223 return -EINVAL; in shtcx_init()
226 if (cfg->chip == SHTC3) { in shtcx_init()
229 return -EINVAL; in shtcx_init()
234 LOG_DBG("Clock-stretching enabled: %d", cfg->clock_stretching); in shtcx_init()
235 LOG_DBG("Measurement mode: %d", cfg->measure_mode); in shtcx_init()