Lines Matching refs:i2c
22 static uint8_t read8(const struct i2c_dt_spec *i2c, uint8_t d) in read8() argument
26 if (i2c_reg_read_byte_dt(i2c, d, &buf) < 0) { in read8()
32 static int is_ready(const struct i2c_dt_spec *i2c) in is_ready() argument
37 if (i2c_reg_read_byte_dt(i2c, TH02_REG_STATUS, &status) < 0) { in is_ready()
48 static uint16_t get_humi(const struct i2c_dt_spec *i2c) in get_humi() argument
52 if (i2c_reg_write_byte_dt(i2c, TH02_REG_CONFIG, TH02_CMD_MEASURE_HUMI) < 0) { in get_humi()
56 while (!is_ready(i2c)) { in get_humi()
59 humidity = read8(i2c, TH02_REG_DATA_H) << 8; in get_humi()
60 humidity |= read8(i2c, TH02_REG_DATA_L); in get_humi()
66 uint16_t get_temp(const struct i2c_dt_spec *i2c) in get_temp() argument
70 if (i2c_reg_write_byte_dt(i2c, TH02_REG_CONFIG, TH02_CMD_MEASURE_TEMP) < 0) { in get_temp()
74 while (!is_ready(i2c)) { in get_temp()
77 temperature = read8(i2c, TH02_REG_DATA_H) << 8; in get_temp()
78 temperature |= read8(i2c, TH02_REG_DATA_L); in get_temp()
92 drv_data->t_sample = get_temp(&cfg->i2c); in th02_sample_fetch()
94 drv_data->rh_sample = get_humi(&cfg->i2c); in th02_sample_fetch()
133 if (!device_is_ready(cfg->i2c.bus)) { in th02_init()
145 .i2c = I2C_DT_SPEC_INST_GET(inst), \