Lines Matching +full:channel0 +full:- +full:gain

4  * SPDX-License-Identifier: Apache-2.0
92 uint8_t gain; member
104 const struct tsl2561_config *config = dev->config; in tsl2561_reg_read()
107 ret = i2c_write_read_dt(&config->i2c, &cmd, 1U, buf, size); in tsl2561_reg_read()
119 const struct tsl2561_config *config = dev->config; in tsl2561_reg_write()
125 ret = i2c_write_dt(&config->i2c, buf, 2U); in tsl2561_reg_write()
136 const struct tsl2561_config *config = dev->config; in tsl2561_sample_fetch()
137 struct tsl2561_data *data = dev->data; in tsl2561_sample_fetch()
143 return -ENOTSUP; in tsl2561_sample_fetch()
155 k_msleep(config->integration_time); in tsl2561_sample_fetch()
160 LOG_ERR("Failed reading channel0 data"); in tsl2561_sample_fetch()
163 data->ch0 = bytes[1] << 8 | bytes[0]; in tsl2561_sample_fetch()
170 data->ch1 = bytes[1] << 8 | bytes[0]; in tsl2561_sample_fetch()
178 LOG_DBG("channel0: 0x%x; channel1: 0x%x", data->ch0, data->ch1); in tsl2561_sample_fetch()
186 struct tsl2561_data *data = dev->data; in tsl2561_channel_get()
187 uint32_t channel0; in tsl2561_channel_get() local
191 return -ENOTSUP; in tsl2561_channel_get()
194 channel0 = (data->ch0 * data->ch_scale) >> TSL2561_CH_SCALE; in tsl2561_channel_get()
195 channel1 = (data->ch1 * data->ch_scale) >> TSL2561_CH_SCALE; in tsl2561_channel_get()
199 if (channel0 != 0) { in tsl2561_channel_get()
200 ratio1 = (channel1 << (TSL2561_RATIO_SCALE + 1)) / channel0; in tsl2561_channel_get()
235 int32_t tmp = ((channel0 * b) - (channel1 * m)); in tsl2561_channel_get()
238 tmp += (1 << (TSL2561_LUX_SCALE - 1)); in tsl2561_channel_get()
241 val->val1 = tmp >> TSL2561_LUX_SCALE; in tsl2561_channel_get()
243 val->val2 = 0; in tsl2561_channel_get()
255 const struct tsl2561_config *config = dev->config; in tsl2561_sensor_setup()
256 struct tsl2561_data *data = dev->data; in tsl2561_sensor_setup()
269 LOG_ERR("Chip ID is invalid! Device @%02x is not TSL2561!", config->i2c.addr); in tsl2561_sensor_setup()
270 return -EIO; in tsl2561_sensor_setup()
273 switch (config->integration_time) { in tsl2561_sensor_setup()
276 data->ch_scale = TSL2561_CHSCALE_TINT0; in tsl2561_sensor_setup()
280 data->ch_scale = TSL2561_CHSCALE_TINT1; in tsl2561_sensor_setup()
284 data->ch_scale = (1 << TSL2561_CH_SCALE); in tsl2561_sensor_setup()
288 return -EINVAL; in tsl2561_sensor_setup()
293 switch (config->gain) { in tsl2561_sensor_setup()
296 data->ch_scale = data->ch_scale << 4; in tsl2561_sensor_setup()
302 LOG_ERR("Invalid ADC gain"); in tsl2561_sensor_setup()
303 return -EINVAL; in tsl2561_sensor_setup()
319 const struct tsl2561_config *config = dev->config; in tsl2561_init()
322 if (!i2c_is_ready_dt(&config->i2c)) { in tsl2561_init()
323 LOG_ERR("I2C dev %s not ready", config->i2c.bus->name); in tsl2561_init()
324 return -ENODEV; in tsl2561_init()
341 .gain = DT_INST_PROP(n, gain)}; \