Lines Matching +full:i2c +full:- +full:errors
2 * Author: Daniel Kampert <DanielKampert@kampis-Elektroecke.de>
7 #include <zephyr/drivers/i2c.h>
53 struct i2c_dt_spec i2c; member
86 const struct apds9306_config *config = dev->config; in apds9306_enable()
88 return i2c_reg_update_byte_dt(&config->i2c, APDS9306_REGISTER_MAIN_CTRL, in apds9306_enable()
94 const struct apds9306_config *config = dev->config; in apds9306_standby()
96 return i2c_reg_update_byte_dt(&config->i2c, APDS9306_REGISTER_MAIN_CTRL, in apds9306_standby()
107 struct apds9306_data *data = item->dev->data; in apds9306_worker()
108 const struct apds9306_config *config = item->dev->config; in apds9306_worker()
110 if (i2c_reg_read_byte_dt(&config->i2c, APDS9306_REGISTER_MAIN_STATUS, &buffer[0])) { in apds9306_worker()
120 if (apds9306_standby(item->dev) != 0) { in apds9306_worker()
126 if (i2c_write_read_dt(&config->i2c, ®, sizeof(reg), &buffer, sizeof(buffer)) < 0) { in apds9306_worker()
130 data->light = sys_get_le24(buffer); in apds9306_worker()
132 LOG_DBG("Last measurement: %u", data->light); in apds9306_worker()
141 const struct apds9306_config *config = dev->config; in apds9306_attr_set()
144 return -ENOTSUP; in apds9306_attr_set()
150 temp = FIELD_PREP(0x07, value->val1); in apds9306_attr_set()
154 temp = FIELD_PREP(0x07, value->val1); in apds9306_attr_set()
158 temp = FIELD_PREP(0x07, value->val1) << 0x04; in apds9306_attr_set()
160 return -ENOTSUP; in apds9306_attr_set()
163 if (i2c_reg_update_byte_dt(&config->i2c, reg, mask, temp)) { in apds9306_attr_set()
165 return -EFAULT; in apds9306_attr_set()
177 const struct apds9306_config *config = dev->config; in apds9306_attr_get()
180 return -ENOTSUP; in apds9306_attr_get()
193 return -ENOTSUP; in apds9306_attr_get()
196 if (i2c_reg_read_byte_dt(&config->i2c, reg, &temp)) { in apds9306_attr_get()
198 return -EFAULT; in apds9306_attr_get()
201 value->val1 = (temp >> mask) & 0x07; in apds9306_attr_get()
202 value->val2 = 0; in apds9306_attr_get()
212 const struct apds9306_config *config = dev->config; in apds9306_sample_fetch()
215 return -ENOTSUP; in apds9306_sample_fetch()
221 return -EFAULT; in apds9306_sample_fetch()
225 if (i2c_reg_read_byte_dt(&config->i2c, APDS9306_REGISTER_ALS_MEAS_RATE, &buffer)) { in apds9306_sample_fetch()
227 return -EFAULT; in apds9306_sample_fetch()
253 struct apds9306_data *data = dev->data; in apds9306_channel_get()
256 return -ENOTSUP; in apds9306_channel_get()
259 value->val1 = data->light; in apds9306_channel_get()
260 value->val2 = 0; in apds9306_channel_get()
269 const struct apds9306_config *config = dev->config; in apds9306_sensor_setup()
274 if (i2c_reg_read_byte_dt(&config->i2c, APDS9306_REGISTER_MAIN_STATUS, &temp)) { in apds9306_sensor_setup()
276 return -EFAULT; in apds9306_sensor_setup()
280 if ((k_uptime_get_32() - now) > 100) { in apds9306_sensor_setup()
282 return -EFAULT; in apds9306_sensor_setup()
288 if (i2c_reg_read_byte_dt(&config->i2c, APDS9306_REGISTER_PART_ID, &temp)) { in apds9306_sensor_setup()
290 return -EFAULT; in apds9306_sensor_setup()
295 return -EFAULT; in apds9306_sensor_setup()
299 LOG_DBG("APDS-9306 found!"); in apds9306_sensor_setup()
301 LOG_DBG("APDS-9306-065 found!"); in apds9306_sensor_setup()
305 if (i2c_reg_write_byte_dt(&config->i2c, APDS9306_REGISTER_MAIN_CTRL, in apds9306_sensor_setup()
308 return -EFAULT; in apds9306_sensor_setup()
312 /* Perform a dummy read to avoid bus errors after the reset. See */ in apds9306_sensor_setup()
313 /* https://lore.kernel.org/lkml/ab1d9746-4d23-efcc-0ee1-d2b8c634becd@tweaklogic.com/ */ in apds9306_sensor_setup()
314 if (i2c_reg_read_byte_dt(&config->i2c, APDS9306_REGISTER_PART_ID, &temp)) { in apds9306_sensor_setup()
316 return -EFAULT; in apds9306_sensor_setup()
325 const struct apds9306_config *config = dev->config; in apds9306_init()
329 if (!i2c_is_ready_dt(&config->i2c)) { in apds9306_init()
331 return -EINVAL; in apds9306_init()
336 return -EFAULT; in apds9306_init()
339 value = ((config->resolution & 0x07) << 4) | (config->frequency & 0x0F); in apds9306_init()
342 if (i2c_reg_write_byte_dt(&config->i2c, APDS9306_REGISTER_ALS_MEAS_RATE, value)) { in apds9306_init()
343 return -EFAULT; in apds9306_init()
346 value = config->gain; in apds9306_init()
348 if (i2c_reg_write_byte_dt(&config->i2c, APDS9306_REGISTER_ALS_GAIN, value)) { in apds9306_init()
349 return -EFAULT; in apds9306_init()
367 .i2c = I2C_DT_SPEC_INST_GET(inst), \