Lines Matching +full:proximity +full:- +full:pulse +full:- +full:count
5 *SPDX-License-Identifier: Apache-2.0
11 * @brief driver for APDS9960 ALS/RGB/gesture/proximity sensor
31 apds9960_setup_int(drv_data->dev->config, false); in apds9960_handle_cb()
34 k_work_submit(&drv_data->work); in apds9960_handle_cb()
36 k_sem_give(&drv_data->data_sem); in apds9960_handle_cb()
52 const struct apds9960_config *config = dev->config; in apds9960_sample_fetch()
53 struct apds9960_data *data = dev->data; in apds9960_sample_fetch()
58 return -ENOTSUP; in apds9960_sample_fetch()
69 if (i2c_reg_update_byte_dt(&config->i2c, in apds9960_sample_fetch()
72 return -EIO; in apds9960_sample_fetch()
75 k_sem_take(&data->data_sem, K_FOREVER); in apds9960_sample_fetch()
78 if (i2c_reg_read_byte_dt(&config->i2c, in apds9960_sample_fetch()
80 return -EIO; in apds9960_sample_fetch()
85 if (i2c_reg_read_byte_dt(&config->i2c, in apds9960_sample_fetch()
86 APDS9960_PDATA_REG, &data->pdata)) { in apds9960_sample_fetch()
87 return -EIO; in apds9960_sample_fetch()
92 if (i2c_burst_read_dt(&config->i2c, in apds9960_sample_fetch()
94 (uint8_t *)&data->sample_crgb, in apds9960_sample_fetch()
95 sizeof(data->sample_crgb))) { in apds9960_sample_fetch()
96 return -EIO; in apds9960_sample_fetch()
102 if (i2c_reg_update_byte_dt(&config->i2c, in apds9960_sample_fetch()
106 return -EIO; in apds9960_sample_fetch()
110 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_sample_fetch()
112 return -EIO; in apds9960_sample_fetch()
122 struct apds9960_data *data = dev->data; in apds9960_channel_get()
127 val->val1 = sys_le16_to_cpu(data->sample_crgb[0]); in apds9960_channel_get()
128 val->val2 = 0; in apds9960_channel_get()
131 val->val1 = sys_le16_to_cpu(data->sample_crgb[1]); in apds9960_channel_get()
132 val->val2 = 0; in apds9960_channel_get()
135 val->val1 = sys_le16_to_cpu(data->sample_crgb[2]); in apds9960_channel_get()
136 val->val2 = 0; in apds9960_channel_get()
139 val->val1 = sys_le16_to_cpu(data->sample_crgb[3]); in apds9960_channel_get()
140 val->val2 = 0; in apds9960_channel_get()
144 val->val1 = data->pdata; in apds9960_channel_get()
145 val->val2 = 0; in apds9960_channel_get()
148 return -ENOTSUP; in apds9960_channel_get()
156 const struct apds9960_config *config = dev->config; in apds9960_proxy_setup()
158 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_proxy_setup()
162 return -EIO; in apds9960_proxy_setup()
165 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_proxy_setup()
169 return -EIO; in apds9960_proxy_setup()
172 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_proxy_setup()
174 config->ppcount)) { in apds9960_proxy_setup()
175 LOG_ERR("Default pulse count not set "); in apds9960_proxy_setup()
176 return -EIO; in apds9960_proxy_setup()
179 if (i2c_reg_update_byte_dt(&config->i2c, in apds9960_proxy_setup()
184 return -EIO; in apds9960_proxy_setup()
187 if (i2c_reg_update_byte_dt(&config->i2c, in apds9960_proxy_setup()
190 config->pled_boost)) { in apds9960_proxy_setup()
192 return -EIO; in apds9960_proxy_setup()
195 if (i2c_reg_update_byte_dt(&config->i2c, in apds9960_proxy_setup()
197 (config->pgain & APDS9960_PGAIN_8X))) { in apds9960_proxy_setup()
199 return -EIO; in apds9960_proxy_setup()
202 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_proxy_setup()
205 return -EIO; in apds9960_proxy_setup()
208 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_proxy_setup()
211 return -EIO; in apds9960_proxy_setup()
214 if (i2c_reg_update_byte_dt(&config->i2c, in apds9960_proxy_setup()
217 LOG_ERR("Proximity mode is not enabled"); in apds9960_proxy_setup()
218 return -EIO; in apds9960_proxy_setup()
227 const struct apds9960_config *config = dev->config; in apds9960_ambient_setup()
231 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_ambient_setup()
234 return -EIO; in apds9960_ambient_setup()
238 if (i2c_reg_update_byte_dt(&config->i2c, in apds9960_ambient_setup()
241 (config->again & APDS9960_AGAIN_64X))) { in apds9960_ambient_setup()
243 return -EIO; in apds9960_ambient_setup()
247 if (i2c_burst_write_dt(&config->i2c, in apds9960_ambient_setup()
251 return -EIO; in apds9960_ambient_setup()
255 if (i2c_burst_write_dt(&config->i2c, in apds9960_ambient_setup()
259 return -EIO; in apds9960_ambient_setup()
263 if (i2c_reg_update_byte_dt(&config->i2c, in apds9960_ambient_setup()
267 return -EIO; in apds9960_ambient_setup()
276 const struct apds9960_config *config = dev->config; in apds9960_sensor_setup()
279 if (i2c_reg_read_byte_dt(&config->i2c, in apds9960_sensor_setup()
282 return -EIO; in apds9960_sensor_setup()
287 return -EIO; in apds9960_sensor_setup()
291 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_sensor_setup()
294 return -EIO; in apds9960_sensor_setup()
297 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_sensor_setup()
299 return -EIO; in apds9960_sensor_setup()
303 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_sensor_setup()
306 return -EIO; in apds9960_sensor_setup()
309 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_sensor_setup()
312 return -EIO; in apds9960_sensor_setup()
315 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_sensor_setup()
319 return -EIO; in apds9960_sensor_setup()
322 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_sensor_setup()
326 return -EIO; in apds9960_sensor_setup()
329 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_sensor_setup()
333 return -EIO; in apds9960_sensor_setup()
336 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_sensor_setup()
340 return -EIO; in apds9960_sensor_setup()
344 LOG_ERR("Failed to setup proximity functionality"); in apds9960_sensor_setup()
345 return -EIO; in apds9960_sensor_setup()
351 return -EIO; in apds9960_sensor_setup()
360 const struct apds9960_config *config = dev->config; in apds9960_init_interrupt()
361 struct apds9960_data *drv_data = dev->data; in apds9960_init_interrupt()
363 if (!gpio_is_ready_dt(&config->int_gpio)) { in apds9960_init_interrupt()
364 LOG_ERR("%s: device %s is not ready", dev->name, in apds9960_init_interrupt()
365 config->int_gpio.port->name); in apds9960_init_interrupt()
366 return -ENODEV; in apds9960_init_interrupt()
369 gpio_pin_configure_dt(&config->int_gpio, GPIO_INPUT | config->int_gpio.dt_flags); in apds9960_init_interrupt()
371 gpio_init_callback(&drv_data->gpio_cb, in apds9960_init_interrupt()
373 BIT(config->int_gpio.pin)); in apds9960_init_interrupt()
375 if (gpio_add_callback(config->int_gpio.port, &drv_data->gpio_cb) < 0) { in apds9960_init_interrupt()
377 return -EIO; in apds9960_init_interrupt()
380 drv_data->dev = dev; in apds9960_init_interrupt()
383 drv_data->work.handler = apds9960_work_cb; in apds9960_init_interrupt()
384 if (i2c_reg_update_byte_dt(&config->i2c, in apds9960_init_interrupt()
389 return -EIO; in apds9960_init_interrupt()
393 k_sem_init(&drv_data->data_sem, 0, K_SEM_MAX_LIMIT); in apds9960_init_interrupt()
397 if (gpio_pin_get_dt(&config->int_gpio) > 0) { in apds9960_init_interrupt()
408 const struct apds9960_config *config = dev->config; in apds9960_pm_action()
413 if (i2c_reg_update_byte_dt(&config->i2c, in apds9960_pm_action()
417 ret = -EIO; in apds9960_pm_action()
421 if (i2c_reg_update_byte_dt(&config->i2c, in apds9960_pm_action()
424 ret = -EIO; in apds9960_pm_action()
427 if (i2c_reg_write_byte_dt(&config->i2c, in apds9960_pm_action()
429 ret = -EIO; in apds9960_pm_action()
433 return -ENOTSUP; in apds9960_pm_action()
442 const struct apds9960_config *config = dev->config; in apds9960_init()
443 struct apds9960_data *data = dev->data; in apds9960_init()
448 if (!device_is_ready(config->i2c.bus)) { in apds9960_init()
450 return -EINVAL; in apds9960_init()
453 (void)memset(data->sample_crgb, 0, sizeof(data->sample_crgb)); in apds9960_init()
454 data->pdata = 0U; in apds9960_init()
458 return -EIO; in apds9960_init()
463 return -EIO; in apds9960_init()
501 (CONFIG_APDS9960_PPULSE_COUNT - 1),
504 (CONFIG_APDS9960_PPULSE_COUNT - 1),
507 (CONFIG_APDS9960_PPULSE_COUNT - 1),
510 (CONFIG_APDS9960_PPULSE_COUNT - 1),