Commit graph

20 commits

Author SHA1 Message Date
Michael Kaplan a818d06cf2 drivers: sensors: apds9960 fix trigger callback context
In the current implementation, the apds9960 trigger callback function
is called with the pointer of a driver-internal allocated trigger
structure. This structure is not initialized anywhere, so essentially
the trigger callback gets called with junk data.

Besides the missing initialization, it would be better instead to hold
a const pointer to a user allocated sensor_trigger object.
This way user code can establish a context with related user data (for
example a pointer to a C++ object) by storing its sensor_trigger object
within a structure alongside the user data, and then using
CONTAINER_OF() macro to get the pointer of the container struct (and
thus the user data).

Signed-off-by: Michael Kaplan <m.kaplan@evva.com>
2023-03-15 22:39:45 +00:00
Kumar Gala 7a9a5f525f drivers: sensor: apds9960: Update driver to use gpio_dt_spec
Move driver to use gpio_dt_spec for GPIO interrupt handling.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-16 10:51:42 -05:00
Kumar Gala cf947c5b13 drivers: sensor: apds9960: Update driver to use i2c_dt_spec
Move driver to use i2c_dt_spec for I2C bus access.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-16 10:51:42 -05:00
Gerard Marull-Paretas fb60aab245 drivers: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all drivers to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 19:58:21 +02:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Johann Fischer 2a117748f6 drivers: apds9960: convert to new GPIO API
Convert APDS9960 sensor driver to new GPIO API.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2020-02-05 12:00:36 +01:00
Anas Nashif 6aa9c3a68f cleanup: include/: move gpio.h to drivers/gpio.h
move gpio.h to drivers/gpio.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Johann Fischer 2204193bdb drivers: apds9960: allow additional LED current configuration
Allow additional proximity LED current configuration.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-06-05 07:48:58 -05:00
Johann Fischer df3796a724 drivers: apds9960: make proximity pulse length configurable
Make proximity pulse length and pulse count configurable.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-06-05 07:48:58 -05:00
Johann Fischer 67ae508459 drivers: apds9960: make ALS and proximity gain configurable
Make ALS and proximity gain configurable.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-06-05 07:48:58 -05:00
Maureen Helm 0cff42fe9d drivers: sensor: Refactor apds9960 to use const config struct
Refactors the apds9960 sensor driver to get the i2c device name, i2c
device address, gpio device name, and gpio pin from a constant device
configuration structure, rather than using hardcoded macros. This will
make it easier to change the names of the macros and to instantiate
multiple instances of the driver.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-03-15 10:30:53 -05:00
Johann Fischer 70776028f5 drivers: apds9960: fix ALS in non-trigger mode
Generate interrupt on every ALS cycle in non-trigger mode
and enable ALS saturation interrupt.

resolves: #11989

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-02-13 22:10:21 -06:00
Punit Vara e5620a2b87 drivers: sensor: Migrate to new logger
Move all sensor drivers and samples to new logging system.

Signed-off-by: Punit Vara <punit.vara@intel.com>
2018-10-16 08:49:53 -04:00
Johann Fischer b192b2b575 drivers: apds9960: add trigger mode for proximity
Add trigger mode for proximity

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-09-21 09:02:00 -05:00
Johann Fischer 963f97d035 drivers: apds9960: use interrupt output for sample
This patch changes the behavior of the sensor. The sensor
will remain in sleep mode after initialization and will only
run the measurements once when sample_fetch is called.
This optimizes the power consumption of the sensor as it
stays in sleep mode most of the time.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-09-21 09:02:00 -05:00
Johann Fischer 9c3d77380a driver: apds9960: reorganize ALS and proximity setups
Refactor and reorganize ALS and proximity setup functions.
Cleanup and reorder register, fix register fields.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-09-21 09:02:00 -05:00
Johann Fischer 163629c96a drivers: apds9960: use i2c_burst_read to fetch ALS data
Use i2c_burst_read to fetch ALS data.
Use unsigned values for ALS and proximity data.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-09-21 09:02:00 -05:00
Flavio Ceolin 67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Punit Vara f60fc94abd drivers: Add apds9960 sensor in polling mode
This patch implements following functionality in polling mode.

Ambient light
RGB light
proximity sensor

Following datasheet has been used to develop driver
https://docs.broadcom.com/docs/AV02-4191EN

Jira: ZEP-1552

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-08-03 15:29:35 -05:00