Lines Matching +full:reset +full:- +full:val

4  * SPDX-License-Identifier: Apache-2.0
35 * Reset register 0x1B, 0x1C and 0x1E
44 /** Wait some time after reset sequence (in ms) */
72 const struct dht20_config *cfg = dev->config; in read_status()
78 rc = i2c_write_dt(&cfg->bus, tx_buf, sizeof(tx_buf)); in read_status()
84 rc = i2c_read_dt(&cfg->bus, rx_buf, sizeof(rx_buf)); in read_status()
97 const struct dht20_config *cfg = dev->config; in reset_register()
103 rc = i2c_write_read_dt(&cfg->bus, tx_buf, sizeof(tx_buf), rx_buf, sizeof(rx_buf)); in reset_register()
105 LOG_ERR("Failed to reset register."); in reset_register()
113 rc = i2c_write_dt(&cfg->bus, tx_buf, sizeof(tx_buf)); in reset_register()
115 LOG_ERR("Failed to reset register."); in reset_register()
136 * Reset register 0x1B, 0x1C and 0x1E if status does not match expected value in reset_sensor()
150 /* Wait 10ms after reset sequence */ in reset_sensor()
159 const struct dht20_config *cfg = dev->config; in dht20_read_sample()
163 * +------+----------------------------------------+ in dht20_read_sample()
165 * +------+----------------------------------------+ in dht20_read_sample()
173 * +------+----------------------------------------+ in dht20_read_sample()
179 rc = i2c_read_dt(&cfg->bus, rx_buf, sizeof(rx_buf)); in dht20_read_sample()
196 rc = -EIO; in dht20_read_sample()
205 struct dht20_data *data = dev->data; in dht20_sample_fetch()
206 const struct dht20_config *cfg = dev->config; in dht20_sample_fetch()
214 return -ENOTSUP; in dht20_sample_fetch()
217 /* Reset sensor if needed */ in dht20_sample_fetch()
221 rc = i2c_write_dt(&cfg->bus, tx_buf, sizeof(tx_buf)); in dht20_sample_fetch()
243 rc = dht20_read_sample(dev, &data->t_sample, &data->rh_sample); in dht20_sample_fetch()
252 static void dht20_temp_convert(struct sensor_value *val, uint32_t raw) in dht20_temp_convert() argument
258 * DegCT = (S / 2^20) * 200 - 50 in dht20_temp_convert()
259 * uDegCT = (S * 1e6 * 200 - 50 * 1e6) / (1 << 20) in dht20_temp_convert()
261 micro_c = ((int64_t)raw * 1000000 * 200) / BIT(20) - 50 * 1000000; in dht20_temp_convert()
263 val->val1 = micro_c / 1000000; in dht20_temp_convert()
264 val->val2 = micro_c % 1000000; in dht20_temp_convert()
267 static void dht20_rh_convert(struct sensor_value *val, uint32_t raw) in dht20_rh_convert() argument
278 val->val1 = micro_rh / 1000000; in dht20_rh_convert()
279 val->val2 = micro_rh % 1000000; in dht20_rh_convert()
283 struct sensor_value *val) in dht20_channel_get() argument
285 const struct dht20_data *data = dev->data; in dht20_channel_get()
288 dht20_temp_convert(val, data->t_sample); in dht20_channel_get()
290 dht20_rh_convert(val, data->rh_sample); in dht20_channel_get()
292 return -ENOTSUP; in dht20_channel_get()
300 const struct dht20_config *cfg = dev->config; in dht20_init()
302 if (!i2c_is_ready_dt(&cfg->bus)) { in dht20_init()
303 LOG_ERR("I2C dev %s not ready", cfg->bus.bus->name); in dht20_init()
304 return -ENODEV; in dht20_init()