Commit graph

1951 commits

Author SHA1 Message Date
Maximilian Deubel d8e0dd1804 ADXL372: add names for KConfig choices
This patch adds names to the KConfig choices of the ADXL372 driver.

Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
2022-07-25 09:33:54 +00:00
Kumar Gala f0441fba58 drivers: sensor: Update drivers to use devicetree Kconfig symbol
Update sensor drivers to use DT_HAS_<compat>_ENABLED Kconfig symbol
to expose the driver and enable it by default based on devicetree.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-22 02:20:18 -05:00
Pieter De Gendt d01934f9e9 drivers: sensor: bq274xx: convert lazy load Kconfig option to dts property
This change allows per-instance configuration of lazy loading and
fixes build issue.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-07-20 08:39:45 -05:00
Kumar Gala d77389464b drivers: sensor: shell_battery: Convert to DEVICE_DT_GET
Move to using DEVICE_DT_GET so we can phase out DT_LABEL.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-19 08:45:13 -05:00
Benjamin Björnsson 6098e1894b drivers: sensor: ms5607: Update driver to use spi_dt_spec
Simplify driver by using spi_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-19 12:28:29 +00:00
Benjamin Björnsson e6f9ef4cc7 drivers: sensor: ms5607: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-19 12:28:29 +00:00
Tomislav Milkovic 0fe2c1fe90 everywhere: Fix legacy include paths
Any project with Kconfig option CONFIG_LEGACY_INCLUDE_PATH set to n
couldn't be built because some files were missing zephyr/ prefix in
includes
Re-run the migrate_includes.py script to fix all legacy include paths

Signed-off-by: Tomislav Milkovic <milkovic@byte-lab.com>
2022-07-18 16:16:47 +00:00
Benjamin Björnsson 0649679b98 drivers: sensor: bmp388: Rename spi variable
Rename variable for consistency across drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-18 10:24:35 -05:00
Benjamin Björnsson b6c8148e7e drivers: sensor: bmp389: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-18 10:24:35 -05:00
Andrew McRae 008859a6ba drivers: sensor: npcx_tach: Remove underflow LOG_INF
A LOG_DBG already exists for the underflow check,
and given that reading 0 edges is a valid case, remove
the noisy underflow log.

Signed-off-by: Andrew McRae <amcrae@google.com>
2022-07-18 09:11:04 -05:00
TOKITA Hiroshi 189c8a82d4 drivers: sensor: adxl345: Add support SPI connection
Support SPI connection for ADXL345.
It works as well as an I2C connection.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2022-07-18 10:37:14 +00:00
Benjamin Björnsson 704e366fcf drivers: sensor: iis2mdc: Move bus union inside device config
Simplify driver by moving auxiliary bus union inside device config.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-15 15:35:54 +02:00
Benjamin Björnsson bbff6eb592 drivers: sensor: iis2mdc: move driver to use i2c_dt_spec and spi_dt_spec
Simplify driver by using i2c_dt_spec and spi_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-15 15:35:54 +02:00
Benjamin Björnsson 2259c6771f drivers: sensor: fxas21002: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-14 10:39:40 +02:00
Benjamin Björnsson 05a6c0fe68 drivers: sensor: stm32_temp: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-13 19:06:41 +02:00
Benjamin Björnsson 597be4d4f7 drivers: sensor: ak8975: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-13 15:53:26 +02:00
Benjamin Björnsson 9ed194a00b drivers: sensor: ak8975: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-13 05:39:37 -05:00
Kumar Gala 1eeae77621 sensors: ak8975: remove passthrough support for MPU9150
Remove the support for enabling passthrough mode support for MPU9150
on the AK8975.  We don't have a proper MPU9150 driver and the MPU9150
has been EOL.  So its highly unlikely this code is being used.

Additonally we remove the device tree binding for the MPU9150 since
we don't have a proper driver for it.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-12 17:57:18 -05:00
Benjamin Björnsson 6c82570f62 drivers: sensor: ccs811: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-12 12:28:53 +02:00
Benjamin Björnsson bf4b30e848 drivers: sensor: iis3dhhc: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-12 10:56:15 +02:00
Benjamin Björnsson 0364f3ae4d drivers: sensor: ti_hdc: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-12 10:18:29 +02:00
Maximilian Deubel 3d2b04c9a8 ADXL362: add dynamic inact time setting
This patch extends the adxl362 driver by adding an option
to change the inactivity detection timeout at runtime.

Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
2022-07-11 18:19:45 +00:00
Kiril Petrov 44f651d315 drivers: nordic_nrf_temp: nrfx: Fix build warning into temp_nrf5_init
Building lwm2m_client with CONFIG_NET_L2_OPENTHREAD=y leads to
following warning during build:

west build -s samples/net/lwm2m_client -b nrf52840dk_nrf52840 -- \
				-DCONFIG_NET_L2_OPENTHREAD=y

zephyr/drivers/sensor/nrf5/temp_nrf5.c:115:10:
warning: zero-length gnu_printf format string [-Wformat-zero-length]
115 |  LOG_DBG("");

Signed-off-by: Kiril Petrov <retfie@gmail.com>
2022-07-11 17:57:12 +02:00
Benjamin Björnsson 78af3f39ec drivers: sensor: ism330dhcx: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-08 10:57:18 +02:00
Benjamin Björnsson e0cc66ab6f drivers: sensor: amg88xx: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-07 09:21:34 -05:00
Yann Roth c640392211 typo: fix LSM6DSL_SHIFT_MD2_CFG_INT2_WU
The register MD2_CFG contains INT2_WU and not INT1_WU

Signed-off-by: Yann Roth <yannroth@msn.com>
2022-07-07 10:16:35 +02:00
Benjamin Björnsson 092251017f drivers: sensor: stts751: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 18:00:21 +00:00
Benjamin Björnsson 0ce4d8b2da drivers: sensor: stm32_vbat: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 18:00:02 +00:00
Anas Nashif 49b36ead95 drivers: add mising braces to single line if statements
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-06 11:00:45 -04:00
Benjamin Björnsson 1cd8a0fb34 drivers: sensor: lsm9ds0_gyro: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 09:49:32 -05:00
Benjamin Björnsson ccf9292a52 drivers: sensor: iis2dh: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 09:11:06 -05:00
Benjamin Björnsson 6e62bd070f drivers: sensor: bmg160: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 09:09:38 -05:00
Benjamin Björnsson 2cff424bea drivers: sensor: tmp007: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 09:07:33 -05:00
Aurelien Jarno 869c60e208 drivers: sensor: stm32_vbat: get vref-mv through the ADC API
Get the vref-mv through the ADC API instead of the device tree. This
saves 8 bytes of SRAM and will be future proof in case, one day, support
for a variable vref is added.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2022-07-06 11:10:42 +02:00
Benjamin Björnsson 251755e21d drivers: sensor: iis2dh: Update driver to use gpio_dt_spec
Move driver to use gpio_dt_spec for GPIO interrupt handling.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 10:43:10 +02:00
Benjamin Björnsson 5c9f5a12f4 drivers: sensor: iis2dh: Update driver to use spi_dt_spec and i2c_dt_spec
Move driver to use spi_dt_spec and i2c_dt_spec for SPI and I2C bus
access, respectively.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 10:43:10 +02:00
Benjamin Björnsson 619c0ee17b drivers: sensor: iis2dh: Change parameter list of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 10:43:10 +02:00
Thomas Stranger 3d70711c04 drivers: sensor: add support for ds18b20 1-wire temperatue sensor
This commit adds support for the ds18b20 1-wire temperature sensor.

The sampling resolution of the sensor can be set in DT.
In case only a single device is on the bus, the driver issues
skip_rom commands. However, in case DT defines several devices,
the driver will use match_rom commands and therefore it is necessary
to set the rom_id of the device via the sensor attribute interface before
being able to sample sensor values.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2022-07-05 23:06:45 +02:00
Benjamin Björnsson c2861ffda2 drivers: sensor: th02: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 15:41:10 +00:00
Benjamin Björnsson f5b9635e31 drivers: sensor: adxl345: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 15:39:33 +00:00
Benjamin Björnsson 1d0e5e17d3 drivers: sensor: ams_iAQcode: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 15:39:15 +00:00
Benjamin Björnsson 803fdf6a46 drivers: sensor: vcnl4040: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 09:14:50 -05:00
Benjamin Björnsson b4dffbfb40 drivers: sensor: mcp9808: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 09:10:06 -05:00
Benjamin Björnsson b2b7665b9c drivers: sensor: mpu6050: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 09:08:43 -05:00
Benjamin Björnsson 1409a8f86b drivers: sensor: lis3mdl: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 09:06:13 -05:00
Benjamin Björnsson 131aedc769 drivers: sensor: isl29035: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 09:02:05 -05:00
Benjamin Björnsson 0ab5e7964c drivers: sensor: bmc150_magn: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 08:59:13 -05:00
Benjamin Björnsson 3f42a6a75f drivers: sensor: hmc5883l: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 08:57:59 -05:00
Benjamin Björnsson ff7aa22217 drivers: sensor: adt7420: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 08:53:08 -05:00
Benjamin Björnsson d0a5f5a08d drivers: sensor: adxl362: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 08:51:13 -05:00
Benjamin Björnsson 4e0dbc7c14 drivers: sensor: bma280: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 08:49:07 -05:00
Benjamin Björnsson b552a003b6 drivers: sensor: dps310: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:43:15 +02:00
Benjamin Björnsson acb22c72e7 drivers: sensor: lsm303dlhc_magn: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:42:21 +02:00
Benjamin Björnsson 6f6fba5e73 drivers: sensor: bmm150: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:31:45 +02:00
Benjamin Björnsson d4cf841622 drivers: sensor: dht: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:30:45 +02:00
Benjamin Björnsson 5983d8b762 drivers: sensor: grove: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:28:43 +02:00
Benjamin Björnsson 927633a819 drivers: sensor: hp206c: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:27:40 +02:00
Benjamin Björnsson 21b371f531 drivers: sensor: lps22hb: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:25:57 +02:00
Benjamin Björnsson 33634e4539 drivers: sensor: lps25hb: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:25:33 +02:00
Benjamin Björnsson b48c760e3d drivers: sensor: lsm6ds0: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:24:39 +02:00
Benjamin Björnsson a94db52f55 drivers: sensor: lsm9ds0_mfd: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:24:07 +02:00
Benjamin Björnsson e2690f033e drivers: sensor: max44009: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:23:44 +02:00
Benjamin Björnsson 6d2d34bdad drivers: sensor: mpr: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:22:55 +02:00
Benjamin Björnsson 8d08148c7f drivers: sensor: ms5837: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:22:31 +02:00
Benjamin Björnsson 6746da203b drivers: sensor: nrf5: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:22:17 +02:00
Benjamin Björnsson 82018dfd9c drivers: sensor: opt3001: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:21:34 +02:00
Benjamin Björnsson b568372c73 drivers: sensor: pms7003: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:21:03 +02:00
Benjamin Björnsson 97ca9ce0be drivers: sensor: si7006: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:20:40 +02:00
Benjamin Björnsson 08d86ff251 drivers: sensor: si7055: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:20:25 +02:00
Benjamin Björnsson d116187fd7 drivers: sensor: si7060: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:20:12 +02:00
Benjamin Björnsson 454c7a1916 drivers: sensor: sx9500: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 12:11:09 +02:00
Benjamin Björnsson d96f361175 drivers: sensor: ens210: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-04 14:07:52 +02:00
Kumar Gala e70933d7dc drivers: sensor: sx9500: 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-07-04 09:49:01 +02:00
Kumar Gala 5c93b3d79a drivers: sensor: sx9500: 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-07-04 09:49:01 +02:00
Maureen Helm 7954fab248 drivers: sensor: Use dt_compat_enabled for magnetometer drivers
In preparation for extending samples/sensor/magn_polling to support
additional magnetometer drivers, enable these drivers by default when
the sensor driver class is enabled (CONFIG_SENSOR=y) and a compatible
devicetree node is enabled.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-07-02 06:03:33 -04:00
Maureen Helm b789c11775 drivers: sensor: Change fxos8700 default mode from accel-only to hybrid
The fxos8700 device supports 3 modes: accelerometer-only,
magnetometer-only, or hybrid (accelerometer and magnetometer) modes. The
accelerometer-only mode is register compatible with mma8451q, mma8652fc,
and mma8653fc, which allows the fxos8700 driver to be used with these
devices as well.

Most in-tree boards can use hybrid mode because they have the fxos8700
device, therefore we change the driver default to match the common case.
For the handful of boards that have an mma86xx or mma84xx device, we
override the driver default to accelerometer-only mode. As a result, we
can enable the magn_polling sample application for the fxos8700 driver
without having to add a bunch of board-specific configuration overlays
for hybrid mode.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-07-02 06:03:33 -04:00
Benjamin Björnsson 8f1ba96b7d drivers: sensor: ism330dhcx: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-01 16:35:03 +00:00
Benjamin Björnsson 0fb0f1a937 drivers: sensor: ism330dhcx: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-01 16:35:03 +00:00
Benjamin Björnsson a30a150a71 drivers: sensor: ism330dhcx: Change parameter of functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-01 16:35:03 +00:00
Benjamin Björnsson 7e943fc06e drivers: sensor: ism330dhcx: Remove unused struct
Simplify driver by removing unused struct declaration.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-01 16:35:03 +00:00
Kumar Gala 2c60426639 drivers: sensor: tmp007: 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-07-01 10:20:55 -05:00
Kumar Gala d184190863 drivers: sensor: tmp007: 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-07-01 10:20:55 -05:00
Benjamin Björnsson 9d726c2226 drivers: sensor: stts751: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-01 09:59:28 -05:00
Benjamin Björnsson d32d681882 drivers: sensor: stts751: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-01 09:59:28 -05:00
Benjamin Björnsson a663aa4e2a drivers: sensor: stts751: Change parameter of read/write functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-01 09:59:28 -05:00
Benjamin Björnsson d2aeb94630 drivers: sensor: lis2dh: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-01 09:34:41 -05:00
Aurelien Jarno f00ddfeb76 drivers: sensor: stm32_temp: drop ts-cal-offset property
According to the formulas found in the reference manuals of the SoC
families using the "st,stm32-temp-cal" version of the temperature sensor
(i.e. G0, G4, H7, L0, L1, L4, L5, U5, WB, WL), the temperature is
computed with the following formula:

T = ((TS_CAL2_TEMP - TS_CAL1_TEMP) / (TS_CAL2 - TS_CAL1))
    * (TS_DATA - TS_CAL1) + TS_CAL1_TEMP

What is called ts-cal-offset in the stm32_temp driver is therefore the
same value as TS_CAL1_TEMP1. Use it directly instead of defining another
property.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2022-07-01 11:38:02 +02:00
Aurelien Jarno 52893d5f0f drivers: sensor: stm32_temp: use the ADC reference voltage
The stm32_temp driver defines the ts-voltage-mv property to determine
the reference voltage of the ADC in the temperature computation. However
this information is already available in the device tree at the ADC
level (even with the same default value). Use it through the ADC API
instead of duplicating the information.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2022-07-01 11:38:02 +02:00
Benjamin Björnsson 616f2fb36e drivers: sensor: iis3dhhc: Update driver to use gpio_dt_spec
Move driver to use gpio_dt_spec for GPIO interrupt handling.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-01 11:37:24 +02:00
Benjamin Björnsson da63820203 drivers: sensor: iis3dhhc: Remove SPI from driver data struct
Remove SPI related things from driver data struct for consistency
with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-01 11:37:24 +02:00
Benjamin Björnsson e6b87cc275 drivers: sensor: iis3dhhc: Change parameter of read/write functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-01 11:37:24 +02:00
Francois Ramu 32222e07a4 drivers: sensor: add a stm32 sensor driver for the internal VBat
Similar to the internal temperature sensor of the stm32
this driver controls the Vbat monitoring in Volts,
using an ADC internal input and the stm32-vbat node of the DTS.
The ref voltage is given by the ADC.
Note that stm32F1x does not propose the feature.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-07-01 11:34:17 +02:00
Kumar Gala 5f7790fc23 sensor: iis2mdc: spi: Fix use of deprecated spi_cs_control field
The gpio_dev field of struct spi_cs_control is deprecated.  The
driver was already using SPI_CONFIG_DT_INST, so we should be
using the associated gpio member of spi_cs_control.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-30 11:19:40 -05:00
Tom Burdick 88ca215eed i2c: Update API terminology
Updates the API and types to match updated I2C terminology. Replaces master
with controller and slave with target.

Updates all drivers to match the changed macros, types, and API signatures.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-06-29 17:51:31 +02:00
Jamie McCrae 4e20669aa9 drivers: sensor: sm351lt: Fix global thread triggering bug
This fixes a bug in the sm351lt driver whereby global triggering will
cause an MPU fault due to an unset pointer.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2022-06-29 14:40:53 +00:00
Kumar Gala 02060f7f72 sensor: pms7003: Convert to DEVICE_DT_GET
Move to using DEVICE_DT_GET so we can phase out DT_LABEL.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-28 13:54:32 -04:00
Kumar Gala 5d8f958b4e sensor: pms7003: Fix compile errors with driver
We get type mismatch errors because of use of K_MSEC.  As the timeout
is defined in terms of milliseconds and k_uptime_get() returns
milliseconds we can just remove K_MSEC usage.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-28 13:54:32 -04:00
Kumar Gala 97f0570c67 drivers: sensor: vcnl4040: Update driver to use gpio_dt_spec
Move driver to use gpio_dt_spec for GPIO interrupt handling.

Added check to vcnl4040_trigger_set to handle case of trigger
mode enabled but the devicetree doesn't have an int_gpios property.

Also, moved up the checking/handling of gpio port device in
vcnl4040_trigger_init so that if we error out its before we
setup any threads and such.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-28 08:22:24 -05:00
Kumar Gala a31c6070de drivers: sensor: vcnl4040: 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-28 08:22:24 -05:00
Benjamin Björnsson 6318d29035 drivers: sensor: max17055: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-28 11:07:57 +02:00
Benjamin Björnsson 805ad30324 drivers: sensor: max17055: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-28 11:07:57 +02:00
Kumar Gala ed738ed096 drivers: sensor: ti_hdc: Update driver to use gpio_dt_spec
Move driver to use gpio_dt_spec for DRDY GPIO handling.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-28 11:07:50 +02:00
Kumar Gala c738c99b33 drivers: sensor: ti_hdc: 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-28 11:07:50 +02:00
Loris Schmit e1c2f2cfb6 drivers: mpu9250: magnetometer data read fix
The magnetometer data read from AK9863 is assumed to be big endian
(like the accelerometer & gyroscope data).
However it is in little endian, which means the appropriate byteorder
function is sys_le16_to_cpu().
See the MPU925 register map:
https://3cfeqx1hf82y3xcoull08ihx-wpengine.netdna-ssl.com/wp-content/uploads/2017/11/RM-MPU-9250A-00-v1.6.pdf
At 5.6 HXL to HZH: Measurement Data

Signed-off-by: Loris Schmit <loris.schmit@inovex.de>
2022-06-28 11:06:06 +02:00
Benjamin Björnsson 8f5d247a71 drivers: sensor: sm351lt: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:59:53 -05:00
Benjamin Björnsson 935bf6fa25 drivers: sensor: sm351lt: Move variable declaration
Move variable declaration inside if-def to remove compiler
warning when building the driver without trigger.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:59:53 -05:00
Benjamin Björnsson 3e4e4eaf75 drivers: sensor: si7060: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:57:34 -05:00
Benjamin Björnsson 0f7751049f drivers: sensor: si7060: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:57:34 -05:00
Benjamin Björnsson 4e30743d28 drivers: sensor: si7055: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:49:45 -05:00
Benjamin Björnsson 7937345afd drivers: sensor: si7055: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:49:45 -05:00
Benjamin Björnsson 00fac1e91b drivers: sensor: si7006: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:48:06 -05:00
Benjamin Björnsson f8aef61793 drivers: sensor: si7006: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:48:06 -05:00
Benjamin Björnsson 5eb99ac36c drivers: sensor: shtcx: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:46:06 -05:00
Benjamin Björnsson dd5cf763ab drivers: sensor: shtcx: Remove wrapper functions
Remove wrapper functions for getting i2c bus and i2c bus
address. This is done here to make it easier to move this
driver to i2c_dt_spec while still having clear separation
between commits.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:46:06 -05:00
Benjamin Björnsson fa75491aca drivers: sensor: sht3xd: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:43:51 -05:00
Benjamin Björnsson 238d5ad291 drivers: sensor: sbs_gauge: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:40:19 -05:00
Benjamin Björnsson 04ce7bca33 drivers: sensor: opt3001: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:38:56 -05:00
Benjamin Björnsson b4b02c1b42 drivers: sensor: opt3001: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:38:56 -05:00
Benjamin Björnsson e3e1bd19a3 drivers: sensor: ms5837: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:36:31 -05:00
Benjamin Björnsson 762db471c0 drivers: sensor: ms5837: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:36:31 -05:00
Benjamin Björnsson 96b460d546 drivers: sensor: mpr: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:34:13 -05:00
Benjamin Björnsson e84aa19c86 drivers: sensor: mpu6050: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:31:14 -05:00
Benjamin Björnsson 62c4cf91e6 drivers: sensor: mpu6050: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:31:14 -05:00
Benjamin Björnsson 9d8f852729 drivers: sensor: mcp9808: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:28:20 -05:00
Benjamin Björnsson 34238059a5 drivers: sensor: mcp9808: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:28:20 -05:00
Benjamin Björnsson ba90450974 drivers: sensor: max44009: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:23:48 -05:00
Benjamin Björnsson c4ac3613fb drivers: sensor: max44009: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:23:48 -05:00
Benjamin Björnsson 220d136235 drivers: sensor: max30101: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:20:09 -05:00
Benjamin Björnsson 00e22733a1 drivers: sensor: max17262: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:18:27 -05:00
Benjamin Björnsson c71ee90ec2 drivers: sensor: isl29035: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:10:44 -05:00
Benjamin Björnsson 6c8161a00d drivers: sensor: isl29035: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:10:44 -05:00
Benjamin Björnsson 1e51107577 drivers: sensor: isl29035: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 10:10:44 -05:00
Kumar Gala 892b43f038 drivers: sensor: th02: 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-27 10:01:59 -05:00
Kumar Gala 1f34441c2d drivers: sensor: wsen_itds: Update driver to use gpio_dt_spec
Move driver to use gpio_dt_spec for GPIO interrupt handling.  Since
the driver can support multiple instances its possible that some
have irq's in dts and some don't.  So we add a check in
itds_trigger_set to make sure we have a GPIO device if we are
trying to set a trigger.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-27 09:47:06 -05:00
Kumar Gala ce41b3c82f drivers: sensor: wsen_itds: 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-27 09:47:06 -05:00
Benjamin Björnsson dbff3f0124 drivers: sensor: lsm6ds0: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 09:42:55 -05:00
Benjamin Björnsson 45b70fc8cf drivers: sensor: lsm303dlhc_magn: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 09:40:16 -05:00
Benjamin Björnsson 129e7d5cda drivers: sensor: lsm9ds0_gyro: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 09:38:06 -05:00
Benjamin Björnsson 2710355553 drivers: sensor: lsm9ds0_gyro: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 09:38:06 -05:00
Benjamin Björnsson bbd7b3fe72 drivers: sensor: lsm9ds0_gyro: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 09:38:06 -05:00
Benjamin Björnsson d35c55d437 drivers: sensor: lps22hb: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 09:34:37 -05:00
Benjamin Björnsson 692b0ead74 drivers: sensor: lsm9ds0_mfd: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-27 12:47:44 +02:00
Benjamin Björnsson 1a0159518b drivers: sensor: lsm6dsl: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-24 20:29:54 +02:00
Benjamin Björnsson 07587e7826 drivers: sensor: lsm6dsl: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-24 20:29:54 +02:00
Benjamin Björnsson bae6af4acc drivers: sensor: lsm6dsl: Remove unused variable and label
Remove variable and label that are not used to remove compiler
warnings.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-24 20:29:54 +02:00
Benjamin Björnsson 20b1fdb39c drivers: sensor: lm75: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-24 20:29:46 +02:00
Benjamin Björnsson d4f00fe3c4 drivers: sensor: ccs811: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-23 16:52:26 -05:00
Benjamin Björnsson 3ac870b03b drivers: sensor: ccs811: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-23 16:52:26 -05:00
Benjamin Björnsson 15aefccf17 drivers: sensor: ccs811: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-23 16:52:26 -05:00
Benjamin Björnsson 3b2f21e291 drivers: sensor: bmi270: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-23 16:46:01 -05:00
Benjamin Björnsson fc7e67966a drivers: sensor: bmi270: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-23 16:46:01 -05:00
Benjamin Björnsson 8c2a6e34a8 drivers: sensor: bmc150_magn: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-23 16:40:03 -05:00
Benjamin Björnsson c145539b54 drivers: sensor: bmc150_magn: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-23 16:40:03 -05:00
Benjamin Björnsson f06ea0e12e drivers: sensor: dht: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-23 16:34:28 -05:00
Benjamin Björnsson 4edf96d40b drivers: sensor: dps310: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-23 16:32:19 -05:00
Benjamin Björnsson 481fe82fa9 drivers: sensor: dps310: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-23 16:32:19 -05:00
Benjamin Björnsson b22c6a8867 drivers: sensor: hmc5883l: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-23 16:24:43 -05:00
Benjamin Björnsson be1e512aad drivers: sensor: hmc5883l: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-23 16:24:43 -05:00
Benjamin Björnsson d4731daaf6 drivers: sensor: lps25hb: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-23 15:46:00 -05:00
Maximilian Deubel 1c1c72ea08 ADXL362: Add separate activity/inactivity triggers
This patch modifies the ADXL362 driver to use the new
SENSOR_TRIG_MOTION trigger for activity detection
and SENSOR_TRIG_STATIONARY for inactivity detection.

Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
2022-06-23 10:28:34 -05:00
Benjamin Björnsson 73ca3c72bc drivers: sensor: adxl345: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-22 14:37:07 +02:00
Benjamin Björnsson 82901bd563 drivers: sensor: fxos8700: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-22 12:27:17 +02:00
Benjamin Björnsson 47b3e65290 drivers: sensor: fxos8700: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-22 12:27:17 +02:00
Benjamin Björnsson 1e44af1e2c drivers: sensor: lis3mdl: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-22 12:27:02 +02:00
Benjamin Björnsson 37b59c3427 drivers: sensor: lis3mdl: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-22 12:27:02 +02:00
Benjamin Björnsson e06359f616 drivers: sensor: fxas21002: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-22 12:25:52 +02:00
Benjamin Björnsson 5f4be73ba0 drivers: sensor: fxas21002: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-22 12:25:52 +02:00
Maximilian Deubel ad3d8e8581 ADXL362: fix write to FIFO_SAMPLES register
This patch removes a superfluous write to the INTMAP1 register
that happens because the byte count was previously wrong.

Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
2022-06-21 10:48:52 +02:00
Benjamin Björnsson 0f62594f65 drivers: sensor: ens210: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-20 08:46:01 -05:00
Benjamin Björnsson 5afcea07b2 drivers: sensor: ens210: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-20 08:46:01 -05:00
Kumar Gala e3f991b7b8 drivers: sensor: ams_iAQcore: 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-20 08:25:32 -05:00
Benjamin Björnsson 6cff868c70 drivers: sensor: fdc2x1x: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-20 08:18:55 -05:00
Benjamin Björnsson 9bb7c9771f drivers: sensor: fdc2x1x: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-20 08:18:55 -05:00
Benjamin Björnsson 534988ffcf drivers: sensor: bmm150: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-17 11:09:19 -05:00
Benjamin Björnsson 94861280f6 drivers: sensor: bq274xx: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-17 08:52:44 -05:00
Benjamin Björnsson 0c42b0f1a6 drivers: sensor: bq274xx: Change parameters of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-17 08:52:44 -05:00
Benjamin Björnsson 4974a2d165 drivers: sensor: bmg160: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-17 08:48:40 -05:00
Benjamin Björnsson 0db8f22892 drivers: sensor: bmg160: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-17 08:48:40 -05:00
Benjamin Björnsson 67d53d9232 drivers: sensor: bma280: Update driver to use gpio_dt_spec
Simplify driver by using gpio_dt_spec for gpio access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-17 10:18:16 +02:00
Benjamin Björnsson 3be45afe79 drivers: sensor: bma280: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-06-17 10:18:16 +02: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
Kumar Gala fa74cadbf0 drivers: sensor: hp206c: Update driver to use i2c_dt_spec
Move driver to use i2c_dt_spec for I2C bus access.

Also removed unused gpio.h header include.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-16 10:37:59 -05:00
Kumar Gala ef6146d802 drivers: sensor: adt7420: 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:35:48 -05:00
Kumar Gala 6563245300 drivers: sensor: adt7420: 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:35:48 -05:00
Thomas Stranger 38b23fd825 drivers: shtc3: fix normal mode measurement time.
The measurement time in normal mode was too short.
With this commit the maximum value of the datasheet is applied.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2022-06-15 17:02:27 -05:00
Kumar Gala 61c2b35335 drivers: sensor: amg88xx: 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-14 09:21:21 -05:00
Kumar Gala 1fbc9632c1 drivers: sensor: amg88xx: 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-14 09:21:21 -05:00
Keith Packard 7c6fe0735d drivers/adxl372: Fix computation of sensor value
Sensor value computation was creating a 64-bit integer value, passing
that to 'abs' and assigning that to an int32_t result and then sanity
checking the result. If the computation goes badly wrong, then the range
reduction of 64-bit to 32-bit values could generate a falsely in-range
value.

Instead, perform the computation in 64-bits, range check that value and
then assign to a 32-bit variable.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-14 01:50:36 +09:00
Kumar Gala bb03af637c drivers: gpio: remove unused HAS_DTS_GPIO Kconfig symbol
All the gpio drivers are based on devicetree and thus we always set
HAS_DTS_GPIO, thus we don't need this Kconfig option anymore.  Remove
uses as its safe to assume DTS is supported for GPIO.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-06-10 09:47:31 +02:00
Chay Guo 08641f0616 driver: sensor: mcux_acmp: add discrete mode
The ACMP on i.MXRT11xx support discrete mode,
updated the driver to support discrete mode configuration.

Signed-off-by: Chay Guo <changyi.guo@nxp.com>
2022-06-09 11:30:49 +02:00
Maximilian Deubel 3530fc088b ADXL362: Add DTS properties for low-power modes
This patch adds DTS properties for using wake-up mode
and the autosleep function to the ADXL362 driver.

Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
2022-06-05 14:42:40 +02:00
Fabio Baltieri e24314f10f include: add more missing zephyr/ prefixes
Adds few missing zephyr/ prefixes to leftover #include statements that
either got added recently or were using double quote format.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-05-27 15:20:27 -07:00
Trent Piepho 094345629b drivers/sensor: lsm6dso: Add support for lsm6dso32
This sensor is virtually identical to the lsm6dso.  The only difference
is the accelerometer ranges are double those of the lsm6dso.

Use the same driver.  The difference is detected by using "st,lsm6dso32"
as the first compatible entry, followed by "st,lsm6dso".

An bit flag in the existing accel_range config field is used to check if
the chip is the doubled range or not.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2022-05-25 13:16:04 -07:00
Trent Piepho 5edd4221ad drivers/sensor: lsm6dso: Refactor common config out of I2C/SPI macros
Move common settings out of the SPI and I2C instantiation macros and
into a common macro, which the aforementioned two macros can then use.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2022-05-25 13:16:04 -07:00
Trent Piepho c269692b1d drivers/sensor: lsm6dso: Remove LE to CPU conversions
In ST HAL v2.00, the functions to get the raw sensors values, e.g.
lsm6dso_acceleration_raw_get(), convert from little-endian to CPU.

Previous versions of ST HAL didn't do this.

The conversion here in the driver is converting a second time.  It's not
an issue on a LE system, the conversion is a no-op, but on a BE system
it would be broken.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2022-05-25 13:16:04 -07:00
Armando Visconti f91471640e drivers/sensor: lsm6ds0: Fix typo when configuring FS at 16G
Fixed a typo when selecting LSM6DS0_ACCEL_FULLSCALE_16G.
(Fixes #45583)

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2022-05-23 15:16:15 +02:00
Jose Alberto Meza d2361e8441 drivers: sensor: mchp_tach: Correct spelling header
Correct spelling in copyright.

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2022-05-20 12:35:37 +02:00
Mulin Chao 22f9036577 drivers: sensor: npcx_tach: add pinctrl driver support
Replace soc-specific pin functions with Zephyr pinctrl api functions for
pin-mux configuration in npcx tachometer driver.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2022-05-12 14:24:03 -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
Tim Lin 5551872047 ITE: drivers/sensor: Use pinctrl instead of pinmux driver
Use pinctrl instead of pinmux driver.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-05-06 11:32:40 +02:00
Bernardo Perez Priego 4c34331b4c drivers: sensor: Store sensor trigger structure reference for client use
Store sensor trigger structure reference provided on `trigger_set`, and
pass reference back to client when trigger callback is invoked.

This will enable client to use `CONTAINER_OF()` inside its trigger
callback code.

Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
2022-05-04 09:22:52 -05:00
Bernardo Perez Priego cfe4d51b4f drivers: sensor: Add adc-comparator binding and implementation for NPCX
Comparator will monitor signal though ADC channel, based on
user configuration, callback will be triggered.
This will enable comparator functionality for nuvoton MCU utilizing its
ADC threshold detection feature. Implementation is exported through
sensor trigger API. Use of CONFIG_ADC_CMP_NPCX is required.

Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
2022-05-03 08:51:53 -05:00
Yong Cong Sin fbd0cd01d5 drivers: sensor: stm32_temp: setup channel before adc_read
Currently the driver only setup the ADC to read from the
internal temperature channel on init. However, it is possible
that some other application that uses the ADC can setup the
ADC to read from some other channel and therefore subsequent
stm32_temp_sample_fetch will fail to read the targeted channel.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-04-29 16:10:51 +02:00
Yong Cong Sin 94624dc0c5 drivers: sensor: stm32_temp: No need to calibrate ADC
The ADC should be calibrated on init, there is no requirement
to calibrate ADC again on stm32_temp_init, remove it.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-04-29 16:10:51 +02:00
Leonard Pollak 35b55175cc drivers: sensor: bme680: Add SPI interface
This enables the SPI interface for the BME680 sensor driver.

Signed-off-by: Leonard Pollak <leonardp@tr-host.de>
2022-04-28 18:11:50 +02:00
Leonard Pollak 4e804bfa73 drivers: sensor: bme680: prep work
Consolidate the initialization routines and change the include guard to
conform with the coding guidelines as a preparation for the following
commits which add support for the SPI interface.

Signed-off-by: Leonard Pollak <leonardp@tr-host.de>
2022-04-28 18:11:50 +02:00
Leonard Pollak 8e7907aa6f drivers: sensor: bme680: fix constants
This fixes the constant for the mem page and replaces a
magic number with the already defined `BME680_LEN_COEFF2` constant.

Signed-off-by: Leonard Pollak <leonardp@tr-host.de>
2022-04-28 18:11:50 +02:00
Maxime Vincent 307a60e217 drivers/sensor: lis2dw12: add drdy pulsed/latched config
Add DT option to configure the data ready interrupt mode.
Latched is the default; pulsed can be enabled through
the drdy-pulsed DT, if desired.

Signed-off-by: Maxime Vincent <maxime@veemax.be>
2022-04-26 15:53:58 -04:00
Maxime Vincent bf1334bafb drivers/sensor: lis2dw12: add threshold interrupt support
Add optional threshold interrupt support.
Implemented using SENSOR_TRIG_THRESHOLD sensor trigger type.
The features can be optionally enabled through Kconfig,
or disabled for smaller code size.

Signed-off-by: Maxime Vincent <maxime@veemax.be>
2022-04-26 15:53:58 -04:00
Maxime Vincent 652ab7f2d4 drivers/sensor: lis2dw12: add fds + hp_ref support
Add FDS (Filtered Data Type Selection) + High-Pass reference mode support
(FDS in CTRL6, HP_REF_MODE in CTRL7)
Values are configurable through DT per instance.

Signed-off-by: Maxime Vincent <maxime@veemax.be>
2022-04-26 15:53:58 -04:00
Maxime Vincent 2d2a708bc8 drivers/sensor: lis2dw12: add low_noise support
Add low_noise support. (LOW_NOISE in CTRL6)
Value is configurable through DT per instance.

Signed-off-by: Maxime Vincent <maxime@veemax.be>
2022-04-26 15:53:58 -04:00
Maxime Vincent 47021a608d drivers/sensor: lis2dw12: add bw_filt support
Add bandwidth filter support. (BW_FILT in CTRL6)
Value is configurable through DT per instance.

Signed-off-by: Maxime Vincent <maxime@veemax.be>
2022-04-26 15:53:58 -04:00
Marcin Niestroj 03d0b982a4 drivers: sensor: lis3mdl: return -ENOTSUP on unsupported channels
sensor_channel_get() API should return -ENOTSUP when requested channel
is not supported. This behavior allows to use `sensor get DEVNAME` shell
command easily, as all unsupported channels are filtered out.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-04-26 13:14:44 -05:00
Andreas Pettersson cd9c82bff2 drivers: sensor: lsm6dso: Remove usage of undefined variable
Remove usage of undefined variable, and remove unused variable.

Fixes issue https://github.com/zephyrproject-rtos/zephyr/issues/42588

Signed-off-by: Andreas Pettersson <andreaspettersson95@gmail.com>
2022-04-20 08:59:35 -05:00
Bartosz Bilas 7c77e7ee08 drivers: sensor: qdec_sam: remove superfluous default n for boolean
bool symbols implicitly default to n so
there is no need to redundant those values.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-04-15 10:32:24 -07:00
Diogo Correia 70e1f97ca4 drivers: sensor: bmi160: fix waiting time before reading CHIP_ID
Value changed from 100us to 150us. Value was not enough upon softreset.
This value was arbitrarily chosen and should be changed if more
information on the subject is provided.

Fixes #43794

Signed-off-by: Diogo Correia <dcorreia@protonmail.com>
2022-04-13 12:57:31 -07:00
Mikkel Jakobsen 0b0c2e78e0 drivers: sensor: add icm42670 6-axis accelerometer driver
the icm42670 from Invensense/TDK is a 6-axis accelerometer with
gyroscope and temperature sensing capabilities.

this initial driver does not support the devices 2K FIFO or many of the
other advanced features. Instead, only basic features are implemented.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@escolifesciences.com>
2022-04-08 15:49:08 -07:00
Titouan Christophe 93d06330c5 drivers: sensor: vl53l0x: add support to reprogram I2C address
The I2C address of the VL53L0X distance sensor can only be programmed
over the I2C bus. To do this:

1. The sensor is powered off or in standby mode
2. Power up the sensor, it boots with a default I2C address (0x29)
3. The I2C master sends a configuration command to set the new address
4. The sensor now communicates at the new address

In case there are more than one such sensor on the bus, they all have
the same address when starting up. We therefore need to first apply
step 1. on all of them. Then, sensor by sensor apply steps 2. to 4.

Because simple designs may not need to reprogram the address, we
introduce a new configuration option CONFIG_VL53L0X_RECONFIGURE_ADDRESS

If this setting is disabled, then the driver behaves as before.

If CONFIG_VL53L0X_RECONFIGURE_ADDRESS is enabled, then the driver does
the following:

- In vl53l0x_init(), apply step 1. This is done when the driver is
  brought up when starting the system
- in vl53l0x_start(), apply steps 2. to 4. This is done when fetching
  a sample, if the sensor has not been started yet.

Also, as cosmetic changes:
- add parenthesis around sub conditions in call to __ASSERT_NO_MSG
- gracefully handle unknown sensor channels in vl53l0x_channel_get

Signed-off-by: Titouan Christophe <moiandme@gmail.com>
2022-04-07 14:30:01 -05:00
Titouan Christophe b2172b4251 drivers: sensor: vl53l0x: add driver support for multiple sensors
Up until now, the vl53l0x driver only supported a single device, ie.
the first entry st,vl53l0x in the device tree. To be able to use
multiple sensors at the same time, create one driver data instance per
vl53l0x node in the device tree. Also split the constant driver config
from the runtime data.

Because the vl53l0x address is only configurable with an I2C command,
and is not persisted if the sensor is rebooted, multiple sensors can
be handled only if either:
- They are on different I2C buses
- Their addresses are coonfigured (by some external code) before
  vl53l0x_init is called

Also use the i2c_dt_spec and gpio_dt_spec APIs, as it makes
the code more concise and readable.

Finally, to distinguish the logs mesages from different sensors,
prefix the text with the sensor name.

Signed-off-by: Titouan Christophe <moiandme@gmail.com>
2022-04-07 14:30:01 -05:00
Titouan Christophe e24899a485 drivers: sensor: vl53l0x: wait only 2ms for tboot
As per the VL53L0X datasheet, in 2.9.1 "Power up and boot sequence",
time to boot is 1.2ms max, so we only have to wait at most 2ms.

Signed-off-by: Titouan Christophe <moiandme@gmail.com>
2022-04-07 14:30:01 -05:00
Titouan Christophe 1267d51dda drivers: sensor: vl53l0x: run uncrustify
Apply uncrustify on the driver source code before going further

Signed-off-by: Titouan Christophe <moiandme@gmail.com>
2022-04-07 14:30:01 -05:00
Andrzej Głąbek 586e26e8fc soc: nrf: Use data from DTS to populate HAS_HW_NRF_* Kconfig options
Instead of selecting appropriate HAS_HW_NRF_* options for particular
nRF SoCs (and simulated nRF52 target), set their values basing on
information from devicetree.
Correct also semantics of those options so that they are set only when
a corresponding DT node is enabled. This allows using them directly in
Kconfig dependencies of Zephyr drivers for nRF peripherals. Update
appropriately these dependencies.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-04-02 15:14:38 +02:00
Ruibin Chang 199eaac0a4 ITE drivers/sensor/vcmp: don't connect shared irq multiple times
This driver exectue connecting the shared irq one time for
every status "okay" vcmp nodes, then it will show enable
the same irq multiple times when build.

So I check whether the irq is enabled or not, if yes,
we needn't to enable again. And we will figure out the
triggered channel in vcmp_it8xxx2_isr().

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2022-03-31 12:20:11 -05:00
Jay Vasanth a94760d9b4 drivers: tach: Microchip XEC TACH driver add PINCTRL support
Add build time optional PINCTRL support to the Microchip XEC TACH
driver shared by MEC15xx and MEC172x families.

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2022-03-31 10:30:17 +02:00
Jay Vasanth b0cfaa44cd drivers: tach: Microchip XEC TACH driver add MEC172x support
Update Microchip XEC TACH driver to support MEC172x.
Standardize device tree properties between chips.
Standardize device structure usage.

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2022-03-31 10:30:17 +02:00
Ruibin Chang a21d043f5b ITE drivers/sensor: add voltage comparator driver
Add voltage comparator driver for ITE it8xxx2 chip.

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2022-03-25 15:00:35 -07:00
Konstantin Mochalov 104a668fe8 drivers: sensor: mhz19b: fix all channels fetch
mhz19b_sample_fetch() from mhz19b sensor driver didn't support
SENSOR_CHAN_ALL chan parameter value, so sensor_sample_fetch() didn't
work, always returning -ENOTSUP (sensor_sample_fetch_chan() worked, if
called with SENSOR_CHAN_CO2).

This change enables mhz19b sensor to work both with
sensor_sample_fetch() and with sensor_sample_fetch_chan() with
SENSOR_CHAN_CO2.

Signed-off-by: Konstantin Mochalov <incredible.angst@gmail.com>
2022-03-25 08:22:33 -05:00
Gerson Fernando Budke 0f472f6d1b drivers: sensors: Update sam qdec driver to use pinctrl
This update Atmel sam qdec sensor driver to use pinctrl driver and API.
It update board and sample with new pinctrl groups format.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2022-03-24 15:45:37 -07:00
Avi Green 1d46332b39 bmi160: Added I2C to Kconfig dependency
bmi160 driver code supports i2c, but is not selectable by Kconfig

Signed-off-by: Avi Green <avigreen1978@yandex.com>
2022-03-23 10:01:47 -07:00
Daniel DeGrasse 31406c13f2 drivers: sensor: Add pinctrl support for mcux acmp sensor
Add pinctrl support for mcux acmp sensor driver

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-03-22 12:36:04 +01:00
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Andrzej Głąbek a5234f3647 soc_nrf_common: Extend and rename the NRF_DT_ENSURE_PINS_ASSIGNED macro
Extend the macro with checks for DT properties related to pin
assignments that are defined but would be ignored, depending on
whether PINCTRL is enabled or not, what presumably indicates
a resulting configuration different from what the user expects.

Add also a possibility to indicate that the pinctrl-1 property
should not be checked because the caller does not support the
sleep state.

Rename the macro so that its name better reflects its function.
Update accordingly all drivers that use it.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-03-18 16:26:21 +01:00
Armando Visconti e8f93a915d drivers: sensor: lsm6dsl: FIX bugs on few registers definition
FIX bugs on few registers definition
Fixes: #43669

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2022-03-17 08:43:39 -05:00
Mikkel Jakobsen 0c6cf9a84e drivers: sensor: icm42605: fix arg passing bug in trigger thread
the device data struct pointer is passed to the thread function when
creating the thread, but the thread function did a int-to-pointer cast
which did not work as intended, causing exception during runtime.

now, we just pass the pointer directly without casting, which is the
pattern seen in other sensor drivers.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@escolifesciences.com>
2022-03-16 08:58:06 -05:00
Mikkel Jakobsen f502d21634 drivers: sensor: icm42605: convert to usinggpio_dt_spec
for the interrupt gpio, now use gpio_dt_spec instead of raw gpio.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@escolifesciences.com>
2022-03-16 08:58:06 -05:00
Gerard Marull-Paretas 9953c194b9 drivers: remove redundant DEV_NAME helpers
Just use dev->name. This change follow same principles applied when
DEV_CFG and DEV_DATA macros were removed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-15 17:31:51 -04:00
Andrzej Głąbek 1a01ca2adf drivers: sensor: qdec_nrfx: Add support for pinctrl
Add support for the new pinctrl API to the nRF QDEC driver.
Update code of the driver and the related devicetree binding.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-03-15 18:38:01 +01:00
Nazar Kazakov 9713f0d47c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-14 20:22:24 -04:00
Avi Green a2190cc92b bmi160: bmi160_bus union bugfix
bmi160.c module defines DT_DRV_COMPAT, but bmi160_trigger.c doesn't.
This causes a catastrophic chain of events.
The bmi160.c module includes bmi160.h,
in which the macro DT_ANY_INST_ON_BUS_STATUS_OKAY
affects the size of bmi160_bus union.
So bmi160.c defines a bmi160_cfg struct which contains that union.
Now, in bmi160_trigger_init we get a pointer to that config struct.
The fact that this module now includes bmi160.h without
DT_DRV_COMPAT, causes it to think the union is empty.

That doesn't cause compilation error, just undefined behaviour,
In which you address an empty struct fields.

In general, I suggest that someone makes sure it doesn't happen
in other drivers as well. The problem presented here is general,
meaning that if an h file assumes someone defined DT_DRV_COMPAT
before and it doesn't,
it may lead to some weird behaviour, like the one described.

Signed-off-by: Avi Green <avigreen1978@yandex.com>
2022-03-11 07:05:12 -06:00
Jeremy Wood 2331b76b9b drivers: lis2dh: power management
* Add support for power management.

Signed-off-by: Jeremy Wood <jeremy@bcdevices.com>
2022-03-09 10:19:22 -06:00
Gerard Marull-Paretas 95fb0ded6b kconfig: remove Enable from boolean prompts
According to Kconfig guidelines, boolean prompts must not start with
"Enable...". The following command has been used to automate the changes
in this patch:

sed -i "s/bool \"[Ee]nables\? \(\w\)/bool \"\U\1/g" **/Kconfig*

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-09 15:35:54 +01:00
Mikkel Jakobsen da514737d0 drivers: sensor: icm42605: fix default kconfig issues
by default, a global trigger thread was enabled in kconfig but
the thread priority and stack size depended on a local thread
being enabled.

the local thread option was never used anywhere so it is removed.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@escolifesciences.com>
2022-03-07 16:23:36 -06:00
Mikkel Jakobsen 9d3f9e3921 drivers: sensor: icm42605: make trigger mode choice named
convert choice to named choice to allow setting from Kconfig.* files

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@escolifesciences.com>
2022-03-07 16:23:36 -06:00
Andrew Hedin c64783f29d drivers: sensors: lis2dh: Allow any movement on interrupt 1
Allow movement detection to be used on hardware
that only has one interrupt line connected.
Change hardware configuration to a bitmask.

Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
2022-03-07 10:46:17 +01:00
Emil Lindqvist 8b4a3e2328 sensor: vcnl4040: add missing semicolon
Adding missing semicolon to vncl4040 driver

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2022-03-03 18:52:28 -05:00
Bartosz Bilas a3af7007f7 drivers: sensor: iis3dhhc: convert to spi_dt_spec
Convert icm42605 driver to use spi_dt_spec helpers.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-03-01 11:54:07 +01:00
Simon Frank ba7af2f780 include: sensor: sensor_value from double overflow
sensor_value_from_double had a early overflow when converting the
fractional part (val2).  This occured when input was more then
2147.493647 (inp >= INT32_MAX/1000000.0 + 0.01).

return value -ERANGE as this is what errno is set to by `strtod` and
similar posix functions.

fixes issue #39176

Signed-off-by: Simon Frank <simon.frank@lohmega.com>
2022-02-24 13:45:29 -08:00
Pete Dietl 5dddf9f0f8 drivers: sensors: Implement MAX31875 sensor
This commit implements the temperature sensor interface for
the Maxim MAX31875Low-Power I2C Temperature Sensor.

Signed-off-by: Pete Dietl <petedietl@gmail.com>
2022-02-24 08:49:40 -06:00
Bartosz Bilas db2b6de0b8 drivers: sensor: lis2dh: convert to spi_dt_spec
Convert lis2dh driver to use `spi_dt_spec` helpers.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-02-21 19:43:55 -05:00
Bartosz Bilas 46a1c2d16f drivers: sensor: ism330dhcx: convert to spi_dt_spec
Convert ism330dhcx driver to use spi_dt_spec helpers.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-02-21 19:38:46 -05:00
Piotr Mienkowski a922fd1b2f drivers: qdec_sam: disable index signal
`qdec_sam` driver supports currently only position measurement and does
not support reading of the index signal. Unfortunately, the index
signal was internally enabled in the driver. If the pin to which the
index signal was connected was used by another driver it could lead to
a false detection of the signal change. Detection of the index signal
change resets the position measurement.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2022-01-28 10:07:06 +01:00
Wealian Liao 6d6c5e1155 drivers: npcx: Drop DRV_CONFIG/DRV_DATA usage
Stop using DRV_CONFIG/DRV_DATA macros and use dev->data and dev->config
instead.

Signed-off-by: Wealian Liao <WHLIAO@nuvoton.com>
2022-01-28 10:06:05 +01:00
Wealian Liao 3565f71a72 drivers: npcx: Correct the macro parentheses
This corrects the following:
1. The priority of type cast is lower than member access. So don't need
the redundant parentheses.
2. The macro should be added to the parentheses.

Signed-off-by: Wealian Liao <WHLIAO@nuvoton.com>
2022-01-28 10:06:05 +01:00
Gerard Marull-Paretas 435213a753 drivers: remove redundant data/config casts
Some drivers explicitely casted data/config from void * to the
corresponding type. However, this is unnecessary and, in many drivers it
has been misused to drop const qualifier (refer to previous commits).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-19 18:16:02 +01:00
Gerard Marull-Paretas 30971b51ba drivers: sensor: sbs_gauge: constify device config access
`const` was missing from one device config access.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-19 18:16:02 +01:00
Gerard Marull-Paretas b9319e57cb drivers: sensor: lm75: constify device config access
`const` was missing from one device config access.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-19 18:16:02 +01:00
Gerard Marull-Paretas 2c103a25cc drivers: sensor: drop get_dev_data/get_dev_config usage
Replace all get_dev_data()/get_dev_config() accessor utilities with
dev->data and dev->config.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-19 18:16:02 +01:00
Gerard Marull-Paretas e8c15f68b2 drivers: sensor: drop DEV_DATA/DEV_CFG usage
Stop using redundant DEV_DATA/DEV_CFG macros and use dev->data and
dev->config instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-19 18:16:02 +01:00
Gerard Marull-Paretas ddc168fa78 pm: s/PM_DEVICE_(DT_(INST))_REF/PM_DEVICE_(DT_(INST))_GET
In order to align with macros used to obtain a device reference (e.g.
DEVICE_DT_GET), align the PM macros to use "GET" instead of "REF". This
change should have low impact since no official release has gone out yet
with the "REF" macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-18 12:14:06 -05:00
Dominik Chat 3e6ab47455 sensors: Implement MPU9250 driver
MPU9250 driver for 9-axis
gyroscope, accelerometer, magnetometer

Signed-off-by: Dominik Chat <dominik.chat@nordicsemi.no>
2022-01-14 12:33:04 +01:00
Wouter Cappelle c3ca3aa27d sensors: STM32: Add support for L5 die temp sensor
This PR adds the different handling of temperature sensor for the
STM32L5 soc. In this soc, there are some calibration settings which
need to be applied for temperature conversion.

Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
2022-01-13 10:34:10 +01:00
Wouter Cappelle ba12740049 sensors: STM32: code formatting of stm32_temp with sample
clang format on stm32_temp.c & the sample

Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
2022-01-13 10:34:10 +01:00
Wouter Cappelle c9e7ca3cac sensors: STM32: Prepare for different handling of temp conversions
moving the conversion from adc value to the get function
which will be used for different handling of stm32 temp sensors

Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
2022-01-13 10:34:10 +01:00
Ryan McClelland dacae94761 drivers: avoid i2c_burst_write where possible
i2c_burst_write can have portability issues with certain i2c
peripherals that can fail when this api is called. This fixes the case
where this can be easily replaced with i2c_write in mcp230xx,
pca95xx, stmpe1600, max17055, and tmp112.

Signed-off-by: Ryan McClelland <ryanmcclelland@fb.com>
2021-12-22 12:14:42 +01:00
Yong Cong Sin 26f7b9c1ea drivers: sensor: Add MH-Z19B CO2 sensor driver
Add MH-Z19B CO2 sensor driver.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Co-Authored-By: Azamlukman <azamlukmanabdullah@gmail.com>
2021-12-20 18:47:47 +01:00
Pete Dietl 2b62282d46 drivers: sensors: tmp112 fix config register updating
The function that sets the driver's state of the sensor's
config register has a bug. This commit fixes that.

Signed-off-by: Pete Dietl <petedietl@gmail.com>
2021-12-20 17:42:33 +01:00
Armando Visconti 34fed86b2b drivers/sensor: lsm6dso: Add power mode properties to DTS
Add power mode properties for bot accelerometer and gyrometer
to Device Tree.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-12-18 07:58:50 -05:00
Armando Visconti 18e8cadaf9 drivers/sensor: lsm6dso: Move odr/range Kconfig property into dts
Move odr and range properties for both accelerometer and gyro
from Kconfigs to Device Tree.
Fixes #41117

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-12-18 07:58:50 -05:00
Jimmy Johnson 5fda6a3b2f sample: sensor: tmp108: Add ti tmp108 sample
This sample writes the tmp108 temperature to the console
once every 3 seconds. There are macro definitions included
for turning off and on alerts if that is set up, and
also using low power one shot mode.

Signed-off-by: Jimmy Johnson <catch22@fastmail.net>
2021-12-17 21:15:25 +01:00
Jimmy Johnson 5c28b218fa drivers: sensor: add ti tmp108 driver support
Adding support for the TI TMP108 temperature sensor. This includes
over/under temp interrupt support as well as one shot, continuous
conversion and power down modes.

Signed-off-by: Jimmy Johnson <catch22@fastmail.net>
2021-12-17 21:15:25 +01:00
Gerard Marull-Paretas ad0855187a drivers: sensor: tmp112: use instance based macros
Replace usage of DT_DRV_INST with instance based macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-17 17:30:06 +01:00
Gerard Marull-Paretas 677050d46d drivers: sensor: max17262: use instance based macros
Replace usage of DT_DRV_INST with instance based macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-17 17:30:06 +01:00
Bartosz Bilas 0bd304f9d9 drivers: sensor: ina23x: add support for INA237
Add the new driver for INA237 variant which is
quite similar to the already supported INA230.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2021-12-14 13:48:54 -06:00
Bartosz Bilas 2df7140947 drivers: sensor: ina230: driver refactoring
Create an explicit ina230 driver which is supposed to
work with 230 and 231 variants. While at it switch
to i2c_dt_spec helpers and change device-tree node
names to use - instead of _ in order to follow
convention.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2021-12-14 13:48:54 -06:00
Bartosz Bilas f50c7ab542 drivers: sensor: ina23x: add ina23x common module
That's needed to not duplicate code between INA230/231
and the upcoming INA237 variant.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2021-12-14 13:48:54 -06:00
Armando Visconti 56b435f2bf drivers/sensor: lps22hh: Move odr Kconfig property into dts
Move odr options from Kconfigs to Device Tree.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-12-14 09:11:15 -06:00
Armando Visconti 177b53a944 drivers/sensor: lps22hh: Add multi-instance support
This commit aligns lps22hh sensor driver to latest multi
instance sensor driver model.

In particular it makes use of the stmemsc common routines
and move ctx handler inside struct config, so that the
bus_init routines can be totally avoided.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-12-14 09:11:15 -06:00
Armando Visconti 13bf2e5e48 drivers/sensor: stmemsc: make use of i2c/spi dt APIs
Make use of the i2c and spi DT APIs introduced in
2946a535 and c894ad12 that get i2c_dt_spec and spi_dt_spec
as input arguments.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-12-13 10:21:43 -06:00
Carles Cufi 2bc9cb4691 sensor: bmi160: Fix address-of-packed-mem warning
The warning below appears once -Waddress-of-packed-mem is enabled:

/__w/zephyr/zephyr/drivers/sensor/bmi160/bmi160.c: In function
bmi160_gyr_channel_get:
/__w/zephyr/zephyr/drivers/sensor/bmi160/bmi160.c:795:23: error: taking
address of packed member of struct <anonymous> may result in an
unaligned pointer value [-Werror=address-of-packed-member]
  795 |           data->sample.gyr, val);
      |           ~~~~~~~~~~~~^~~~
/__w/zephyr/zephyr/drivers/sensor/bmi160/bmi160.c: In function
bmi160_acc_channel_get:
/__w/zephyr/zephyr/drivers/sensor/bmi160/bmi160.c:807:23: error: taking
address of packed member of struct <anonymous> may result in an
unaligned pointer value [-Werror=address-of-packed-member]
  807 |           data->sample.acc, val);
      |           ~~~~~~~~~~~~^~~~

To avoid the warning, make the struct non-packed, since it is not
necessary in this case given that a union already guarantees that the
pointer to the union points to each member of the union equally..

More info in #16587.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-12-10 14:08:59 +01:00
Pete Dietl a1bf02e519 drivers: sensors: tmp112: Remove extra I2C reads
The original code erroneously used:
uint16_t *val;
sizeof val
instead of:
sizeof *val;
This commit fixes this problem and removes an unnecessary
buffer from the stack

Signed-off-by: Pete Dietl <petedietl@gmail.com>
2021-12-09 10:27:47 -06:00
Bartosz Bilas cf8e974bec drivers: sensor: max6675: convert to spi_dt_spec
Convert max6675 driver to use `spi_dt_spec` helpers.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-12-09 10:21:13 -06:00
Bartosz Bilas 68080c1269 drivers: sensor: icm42605: convert to spi_dt_spec
Convert icm42605 driver to use spi_dt_spec helpers.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-12-09 10:20:41 -06:00
Guillaume Lager 972e5d0274 sensor: eeprom: Add TMP116 EEPROM access
eeprom access is supported by using
either custom or eeprom API

Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
2021-12-08 07:51:46 -06:00
Torsten Rasmussen 0c66240908 drivers: nrf5: kconfig: add missing dependency for TEMP_NRF5
Fixes: #40538

The TEMP_NRF5 setting requires MULTITHREADING, therefore add this
dependency to Kconfig.

The TEMP_NRF5 supports an alternative driver implementation using the
TEMP_NRF5_FORCE_ALT setting.
Because it cannot be known whether an alternative implementation has
the same dependency, then the MULTITHREADING is OR'ed with
TEMP_NRF5_FORCE_ALT, as to allow enabling of TEMP_NRF5 if an alternative
driver is provided.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-12-01 16:10:59 +01:00
Markus Brüx c56851a5cb drivers: sensor: lis2dh: Allow power-down mode
Remove check if frequency is equal to zero. A value of `ODR = 0` is
explicitly allowed by manufacturer / datasheet.
This has prevented applications from using the lis2dh power-down-mode,
which is set via `ODR = 0`.

For reference see "Table 28. Data rate configuration" in datasheet p.33.

Fixes #35486.

Signed-off-by: Markus Brüx <markus.bruex@grandcentrix.net>
2021-11-29 18:19:18 -05:00
Thomas Stranger aef64fcb17 drivers: sensor: shtcx: fix
This commit fixes humidity value and model dependent timing parameters.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2021-11-29 18:18:42 -05:00
Ruibin Chang fad78a2c07 ITE drivers/sensor: add tachometer driver for it8xxx2_evb
Add tachometer driver for it8xxx2_evb.

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2021-11-29 08:25:19 -05:00
Gerard Marull-Paretas 89a4f36fc8 device: remove inclusion of pm/device.h
The device PM subsystem _depends_ on device, not vice-versa. Devices
only hold a reference to struct pm_device now, and initialize this
reference with the value provided in Z_DEVICE_DEFINE. This requirement
can be solved with a forward struct declaration, meaning there is no
need to include device PM headers.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-29 11:08:38 +01:00
Ryan McClelland b7bedb5c1e drivers: fix double promotion warnings
With -Wdouble-promotion added to the warning base, fix warnings given
by the compiler.

Signed-off-by: Ryan McClelland <ryanmcclelland@fb.com>
2021-11-24 17:14:25 -05:00
Guillaume Lager 4c986a266f drivers: sensor: tmp112: Add default device initialization
This allow to have a smaller driver footprint when a single
configuration is required.

Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
2021-11-23 13:12:39 +01:00
Guillaume Lager cd207ca0bc drivers: sensor: tmp112: correct type
TMP112 registers are 16bit so there is no reason to use int64_t for
register values

Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
2021-11-23 13:12:39 +01:00
Tomasz Bursztyka d5de0788ad drivers/sensors: Enable 3-wire SPI access to HTS221 sensor driver
HTS221 is a humidity and temperature sensor (thus HTS) that can be wired
on i2c or SPI bus. On SPI bus however, it uses the 3-wire mode, aka:
half-duplex.

Now that SPI API exposes half duplex operation, let's enable the SPI bus
on that sensor.

Let's move to a better DTS integrated driver as well, and also use
stmemsc interface.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-19 11:50:38 +01:00
Tomasz Bursztyka f6be2835bd drivers: Apply SPI API change to relevant places
Mostly drivers, but also one sample and one test.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-11-19 11:50:38 +01:00
Gerard Marull-Paretas 88a69674c0 drivers: use new PM macros
Port some drivers to the recently introduced macros to showcase its
usage and be able to do some initial testing (nRF52840).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-19 10:11:32 +01:00
Gerard Marull-Paretas c759a35d08 drivers: use DT_INST_ENUM_IDX(_OR) macros
Replace `DT_ENUM_IDX(_OR)(DT_DRV_INST(...),` pattern with
`DT_INST_ENUM_IDX(_OR)(...,`.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-18 19:12:07 -05:00
Bartosz Bilas ee95b5317a drivers: sensor: lsm6dsl: improve driver initialization
Take into account the return code of the bus_init function
and propagate codes from the init* functions to the user
instead of hardcoded -EIO. While at it set the ERROR
level message to the logs.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2021-11-09 08:32:13 -06:00
Benjamin Lindqvist 0ab1bf42b3 drivers: sensor: lis2dh: Level triggered interrupts
Both DRDY and motion interrupts behaves like level signals since they
remain asserted until they're cleared. Configuring them as edge
interrupts is dangerous because if we ever miss an interrupt, it may
never get cleared and thus will never trigger again.

Treating them as edge signals seems to have no advantages, other than
being marginally simpler to implement.

The patch has gotten many hours of run-time on real hardware using a
nRF52-based board and a LIS3DH with both interrupts connected and
heavily utilized.

Signed-off-by: Benjamin Lindqvist <benjamin.lindqvist@endian.se>
2021-11-08 15:37:57 -06:00
Gerard Marull-Paretas cb329bbefe drivers: sensor: bme280: make PM action callback static
The PM action callback is never accessed externally, so make it static.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-03 20:27:18 -04:00
Gerard Marull-Paretas 4baf1e01ff drivers: use common PM action callback naming
The PM callback is no longer referenced as "pm_control" but
"pm_action_cb", so reflect this new naming on the callbacks.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-03 20:27:18 -04:00
Gerard Marull-Paretas 79effd7d1a drivers: sensor: si7210: make PM callback static
The PM action callback is not used externally, so make it static.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-03 20:27:18 -04:00
Armando Visconti aa3f3d943a drivers/sensor: lsm6ds0: Fix SENSOR_DEG2RAD_DOUBLE macro
In order to convert from degrees to radiants the SENSOR_DEG2RAD_DOUBLE
macro must divide the argument by 180 degrees and multiply by PI
radiants, and not the other way around. Please note that same macro
is already defined in the correct way in other sensor drivers as well.
(Fix #39483)

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-11-03 08:16:45 -05:00
Andrew Hedin 52c298e0e3 drivers: sensors: lis2dh: Add ability to read temperature
Allow user to read temperature from LIS2DH family of sensors.

Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
2021-11-02 22:23:39 -04:00
Bartosz Bilas 84dc576670 drivers: sensor: lsm6dsl: convert to use spi_dt_spec and i2c_dt_spec
Convert lsm6dsl driver to use `spi_dt_spec` and `i2c_dt_spec` helpers.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2021-10-29 12:21:27 -05:00
Ryan Holleran cbb0585e0b drivers: sensor: fxos8700: Keep current power mode when setting ODR
Setting the power mode to enabled causes other initialization to not
occur. Restore the power mode set upon entry when exiting.

Signed-off-by: Ryan Holleran <rhollerar@gmail.com>
2021-10-28 10:10:52 -05:00
Jakub Rzeszutko 36f907e43c driver: qdec - fix step limits
Corrected the condition that checks the maximum number of steps
allowed.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2021-10-28 08:29:59 -05:00
Bartosz Bilas 0a7d8d4452 drivers: sensor: bmp388: convert to spi_dt_spec
Convert bmp388 driver to use spi_dt_spec helpers.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-10-28 08:29:07 -05:00
Bartosz Bilas 022bc83351 drivers: sensor: ms5607: convert to spi_dt_spec
Convert ms5607 driver to use spi_dt_spec helpers.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2021-10-28 08:28:26 -05:00
Maureen Helm 1788b036fb drivers: sensor: Fix ina219 driver when device pm enabled
Fixes a build error in the ina219 sensor driver when device power
management is enabled.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2021-10-26 20:51:13 -04:00
Maureen Helm be38a87089 drivers: sensor: Fix bq274xx driver when device pm enabled
Fixes a build error in the bq274xx sensor driver when device power
management is enabled.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2021-10-26 20:51:13 -04:00
Gerard Marull-Paretas 6869743e28 sensor: qdec_nrfx: fix PM callback signature
The PM action callback had an incorrect signature, probably a leftover
from the actions conversion.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-10-25 08:30:58 -05:00
Armando Visconti ea6ad7337c drivers/sensor: lis2ds12: Move odr Kconfig property into dts
Move odr options from Kconfigs to Device Tree. Moreover add
in DT a power-mode option to select among 4 possible values
(PD, LP, HR, HF). The power mode cannot be currently set from
sensor APIs.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-10-22 09:06:07 -05:00
Armando Visconti e0f06e23ef drivers/sensor: lis2ds12: Move range Kconfig property into dts
Converts lis2ds12 range options (2g, 4g, 8g, 16g) from Kconfig
to Device Tree.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-10-22 09:06:07 -05:00
Armando Visconti f3ad909abd drivers/sensor: lis2ds12: Add multi-instance support
This commit aligns lis2ds12 sensor driver to latest multi
instance sensor driver model.

In particular it makes use of the stmemsc common routines
and move ctx handler inside struct config, so that the
bus_init routines can be totally avoided.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-10-22 09:06:07 -05:00
Armando Visconti 1c0acad364 driver/sensor: lis2ds12: make use of STdC definitions
Port the lis2ds12 sensor driver on top of the lis2ds12_StdC
HAL interface (in modules/hal/st/sensor/stmemsc/).

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-10-22 09:06:07 -05:00
Armando Visconti dabaaa1e5d drivers/sensor: stmemsc: make use of spi_dt_spec and i2c_dt_spec
Make use of the new DT facilities that introduced two new
bus structures, spi_dt_spec and i2c_dt_spec, as well as the
macros, SPI_DT_SPEC_INST_GET and I2C_DT_SPEC_INST_GET, to
retrieve info from DT.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-10-22 09:06:07 -05:00
Bartosz Bilas 919b3f9165 drivers: sensor: ina23x: fix sample fetching
Fix the usage of sensor shell module that calls sensor_sample_fetch
function with SENSOR_CHAN_ALL id which is not supported and
causes the following error:

uart:~$ sensor get INA237 current
Failed to read sensor: -134
channel idx=31 current =   0.000000

Fix that by adding support for SENSOR_CHAN_ALL channel id.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2021-10-22 08:51:30 -05:00
Bartosz Bilas fd316a5452 drivers: sensor_shell: add missing power sensor channel
There is no power channel within the name array that
is used by e.g INA23X so let's add it to have support
in sensor shell commands.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2021-10-19 07:15:55 -04:00
Pavel Hübner f3dd088a99 drivers: sht3xd: Add names to choices in Kconfig
Unless a choice is named, its default value
cannot be changed in another Kconfig file.

Signed-off-by: Pavel Hübner <pavel.hubner@hardwario.com>
2021-10-12 09:21:08 -05:00
Luis Ubieda a717820f74 drivers: bmi270: Added inter-write delays required to configure device.
- Per datasheet (Rev 1.0, Page 29): When enabling adv_power_save, there
needs to be a 1ms inter-write registers delay. With this addition, the
driver will work at SCLK frequencies faster than 100kHz.
- Added helper function reg_write_with_delay() to factor these writes.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2021-10-12 08:54:00 -05:00
Pavel Hübner 7504265e47 drivers: lis2dh: Add names to choices in Kconfig
Unless a choice is named, its default value
cannot be changed in another Kconfig file.

Signed-off-by: Pavel Hübner <pavel.hubner@hardwario.com>
2021-10-11 21:04:09 -04:00
Armando Visconti a2f3ea5d19 drivers/sensor: lsm6dso: Prevent device entering I3C
On LSM6DSO sensor the INT1 pin is used for both generating the drdy
interrupt and for switching to I3C hotjoin mode just after reset if
it is at logical '1' level. It might happen that after a board
reset the logical level '1' is preserved (maybe a level shifter)
forcing the LSM6DSO to enter erroneously in I3C mode, breaking any
attempt to communicate with it. (Fix #38902)

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-10-06 22:22:09 -04:00
Igor Knippenberg bd7b7a6423 drivers: sensors: fdc2x1x: removed unused fdc2x1x_data
Removing two unused "struct fdc2x1x_data" to fix warnings
when compiling with PM_DEVICE=y.

Signed-off-by: Igor Knippenberg <igor.knippenberg@gmail.com>
2021-10-05 13:13:46 -04:00
Kevin Townsend 21321fba1c drivers: sensor: lsm303dlhc_mag: Fix gain factor
The magnetometer on the LSM303DLHC has a different gain conversion
factor for LSB to Gauss for the Z axis than it does for X, Y. This
commit takes into account the different conversion factors, and
adds the correct coefficients for each gain setting and axis.

Signed-off-by: Kevin Townsend <kevin.townsend@linaro.org>
2021-10-04 20:40:43 -04:00
Jonathan Hahn c9f87969c2 drivers: sensor: add I3G4250D Gyro driver
Implements a shim layer driver using st hal for
I3G4250D gyro, mounted for example on stm32f3_disco_E.
No support for triggers included yet.

Signed-off-by: Jonathan Hahn <Jonathan.Hahn@t-online.de>
2021-09-28 19:44:26 -04:00
Bartosz Bilas 6badb7f1b8 drivers: sensors: sht3xd: allow multiple instances
Make this driver multi-instance.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2021-09-08 09:49:34 -04:00
Armando Visconti c3050a5aab drivers/sensor: lps22hh: Fix int32 overflow in the val2 part
The val2 calculation was done using (1000000 / 40960) as
multiplying factor, which was sometimes leading to a
int32 overflow. So, let's use the equivalent (but smaller)
(3125 / 128).

Fix #38090

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-09-06 03:31:50 -04:00
Gerard Marull-Paretas 5f9fddd9d5 drivers: sensor: adxl362: improve error handling
Error handling was missing in numerous places, mostly on GPIO related
callbacks. Some error codes were not correct (-EINVAL vs -ENODEV) and in
some cases error was not propagated correctly.

Fixes #38117

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-30 17:53:24 -04:00
Gerard Marull-Paretas 35e7acb703 drivers: sensor: adxl372: add missing error handling
Error handling was missing in numerous places, mostly for GPIO related
callbacks. An assertion has been used in the context of thread callback.

Fixes #38132

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-30 17:53:24 -04:00
Martí Bolívar 21c6ca9487 drivers: sensor: clean up zephyr_library calls, again
Apply the same fix in bd8afe9365
(" drivers: sensor: clean up zephyr_library calls") to remove
redundant code in the sensor driver build system files. Additional
instances of the antipattern have crept in.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-30 17:07:51 -04:00
Gerard Marull-Paretas 546dd95ed5 drivers: sensor: sgp40: fix ticks variable types
The result of temperature and relative humidity ticks ranges from 0 to
65535 which is the range of a uint16_t variable. Intermediate tmp
variable type has also been adjusted.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-30 13:42:18 -04:00
Leonard Pollak dcff99eeaf drivers: sensor: sgp40: fix rounding errors
This fixes/improves the rounding errors that are introduced
through the truncation of integer division.

Signed-off-by: Leonard Pollak <leonardp@tr-host.de>
2021-08-27 13:07:54 -04:00
Gerard Marull-Paretas 936f3523d3 drivers: sensor: fxas21002: check gpio calls return code
Some GPIO related calls were not being checked for error.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-26 18:40:08 -04:00
Gerard Marull-Paretas 50a31d2f36 drivers: sensor: bmg160: check gpio calls return code
Some GPIO related calls were not being checked for error.

This patch also fixes coverity issue 236651.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-26 18:40:08 -04:00
Gerard Marull-Paretas 7e57a8720d drivers: sensor: bmi160: check gpio calls return code
Some GPIO related functions were not being checked for errors.

This patch fixes coverity issue 236653.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-26 18:40:08 -04:00
Gerard Marull-Paretas 18732a5c74 drivers: sensor: fxos8700: check gpio calls return code
Some GPIO related calls were not being checked for errors.

This patch fixes coverity issue 236650.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-26 18:40:08 -04:00
Gerard Marull-Paretas 6cfab29e19 drivers: sensor: adt7420: check gpio add callback return code
gpio_add_callback was not being error-checked. Some other minor cleanups
(rc var to the top, remove redundant log).

This patch fixes coverity issue 236649.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-26 18:40:08 -04:00
Gerard Marull-Paretas 2682879df5 drivers: sensor: sx9500: check gpio calls return code
Some GPIO related calls were not being checked for error.

This patch fixes coverity issue 236648.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-26 18:40:08 -04:00
Gerard Marull-Paretas 53231c8bfe drivers: sensor: bmp388: check gpio calls return code
Some GPIO related calls were not being checked for error.

This patch fixes coverity issue 236647.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-26 18:40:08 -04:00
Gerard Marull-Paretas 09048f843a drivers: sensor: sgp40: fix humidity formula
Fix the formula used to compute RH/ticks formula according to the Table
9 of the datasheet.

This patch also fixes coverity issue 238360.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-26 18:40:08 -04:00
Gerard Marull-Paretas 9dab2b3c5c drivers: sensor: sgp40: fix temperature formula
Fix the formula that computes T/ticks according to the details found on
Table 9 of the datasheet.

This patch fixes coverity issue 238343.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-26 18:40:08 -04:00
Aurelien Jarno 698a28663c drivers/sensor: Add basic Silabs Si7210 support
This adds basic support for the Silabs Si7210 hall effect magnetic
position and temperature sensor. It is able to get magnetic field and
temperature in the default scale of the sensor (depending on the
variant). It also supports going into sleep mode without measurements
through the device power management infrastructure.

It is most notably missing support for scale change, measurement
averaging and filtering, and alert pin configuration (threshold,
hysteris, tamper).

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-08-24 10:16:19 -05:00
Vojislav Milivojevic fcfb1d9872 drivers: sensors: fix of sensor channel get for z axis
the correct value is returned when using sensor channel get function to
read z-axis value

Signed-off-by: Vojislav Milivojevic <milivojevicvoja@yahoo.com>
2021-08-24 09:40:26 -05:00
Leonard Pollak d6eb80ac27 drivers: sensor: INA219: added support
This adds support for the TI INA219 Zero-Drift, Bidirectional
Current/Power Monitor with I2C Interface

Signed-off-by: Leonard Pollak <leonardp@tr-host.de>
2021-08-23 10:32:07 -05:00
Daniel Leung ab87df9f75 sensor: grove: fix cmake empty library warning
When there is no grove sensor driver enabled, cmake warns
that the library has no sources. Fix that by adding
a new kconfig to be used by CMake to selectively
include the grove directory.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-18 19:08:41 -05:00
Daniel Leung e4da47ca8f drivers: sensor: fix cmake empty library warning
When there is no sensor driver enabled, cmake warns that
the library has no sources. Fix that by wrapping cmake
library instructions inside kconfig.

Fixes #37765

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-18 19:08:41 -05:00
Alexander Wachter 3262eb416f drivers: sensors: tmp116: Use compile time i2c device
Use the compile-time devictree macro to obtain the i2c dev.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2021-08-18 09:27:29 -05:00
Alexander Wachter 704ec188f2 drivers: sensors: tmp112: Allow multiple instances
Allow to instanciate multiple instance.
Use compile-time defined i2c device instance.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2021-08-18 09:27:29 -05:00
Martí Bolívar f78d4be329 dts: fix 'grove,foo' compatibles by using 'seeed,grove-foo'
Rename:

- grove,light to seeed,grove-light
- grove,temperature to seeed,grove-temperature

The "grove" brand applies to a family of products by Seeed (sic):

https://www.seeedstudio.com/category/Grove-c-1003.html

Therefore we should use the existing vendor seeed.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-17 17:51:57 -04:00
Martí Bolívar 98f43ba0be dts: fix max30101 compatible
It should be "maxim,max30101", because the vendor prefix for this
company is "maxim", not "max".

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-17 17:51:57 -04:00
Leonard Pollak 9a59d30517 drivers: sensor: SHT4X: convert to i2c_dt_spec
Convert sht4x driver to `struct i2c_dt_spec`.

Signed-off-by: Leonard Pollak <leonardp@tr-host.de>
2021-08-17 12:40:17 -05:00
Leonard Pollak adc5604c5c drivers: sensor: SGP40: convert to i2c_dt_spec
Convert sgp40 driver to `struct i2c_dt_spec`.

Signed-off-by: Leonard Pollak <leonardp@tr-host.de>
2021-08-17 12:40:17 -05:00
Daniel Leung bcdff8220a drivers: sensors: build as static libraries
Instead of putting object files inside libzephyr.a, simply
build a separate static library for the top level of sensor
drivers. Also, for those that were not building its own
static library, make them do so as majority of sensor
drivers are building their own static libraries.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-17 06:06:03 -04:00
Christopher Friedt 5c7f395f8f Revert "include: driver: sensor: add tank level channel in units of percent"
This reverts commit f51aec4307.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-08-10 09:44:48 -05:00
Jordan Yates 3682eb9714 sensor: bmi160: convert to _dt_spec
Convert bmi160 driver to use `spi_dt_spec`, `i2c_dt_spec` and
`gpio_dt_spec`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-09 22:40:18 -04:00
Jordan Yates 757bb42d5f sensor: bme280: convert to _dt_spec
Convert bme280 driver to use `spi_dt_spec` and `i2c_dt_spec`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-09 22:40:18 -04:00
Jordan Yates 75682f7d0e sensor: adxl372: convert to _dt_spec
Convert adxl372 driver to use `spi_dt_spec` and `gpio_dt_spec`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-09 22:40:18 -04:00
Jordan Yates 534bfbda8a sensor: adxl362: convert to _dt_spec
Convert adxl362 driver to use `spi_dt_spec` and `gpio_dt_spec`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-09 22:40:18 -04:00
Henrik Brix Andersen eb616130d7 drivers: sensor: add driver for the LM77 temperature sensor
Add sensor driver for the LM77 temperature sensor.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-08-09 19:50:29 -04:00
Nick Ward f51aec4307 include: driver: sensor: add tank level channel in units of percent
Provides an enum for tank level sensor drivers.

Signed-off-by: Nick Ward <nick.ward@setec.com.au>
2021-08-09 16:24:50 -04:00
Aurelien Jarno 117090c1a2 drivers: sensors: ti_hdc20xx: add support for DRDY/INT pin
Add optional support for the DRDY/INT pin. This avoids waiting a fixed
time for the temperature and humidity conversion to finish.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-08-09 11:32:43 -04:00
Aurelien Jarno 28f9a7614b drivers: sensors: ti_hdc20xx: reset the device during init
Soft-reset the TI HDC20XX sensor during init to bring all registers in a
known and consistent state.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-08-09 11:32:43 -04:00
Aurelien Jarno 28e7cfd037 drivers: sensors: ti_hdc20xx: convert to i2c_dt_spec
Convert ti_hdc20xx temperature and humidity sensor driver to
`i2c_dt_spec`.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-08-09 11:32:43 -04:00
Aurelien Jarno 7ebae7f569 drivers: sensors: ti_hdc20xx: use uint16_t variables to store the samples
The temperature and humidity samples are 16 bits long and can therefore
fit in a uint16_t variable. This save 4 bytes of RAM.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-08-09 11:32:43 -04:00
Gerard Marull-Paretas 7ccc1a41bc pm: use actions for device PM control
Instead of passing target states, use actions for device PM control.
Actions represent better the meaning of the callback argument.
Furthermore, they are more future proof as they can be suitable for
other PM actions that have no direct mapping to a state. If we compare
with Linux, we could have a multi-stage suspend/resume. Such scenario
would not have a good mapping when using target states.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 6d273f49bd pm: fix incorrect usages of PM_DEVICE_STATE_OFF
According to the documentation the OFF state has to be used when the
devices is fully turned off, ie, power removed. Most drivers were using
a sort of fall-through for all non-active states, leading to behaviors
not following the specifications.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 495672ab62 pm: cleanup pm control callback implementations
- Return -ENOTSUP if the requested state is not supported
- Remove redundant "noop style" functions.
- Use switch everywhere to handle requested state (not necessary in all
  drivers, but better take off with consistency in place after current
  changes).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas d41dadc569 pm: rename PM_DEVICE_STATE_SUSPEND to PM_DEVICE_STATE_SUSPENDED
The verb tense for the suspended state was not consistent with other
states. The likely reason: state was being used as a command/action.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 56a35e5682 pm: converge to suspend state for low power modes
The difference between low power and suspend states is a thin blur line
that is is not clear and most drivers have used indistinctly. This patch
converges to the usage of the suspend state for low power, since
contrary to the low power state, it is used by both system and runtime
device PM. The low power state is still kept, but its future is unclear
and needs some discussion.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 920f30cc0e pm: simplify state change check logic
The device PM control function will only be called if the requested
state is different from the current one. A significant amount of drivers
were checking for state changes, now unnecessary. This patch removes all
this redundant logic.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 11eef4d8c8 pm: device: remove pointer usage for state
Since the state is no longer modified by the device PM callback, just
use the state value.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 9e7d545bb4 pm: device: remove ctrl_command callback argument
The ctrl_command is not used anymore, so remove it from the callback
signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas da0ff4ae46 pm: device: remove usage of ctrl_command
The callback is now invoked to set the device PM state in all cases, so
the usage of ctrl_command is redundant.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas c2cf1ad203 pm: device: remove usage of local states
The device PM subsystem already holds the device state, so there is no
need to keep duplicates inside the device. The pm_device_state_get has
been refactored to just return the device state. Note that this is still
not safe, but the same applied to the previous implementation. This
problem will be addressed later.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Jordan Yates 6cf6d515b1 sensor: sht3xd: convert to i2c_dt_spec
Convert sht3xd driver to `struct i2c_dt_spec` as a demonstration.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-03 19:05:14 -04:00
Jordan Yates 7bdb22941c sensor: bme680: convert to i2c_dt_spec
Convert bme680 driver to `struct i2c_dt_spec` as a demonstration.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-03 19:05:14 -04:00
Efrain Calderon 5274aa5dc2 drivers: bme280: fetch data after measurement is done
After powering-on the sensor, and before every measurement, it loads
the NMV. We must wait until this process is completed otherwise
we will read weird values.
Since it was observed that the time may be a bit long after a cold
start, it is more convinient to just wait until the sensor iready,
without a timout.

Signed-off-by: Efrain Calderon <efrain.calderon@aquarobur.com>
2021-07-30 20:15:56 -04:00
Efrain Calderon c009450d44 drivers: bme280: do soft reset after boot
To ensure that we have the same behaviour with a power cycle
and by pressing the reset button, we can perform soft reset
in `bme280_chip_init()`.

Signed-off-by: Efrain Calderon <efrain.calderon@aquarobur.com>
2021-07-30 20:15:56 -04:00
Efrain Calderon 86e656b640 drivers: bme280: fix: build broken after PM changes
The driver did not build with PM_DEVICE enabled.
commit to blame: cc2f0e9c08

Signed-off-by: Efrain Calderon <efrain.calderon@aquarobur.com>
2021-07-30 20:15:56 -04:00
Gerard Marull-Paretas 70322853a8 pm: device: move device busy APIs to pm subsystem
The following device busy APIs:

- device_busy_set()
- device_busy_clear()
- device_busy_check()
- device_any_busy_check()

were used for device PM, so they have been moved to the pm subsystem.
This means they are now prefixed with `pm_` and are defined in
`pm/device.h`.

If device PM is not enabled dummy functions are now provided that do
nothing or return `-ENOSYS`, meaning that the functionality is not
available.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-30 09:28:42 -04:00
Aurelien Jarno 9ecdd78961 drivers: sensors: ti_hdc20xx: update temperature conversion formula
TI recently released a new version of the HDC2080 datasheet, which
slightly update the temperature conversion formula, with a temperature
offset of -40.5°C instead of -40°C. Adjust the code accordingly.

In addition the datasheet also describes a voltage dependent
compensation of -0.08°C/V above 1.8V, however it's not something easily
doable with the current sensor framework, so just ignore that part.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-07-30 07:06:18 -04:00
Sam Hurst 1382d64ed5 drivers: sensor: Add driver for TI INA23x
This driver supports the TI INA230 and INA231 Bidirectional Current
and Power Monitors. The devices work on the I2C interface and are
created from DT nodes with a compatible property matching "ti,ina23x".

The following datasheets were referenced while developing the driver:
https://www.ti.com/product/INA230
https://www.ti.com/product/INA231

Twister passed:
twister -T tests/drivers/build_all/sensor/

Testing was performed on the stm32g071b_disco board with the following:
Load:    ~170 ohms
Voltage: 5V

Measured Values:
Voltage: 5.1 V
Current: 0.032 A
Power:   0.157 W

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2021-07-27 17:59:23 -04:00
Piotr Mienkowski 1d199ca5ac drivers: qdec_sam: align naming of TcChannel in TC
Change naming of TC_CHANNEL to TcChannel in Tc struct to align with
a new convention used by samv71, samv71b series.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2021-07-26 05:13:40 -04:00
Leonard Pollak 2d0fd2554a drivers: sensor: SHT4X Added support
This adds support for Sensirion's SHT4X temperature and
humidity sensor.

Signed-off-by: Leonard Pollak <leonardp@tr-host.de>
2021-07-22 10:17:13 -04:00
Leonard Pollak 0d7cb32c58 drivers: sensor: SGP40 Added support
This adds support for Sensirion's SGP40 multipixel gas sensor.

Signed-off-by: Leonard Pollak <leonardp@tr-host.de>
2021-07-22 10:17:13 -04:00
Luka Lopotar 7b67e239fe sensor: bq274xx: Add power management and shutdown mode
Add support for power management and the shutdown mode for bq274xx fuel
gauge sensor. This now allows boards that have any kind of low power
mode to turn on or off the sensor.

Tested on a Company's custom board with bq27421 sensor on it.

Signed-off-by: Luka Lopotar <luka.lopotar@greyp.com>
2021-07-22 06:21:25 -04:00
Alexander Wachter 2daad1dab9 drivers: sensors: Add driver for LM75
This commit adds a driver implementation for the LM75 I2C temperature
sensor.

Signed-off-by: Alexander Wachter <alexander.wachter@leica-geosystems.com>
2021-07-20 16:15:32 -05:00
Armando Visconti 59812961f2 drivers/sensor: lis2mdl: Fix errors when CONFIG_PM_DEVICE=y
Fix a couple of issues related to Power Management:

    1. A build error because 'dev' was used even if not declared
       in the caller routine scope
    2. The lis2mdl power management init specific routine was
       not declared in in the device instance definition

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-07-15 11:50:00 -04:00
Thomas Stranger d25d385145 drivers: sensor: sht3xd: use sys functions for crc and byteorder
replace custom crc8 with sys/crc8
use sys_put/sys_get helpers for byteorder specific operations

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2021-07-15 06:44:34 -04:00
Thomas Stranger 22c8d9973b drivers: sensor: shtcx: add driver supporting shtc1 and shtc3
Add driver for sensirion consumer humidity sensor line.
Supports shtc1 and shtc3, but only shtc3 is tested.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2021-07-15 06:44:34 -04:00
Gerard Marull-Paretas 26ad8376bd pm: remove callback from control function
The callback is not used anymore, so just delete it from the pm_control
callback signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-13 09:36:45 -04:00
Gerard Marull-Paretas 217e610d8f pm: remove redundant callback usage
the device PM callback is not used anymore by the device PM subsystem,
so remove it from all drivers/tests using it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-13 09:36:45 -04:00
Aurelien Jarno 0d543f1742 drivers/sensor: Add basic TI HDC20XX support
Add basic support for TI HDC20XX series (e.g. HDC2010, HDC2021, HDC2022,
HDC2080). It is able to get temperature and humidity in the default
14-bit resolution. Triggers, resolution selection, interrupt line, auto
measurement mode are currently not supported.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-07-09 07:48:15 -04:00
Gerard Marull-Paretas cc2f0e9c08 pm: use enum for device PM states
Move all PM_DEVICE_STATE_* definitions to an enum. The
PM_DEVICE_STATE_SET and PM_DEVICE_STATE_GET definitions have been kept
out of the enum since they do not represent any state. However, their
name has not been changed since they will be removed soon.

All drivers and tests have been adjusted accordingly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-07 14:13:12 -04:00
Martí Bolívar bd8afe9365 drivers: sensor: clean up zephyr_library calls
In drivers/sensor/CMakeLists.txt, we have various lines like this:

    add_subdirectory_ifdef(CONFIG_FOO foo)

Then drivers/sensor/foo/CMakeLists.txt says:

    zephyr_library()
    zephyr_library_sources_ifdef(CONFIG_FOO foo.c)

This is redundant; the foo/CMakeLists.txt won't be added to the build
system unless CONFIG_FOO=y in the first place, so there's no need for
extra boilerplate testing it again.

Remove all these unnecessary instances in each sensor driver's
CMakeLists.txt using this pattern:

    zephyr_library()
    zephyr_library_sources(foo.c)

In a couple of places, the '.c' extension is missing. Add them in for
consistency when that happens.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-06-30 09:36:33 -04:00
Armando Visconti fa423d30a2 drivers/sensor: lis2dw12: Preserve APIs error code
Return the same error code returned by HAL i/f APIs.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-29 11:31:06 -04:00
Armando Visconti 40f843ae54 drivers/sensor: lis2dw12: Set tap triggers only if detection is on
Set single/double tap triggers only if tap detection is enabled.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-29 11:31:06 -04:00
Armando Visconti de0ff0c354 drivers/sensor: lis2dw12: Fix the logic to set TAP interrupt
The lis2dw12 sensor can generate the TAP interrupt only on INT1,
while DRDY can be generated on both. The int-pin DT property
specifiy on which pin the DRDY (and not the TAP) can be generated.

This commit fix the way the trigger is set: first the driver checks
the trigger type (DRDY or TAP), then it uses the int-pin information
only in DRDY case but allows setting TAP regardless of int-pin (it
always routes it on INT1).

The previous code was first checking int-pin: if it was INT2 then
the driver refused setting TAP triggers.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-29 11:31:06 -04:00
Armando Visconti 9217e37901 drivers/sensor: lis2dw12: Add multi-instance support
This commit aligns lis2dw12 sensor driver to latest multi
instance sensor driver model.

In particular it makes use of the stmemsc common routines
and move ctx handler inside struct config, so that the
bus_init routines can be totally avoided.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-29 11:31:06 -04:00
Armando Visconti 77b74f1b85 drivers/sensor: lis2dw12: Remove odr values from Kconfig
Remove all odr values from Kconfig and always init it
at 12.5Hz. It is responsibility of application to set
the rate to a different value using SENSOR_ATTR_SAMPLING_FREQUENCY.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-29 11:31:06 -04:00
Armando Visconti 344e06025d drivers/sensor: lis2dw12: Move range Kconfig property into dts
Converts lis2dw12 range options (2g, 4g, 8g, 16g) from Kconfigs
to Device Tree.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-29 11:31:06 -04:00
Armando Visconti a783a062f8 drivers/sensor: lis2dw12: Move power Kconfig property into dts
Move lis2dw12 power-mode option from Kconfigs to Device Tree.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-29 11:31:06 -04:00
Armando Visconti 56ce558094 drivers/sensor: lis2dw12: Move trigger pulse Kconfig property into DT
Move lis2dw12 trigger pulse configurations from Kconfigs to Device Tree.
Moreover the dts properties have been renamed as 'tap', which sounds a
better name to immediately catch the feature behind it. Since tap
threshold cannot be zero, this value (which is the default in dts
binding) is used to enable/disable the device feature per each axis.
The event can be generated on INT1 only.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-29 11:31:06 -04:00
Armando Visconti 8609733e76 drivers/sensor: lis2dw12: use gpio_dt_spec oriented macros
Use gpio_dt_spec structure (and related APIs) in config for configuring
the gpio used for drdy and pulse interrupts.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-29 11:31:06 -04:00
Armando Visconti 351b28e122 drivers/sensor: lis2dw12: move int-pin in DTS binding
Take the int-pin information (i.e. what pin between INT1
and INT2 the drdy is attached to) directly from DT.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-29 11:31:06 -04:00
Aurelien Jarno b94edd2393 drivers/sensor: ms5607: fix compensation for temperature < 20C
When the temperature is lower than 20C, adc_temperature is smaller than
(data->t_ref << 8), which should yield a negative value for dT. While dT
and adc_temperature are correctly declared as signed, the subtrahend is
wrongly casted to unsigned, yielding insanely high temperature values.
Fix that by casting it to int32_t instead of uint32_t.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-06-28 11:53:56 -04:00
Fabio Baltieri 3af832868c drivers: npcx: convert NPCX drivers clock client to DEVICE_DT_GET
Convert the various device_get_binding() calls used to get the device
clock node to use DEVICE_DT_GET. The latter is processed at link time,
so it should be a bit more efficient.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2021-06-27 23:02:39 -04:00
Kumar Gala 28e4af6176 drivers: sensor: iis2iclx: Fix compile warning
Fix compile warning with clang and extraneous parentheses

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-21 10:08:24 -05:00
Kumar Gala deb689f0f9 drivers: sensor: max17055: Fix compile error with clang
Since we are writing a register it makes more sense for the type
to be unsigned.  This hopefully address a compile warning we get
with clang:

error: implicit conversion from 'int' to 'int16_t' (aka 'short')
changes value from 32768 to -32768 [-Werror,-Wconstant-conversion]

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-21 10:08:24 -05:00
Kumar Gala 83cfcd41fc drivers: sensor: icm42605: Fix build issues
If CONFIG_ICM42605_TRIGGER is not set the driver doesn't build.  There
are a few places that need ifdefs based on CONFIG_ICM42605_TRIGGER for
the driver to build correctly.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-21 10:08:24 -05:00
Aurelien Jarno 9d0169deaf drivers/sensor: ms5607: Add I2C support
Add I2C support to the MS5607 driver, which mostly consist in adding the
I2C transfer functions.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-06-18 11:23:07 +02:00
Aurelien Jarno 593ec46c0a drivers/sensor: ms5607: Add multi-instance support
Add multi-instance support to the MS5607 driver. This is needed to
easily add I2C support later. It also simplifies a bit the driver
initialisation by using more static values.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2021-06-18 11:23:07 +02:00
Armando Visconti 098a5f51aa drivers/sensor: Clean unused axis structures
axis1bit16 and axis3bit16 unions are no longer used
and can be deleted from all .h files that are referencing
them.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-18 11:22:58 +02:00
Armando Visconti 7f9e3af932 modules/hal_st: Align sensor drivers to stmemsc HAL i/f v2.00
Align all sensor drivers that are using stmemsc (STdC) HAL i/f
to new APIs of stmemsc v2.00.

Requires https://github.com/zephyrproject-rtos/hal_st/pull/7
(merged as 575de9d461aa6f430cf62c58a053675377e700f3)

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-18 11:22:58 +02:00
Flavio Ceolin 0ea0344328 drivers: fxos8700: Remove unnecessary cast
Change a variable type in fxos8700_set_odr to avoid unnecessary cast.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-06-16 11:13:45 -05:00
Flavio Ceolin 54d33990f3 drivers: fxos8700: Make internal function static
fxos8700_set_odr is used only inside this file and don't need to be
exported.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-06-16 11:13:45 -05:00
Flavio Ceolin e31d2ab6b4 drivers: fxos8700: Fix sensor_attr_set behavior
It is necessary to put the device in standby to change the contents of
CTRL_REG1. This register is used to change the sampling frequency.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-06-16 11:13:45 -05:00
Pieter De Gendt 46643dcb05 sensor: bq274xx: fix sleep logic when polling after softreset
The bq274xx fuel gauge does a softreset when configuring, after
which the device is polled and sealed. However the sleep logic
was inverted so the poll became blocking.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2021-06-16 10:39:44 +02:00
Piotr Mienkowski aaf64e0bdf soc: atmel_sam: Add _INST to ATMEL_SAM_DT_PIN* macros
The macros are used to get the pin(s) of a given driver instance. Add
_INST prefix to match convention used by the devicetree.h. The original
macros can now be used to obtain pin(s) of an arbitrary device instance
identified by the nodelabel.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2021-06-14 09:50:41 -05:00
Armando Visconti fcb0953309 drivers/sensor: lis2mdl: Add multi-instance support
Add multi-instance support and make use of the stmemsc i2c/spi
read/write routine that has been introduced to simplify the ST
sensor drivers code.

Moreover, move spi-full-duplex property from Kconfig inside Device
Tree, so that each LIS2MDL instance can be configured selectively
in accordance to how it is used in h/w.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-04 16:29:45 -05:00
Guillaume Lager 42835a780a drivers: sensor: tmp116: Check that a new value is available
Add a check to ensure that the conversion is complete before reading

Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
2021-06-04 16:18:33 -05:00
Guillaume Lager c40f0ec108 drivers: sensor: tmp116: Fix compilation error
commit d31ed3be04 enabled multiple
instances but when multiple instances are actually used the code does
not compile

Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
2021-06-04 16:18:33 -05:00
Anas Nashif 24bd45b287 pm: do not use deprecate Kconfig
CONFIG_DEVICE_POWER_MANAGEMENT is deprecated, use CONFIG_PM_DEVICE
instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-06-04 12:19:38 -05:00
Gerard Marull-Paretas 45a6de6804 drivers: fix pm callback signature
For some reason a few drivers were not converted to the new device PM
callback signature. The reason may be because the device PM part is
compiled only when CONFIG_PM_DEVICE=y, a condition not enabled in CI by
default.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-06-04 08:16:49 -05:00
Armando Visconti e879be1dbb drivers/sensor: lis2mdl: Fix temperature sample handling
The lis2mdl temperature samples work with a level of 25 Celsius.
When temperature goes below that level the samples become negative
and there was an issue in properly propagating the sign.

Fix #35910

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-03 09:44:31 -05:00
Armando Visconti 4e8c809d74 drivers/sensor: lps22hh: Fix the raw to kPa sample conversion
The lps22hh 24 bit raw sample is left aligned, which means that
it needs to be right-shifted by 8 before applying conversion.
Moreover the conversion has been simplified for clarity.

Fix #35871

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-03 09:30:42 -05:00
Armando Visconti 282a644b0e drivers/sensor: lis2dh: use gpio_dt_spec oriented macros
Use gpio_dt_spec structure and related macros for both drdy
and AnyMotion interrupts, to have a more compat, readable and
safe code. Moreover, skip setting DRDY or AnyMotion trigger
from application if the corresponding irq-gpios has not been set.

(This commit also fixes #34794)

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-06-02 08:51:14 -05:00
Piotr Mienkowski a323a41fc2 sensor: qdec_sam: use compatible atmel,sam-tc-qdec
Change the drivers's compatible from atmel,sam-tc to atmel,sam-tc-qdec.
The atmel,sam-tc should be reserved for the future counter driver.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2021-05-26 18:13:10 -05:00
Armando Visconti 468c553190 drivers/sensor: iis2iclx: (FIX) enable interrupt selectively
(same considerations as commit 2f01479b)
In a multi-instance driver it may happen that on some h/w
one device should use interrupts and a second device should use
polling mode. So, CONFIG_IIS2ICLX_TRIGGER is not enough to discriminmate
if interrupt inizialization routine should be called or not; the choice
is now based whether the "irq-gpios" property is present in the DT
for that particular instance or not.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-05-20 17:55:08 -04:00
Armando Visconti 1f851bc268 drivers/sensor: lsm6dso: use gpio_dt_spec oriented macros
Use gpio_pin_configure_dt() and gpio_pin_interrupt_configure_dt()
for drdy_gpio: they result in a more readable code.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-05-20 17:55:08 -04:00
Alexander Wachter 1c792fb0b5 drivers: sensors: sbs-gauge: add CHAN_ALL to fetch
Add the SENSORS_CHAN_ALL to the fetch function.

Signed-off-by: Alexander Wachter <alexander.wachter@leica-geosystems.com>
2021-05-19 08:56:21 -05:00
Armando Visconti b430b8d6a6 drivers/sensor: iis2iclx: Fix shub for multi-instance case
In case of multi-instance the driver tries to discover whether
there are devices attached to SDx/SCx sensorhub bus. If not it
just turns the shub_inited variable (inside data structure) to false
and skips doing any further sensorhub related action for that
particular IIS2ICLX device instance, regardless the fact that the
macro CONFIG_IIS2ICLC_SENSORHUB is enabled.

Moreover, the info found during the enumeration process for a
particular instance (number and types of attached devices) must be
saved inside the per-instance data structure, so that more than one
IIS2ICLX device can be used as a sensorhub without interfering with
the others.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-05-18 11:18:08 -05:00
Armando Visconti 1325525e3b drivers/sensor: lsm6dso: Fix shub for multi-instance case
In case of multi-instance the driver tries to discover whether
there are devices attached to SDx/SCx sensorhub bus. If not it
just turns the shub_inited variable (inside data structure) to false
and skips doing any further sensorhub related action for that
particular LSM6DSO device instance, regardless the fact that the macro
CONFIG_LSM6DSO_SENSORHUB is enabled.

Moreover, the info found during the enumeration process for a
particular instance (number and types of attached devices) must be
saved inside the per-instance data structure, so that more than one
LSM6DSO device can be used as a sensorhub without interfering with
the others.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-05-18 11:18:08 -05:00
Armando Visconti 24f345ee3e drivers/sensor: iis2mdc: use gpio_dt_spec oriented macros
Use gpio_pin_configure_dt() and gpio_pin_interrupt_configure_dt()
for drdy_gpio: they result in a more readable code.

Moreover, this commit includes also the fix for PR #35156
(i.e. CID 235979, add check for gpio_pin_configure() return val).

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-05-12 23:34:46 -05:00
Eug Krashtan 05d798e3a9 drivers: sensor: STM32 die temperature driver
STM32 internal temperature sensor driver.
This sensor can be used to measure the temperature of the CPU
and its surroundings.

Signed-off-by: Eug Krashtan <eug.krashtan@gmail.com>
2021-05-08 10:18:09 -05:00
Armando Visconti 2f01479b56 drivers/sensor: lsm6dso: (FIX) enable interrupt selectively
In a multi-instance driver it may happen that on some h/w
one device should use interrupts and a second device should use
polling mode. So, CONFIG_LSM6DSO_TRIGGER is not enough to discriminmate
if interrupt inizialization routine should be called or not; the choice
is now based whether the "irq-gpios" property is present in the DT
for that particular instance or not.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-05-07 20:53:47 -04:00
Armando Visconti cacee210ad drivers/sensor: lsm6dso: move ctx structure inside struct config
Move ctx structure from struct data to struct config, so that
it can be filled at compile time and we could get rid of the bus
init routines.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-05-07 20:53:47 -04:00
Armando Visconti 99308c514a drivers/sensor: iis2iclx: clean unused leftovers
Remove few unused declarations.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-05-07 20:53:47 -04:00
Flavio Ceolin 0c607adb63 pm: device: Align state names with system states
Change device pm states to the same pattern used by system power
management.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 18:35:12 -04:00
Flavio Ceolin 7eba310220 power: device: void *context -> uint32_t *state
The context parameter used across device power management is
actually the power state. Just use it and avoid a lot of
unnecessary casts.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
MORGER Patrick 0e1d16bf03 drivers: sensors: smart-battery with SBS 1.1 compliant fuel gauge
Implementation of a SBS 1.1 compliant fuel gauge driver

Signed-off-by: MORGER Patrick <patrick.morger@leica-geosystems.com>
2021-05-07 07:55:23 -05:00
Gerard Marull-Paretas 56f1a8ce98 pm: rename PM_DEVICE_GET/SET_POWER_STATE to PM_DEVICE_STATE_GET/SET
Adjust name to be consistent with device PM naming conventions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas dbf46b3815 pm: rename device_pm_cb to pm_device_cb
Prefix all device PM functions/data structures with pm.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas 2c7b763e47 pm: replace DEVICE_PM_* states with PM_DEVICE_*
Prefix device PM states with PM.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Kumar Gala 293802c407 sensor: max17262: Fix CI build failure
device_pm_control_nop has been marked deprecated so we get a CI
build error due to its use.  Replace with NULL to fix the issue.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-05-05 14:13:21 -04:00
Matija Tudan d2c503f202 sensor: add MAX17262 fuel gauge driver and sample application
The MAX17262 is an ultra-low power fuel-gauge IC which implements the
Maxim ModelGauge m5 algorithm. The IC monitors a single-cell battery
pack and supports internal current sensing for up to 3.1A pulse
current. The IC provides best performance for batteries with 100mAhr
to 6Ahr capacity.

Signed-off-by: Matija Tudan <mtudan@mobilisis.hr>
2021-05-05 15:54:29 +02:00
Armando Visconti f0332eb5d3 drivers/sensor: iis2dlpc: use common stmemsc routine
This commit aligns iis2dlpc sensor driver to latest multi
instance sensor driver model.

In particular:

    1. make use of some few DT helpers:
        - get bus devices with DEVICE_DT_GET
        - get SPI information with SPI_CONFIG_DT_INST
        - get drdy gpios with GPIO_DT_SPEC_GET

    2. make use of the stmemsc common routines and move ctx
       handler inside struct config, so that the bus_init
       routines can be totally avoided.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-05-04 22:41:56 -04:00
Gerard Marull-Paretas bf7a396538 drivers: sensor: remove usage of device_pm_control_nop
device_pm_control_nop is now deprecated in favour of NULL.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 15:30:03 -04:00
Gerard Marull-Paretas b735f5eb15 drivers: sensor: iis2iclx: use GPIO_DT_SPEC_INST_GET
Replace GPIO_DT_SPEC_GET for GPIO_DT_SPEC_INST_GET.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 18:17:23 +02:00
Gerard Marull-Paretas 87a8119105 drivers: sensor: iis2mdc: use GPIO_DT_SPEC_INST_GET
Replace GPIO_DT_SPEC_GET for GPIO_DT_SPEC_INST_GET.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 18:17:23 +02:00
Gerard Marull-Paretas c065738d6c drivers: sensor: lsm6dso: use GPIO_DT_SPEC_INST_GET
Replace GPIO_DT_SPEC_GET for GPIO_DT_SPEC_INST_GET.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 18:17:23 +02:00
Gerard Marull-Paretas ba5511ea1f drivers: sensor: bmp388: use GPIO_DT_SPEC_INST_GET
Replace GPIO_DT_SPEC_GET for GPIO_DT_SPEC_INST_GET.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 18:17:23 +02:00
Armando Visconti 8717654c1d drivers/sensor: iis2iclx: move ctx structure inside config
Move ctx structure from struct data to struct config, so that
it can be filled at compile time and we could get rid of the bus
init routines.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-04-21 20:41:46 -04:00
Armando Visconti 6fa0d01c5f drivers/sensor: iis2iclx: Use DT helper for gpio_drdy
Use gpio_dt_spec structure and populate it using GPIO_DT_SPEC_GET
macro.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-04-21 20:41:46 -04:00
Armando Visconti 2846283f84 drivers/sensor: iis2mdc: (FIX) Remove SPI Full Duplex mode
The IIS2MDC sensor does not support the SPI 4 wires. So, remove
it from the driver.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-04-16 12:21:11 +02:00
Armando Visconti 4df7af583a drivers/sensor: iis2mdc: Add multi-instance support
Make this driver multi-instance and use the new API.
This commit makes use of the new helpers introduced in #30536.

In particular:
    - get bus devices with DEVICE_DT_GET
    - get SPI information with SPI_CONFIG_DT_INST
    - get drdy gpios with GPIO_DT_SPEC_GET

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-04-16 12:21:11 +02:00
Emil Obalski cd465ff8c4 drivers: sensors: Support XYZ accel get for adxl362.
Add a possibility to get values of accelerometer measurement for
all 3 axis of accelerometer with one channel_get().

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2021-04-06 18:46:03 -05:00
Armando Visconti c4b35c1d36 drivers/sensor: lsm6dso: Add multi-instance support
Make this driver multi-instance and use the new API.

This commit makes use of some DT macro helpers
In particular:
    - get bus devices with DEVICE_DT_GET
    - get SPI information with SPI_CONFIG_DT_INST
    - get drdy gpios with GPIO_DT_SPEC_GET

Moreover the driver is now using the stmemsc common
routines as requested in issue #33440 and it avoids
the unnecessary declaration of both ctx_i2c and ctx_spi
in the data structure.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-04-06 15:34:01 +02:00
Armando Visconti 36eceba7e4 drivers/sensor: lsm6dso: move int-pin in DTS binding
Take the int-pin information (i.e. what pin between INT1
and INT2 the drdy is attached to) directly from DT.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-04-06 15:34:01 +02:00
Hayden Ball 64995e2a54 max17055: Set battery parameters from device tree
Currently the MAX17055 driver assumes that a battery matching the
default characteristics is used.

This change allows battery characteristics to be specified in device
tree and writes them to the MAX17055 on initialization.

Existing default values are maintained for backwards compatibility.

Initialization routine taken from MAX17055 Software Implementation
Guide, document UG6365.

Signed-off-by: Hayden Ball <hayden@playerdata.co.uk>
2021-04-05 15:29:00 -05:00
Corey Wharton e3c94d381a driver: sensor: Add support for BMP388 pressure sensor
Adds support for Bosch's BMP388 pressure sensors connected either
by a I2C or SPI bus.

Signed-off-by: Corey Wharton <coreyw7@fb.com>
2021-04-02 08:06:46 -05:00
Armando Visconti 8b7a1a78c0 drivers/sensor: iis2iclx: Fix sensorhub building
The iis2iclx driver was not building correctly when
CONFIG_IIS2ICLX_SENSORHUB was enabled.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-04-01 15:34:36 -05:00
Armando Visconti aae2161542 drivers/sensor: iis2iclx: avoid using both ctx_i2c and ctx_spi
The STMEMSC HAL i/f requires every driver using it to define
for each instance a stmdev_ctx_t structure, which is used to
export the hardware specific APIs to handle i2c and spi busses
operations. Since this structure is bus agnostic, there is no
need to declare it twice for both i2c and spi. Instead, declare
only one structure, which will be populated either with i2c APIs
or with spi APIs according to where that particular instance is
declared inside the DT.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-04-01 15:34:36 -05:00
Armando Visconti 9e50268c96 drivers/sensor: iis2iclx: Make use of stmemsc common routines
Make use of the stmemsc i2c/spi read/write routine that
has been introduced to simplify the ST sensor drivers code.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-04-01 15:34:36 -05:00
Armando Visconti 253cbfd0aa drivers/sensor: stmemsc: Add common i2c/spi read/write routines
Add common i2c/spi read/write routines for the benefit of those
ST sensor drivers who make use of the stmemsc HAL i/f.

Add generic stmemsc_cfg_i2c and stmemsc_cfg_spi structures which
contains all relevant information required by i2c/spi low level
routines, such as:

    - the pointer to the bus device
    - the I2C slave address (if instance is on I2C bus)
    - the spi_config structure (if istance is on SPI bus)

This level of abstraction allows the re-use of the i2c/spi read/write
routines among all stmemsc based sensor driver without the need to
reference the specific sensor data and or config structures.

The STMEMSC HAL source code is located here:
     zephyrproject-rtos/modules/hal/st/sensor/stmemsc/

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-04-01 15:34:36 -05:00
Masoud Shiroei ef2a590281 drivers: sensor: lis2mdl: Add single mode operation
Support single mode operation by enabling it and
making the driver to use the interrupt to findout
when the data is ready for fetch. The sample fetch
will be blocked for a specified maximum time untill
the interrupt happens.

* Make operation mode configurable in DTS file
* Make offset cancellation configurable in DTS file
* Use single common .yaml file for both i2c and spi
* Store above configurations in dev->config_info

Signed-off-by: Masoud Shiroei <masoud.shiroei@assaabloy.com>
2021-03-31 08:08:35 -04:00
Masoud Shiroei 02238adf2a drivers: sensor: lis2mdl: Fix all log messages
Remove unnecessary "\n" at the end of logs.

Change LOG_DBG to LOG_ERR wherever is appropriate

Signed-off-by: Masoud Shiroei <masoud.shiroei@assaabloy.com>
2021-03-31 08:08:35 -04:00
JuHyun Kim b486c35bc9 driver: sensor: icm42605: Fixed Dereference afterr null check issue
Fixed Coverity CID: 219524 : Dereference after null check
For fix this issue added null check before call function pointer

Fixes #32913

Signed-off-by: JuHyun Kim <jkim@invensense.com>
2021-03-30 08:17:47 -04:00
Christian Taedcke b0b20112e8 drivers: sensor: ccs811: fix sw reset delay
Before this change, the sw reset did not work after power-on, because
I2C commands are only accepted after 20msec (t_START after power-on).

Now the 20msec delay is moved before performing the reset to ensure that
the SW reset command can be executed. An additional 2msec delay is added
after the reset (see datasheet t_START after reset).

Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
2021-03-25 16:58:42 -05:00
Steven Daglish 8f13b7860e sensor: mcp9808: Bug fix for setting resolution
Resolution currently only gets set if CONFIG_MCP9808_TRIGGER is also
set. If CONFIG_MCP9808_TRIGGER is not set, resolution gets not to '0'.

This small bug fix moves resolution to before CONFIG_MCP9808_TRIGGER is
checked, so that the resolution is changed as required.

Signed-off-by: Steven Daglish <s.c.daglish@gmail.com>
2021-03-23 12:13:45 +01:00
Pieter De Gendt 000924c8eb sensor: bq27421: lazy configure fuel gauge
The BQ274XX driver init function performs a lot i2c transfers
that slow down booting the system. We can do this lazely on the
first sample request to speed up the boot.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2021-03-23 12:13:20 +01:00
Piotr Mienkowski f5163e2ce2 drivers: sensor: Add Atmel SAM QDEC (TC) Driver
Tested on Atmel SMART SAM E70 Xplained board

Origin: Original

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2021-03-18 10:20:17 +01:00
Igor Knippenberg 79a3d1b85a drivers: sensors: fdc2x1x: Add driver for Texas Instruments FDC2X1X
Adds support for the Texas Instruments FDC2X1X Capacitance-to-Digital
Converter for Proximity and Level Sensing Applications.

Signed-off-by: Igor Knippenberg <igor.knippenberg@gmail.com>
2021-03-17 11:35:17 +01:00
Armando Visconti de707b6870 drivers/sensor: iis2iclx: fix multi-instance using new helpers
This commit simplifies the Device Tree configuration by using
the new helpers introduced in #30536.

In particular:
    - get bus devices with DEVICE_DT_GET
    - get SPI information with SPI_CONFIG_DT_INST

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-03-10 06:11:45 -05:00
Guðni Már Gilbert 15d1ea544b drivers: sensor: bmi160: Fix bug where undersampling is not set
Fix #32774

Bit position BIT(7) is 1000 0000 in binary which is actually the
bit positon 128. BIT(7) can be used as a mask, but we need to define
the position specifically as the integer 7.

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2021-03-09 14:16:24 +01:00
James Harris b10428163a kernel: sem: add K_SEM_MAX_LIMIT
Currently there is no way to distinguish between a caller
explicitly asking for a semaphore with a limit that
happens to be `UINT_MAX` and a semaphore that just
has a limit "as large as possible".

Add `K_SEM_MAX_LIMIT`, currently defined to `UINT_MAX`, and akin
to `K_FOREVER` versus just passing some very large wait time.

In addition, the `k_sem_*` APIs were type-confused, where
the internal data structure was `uint32_t`, but the APIs took
and returned `unsigned int`. This changes the underlying data
structure to also use `unsigned int`, as changing the APIs
would be a (potentially) breaking change.

These changes are backwards-compatible, but it is strongly suggested
to take a quick scan for `k_sem_init` and `K_SEM_DEFINE` calls with
`UINT_MAX` (or `UINT32_MAX`) and replace them with `K_SEM_MAX_LIMIT`
where appropriate.

Signed-off-by: James Harris <james.harris@intel.com>
2021-03-05 08:13:53 -06:00
Kumar Gala ea98cc3c87 sensors: grove: temp: Convert to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the io-channels/adc controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 11:28:30 -06:00
Kumar Gala ae75e604d6 sensors: grove: light: Convert to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the io-channels/adc controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 11:28:30 -06:00
Kumar Gala afffb3b17e sensors: nxp_kinetis_temp: Convert to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the io-channels/adc controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-02 11:28:30 -06:00
Armando Visconti 79c709bf02 drivers/sensor: ism330dhcx: Move INT_PIN Kconfig attr into DT
Convert ism330dhcx INT_PIN attribute from Kconfigs to Device
Tree binding properties. Here int-pin has been defined as
enum with two possible values: 1 and 2.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-02-28 16:47:15 -05:00
Armando Visconti e97424e23d drivers/sensor: ism330dhcx: Move accel/gyro odr Kconfig attr into DT
Convert ism330dhcx accel and gyro odr attributes from Kconfigs to Device
Tree binding properties.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-02-28 16:47:15 -05:00
Armando Visconti 404ab86cb5 drivers/sensor: ism330dhcx: Move accel/gyro range Kconfig attr into DT
Converts ism330dhcx accel and gyro range attributes from Kconfigs to
Device Tree binding properties.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-02-28 16:47:15 -05:00
Jack Rosenthal ea9866dc86 shell: add an option for minimal default configuration
The default shell configuration has heavy flash and memory requirements,
requiring project maintainers to set many configuration options to "n"
to keep flash and memory requirements within reason.

This adds a new configuration option, CONFIG_SHELL_MINIMAL, which will
disable flash and memory heavy options by default, and allow project
maintainers to select/imply only the options they want.

On a quick test from an ARM board I'm working on, enabling this option
cut flash space requirements by ~8 KB, and memory requirements by ~1 KB.

Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
2021-02-27 10:26:33 +01:00
Adam Serbinski c70fc85909 drivers: sensors: mpu6050: add support for mpu9250
mpu9250 is a single package that contains both an mpu6050 6-axis
motion sensor and an ak8963 magnetometer. The two parts have
separate i2c addresses, yet despite the common mpu6050 component,
it has a different value in the "WHOAMI" register -- 0x71 instead
of 0x68.

This adds the additional chip id value in order to enable the use
of mpu9250.

Signed-off-by: Adam Serbinski <adam@serbinski.com>
2021-02-24 17:52:47 -06:00
Martí Bolívar 4a381fce6b drivers: bme280: clean up array usage
Use sizeof() and ARRAY_SIZE() to have more single points of truth.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-02-23 10:34:19 -05:00
Martí Bolívar bfff50127f drivers: bme280: factor out bus I/O routines
Move the SPI and I2C bus I/O bits into their own files. This makes
this driver more similar to other sensor drivers.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-02-23 10:34:19 -05:00
Martí Bolívar 8c2709e81a drivers: bme280: get dependencies straight from DT
Now that we have various convenience macros in drivers/spi.h and
device.h defined, we can resolve some longstanding TODO items in how
this driver gets a hold of the devices it depends on:

- get bus devices with DEVICE_DT_GET
- get SPI chip select information with SPI_CONFIG_DT_INST

The results are shorter on boilerplate, save RAM, and improve boot
time.

The same techniques could be reused by other device drivers.

These changes require that the SPI bus and GPIO (for device CS)
devices used to interface with the BME280 are defined in devicetree.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-02-23 10:34:19 -05:00
Bosch Sensortec aabbc52351 driver: sensor: bmi270 Added support
Added driver support for the BMI270 IMU

Signed-off-by: Bosch Sensortec <github@bosch-sensortec.com>
2021-02-22 17:58:00 -05:00
Mulin Chao 7c9d3f44f0 driver: sensor: npcx: add tachometer sensor support.
In NPCX7 series, it contains two tachometer (TACH) modules that contains
two Independent timers (counter 1 and 2). They are used to capture a
counter value when an event is detected via the external pads (TA or
TB).

The CL also includes:
— Add npcx tachometer device tree declarations.
— Zephyr sensor api implementation for tachometer.
— Enable "tach1" device in npcx7m6fb.dts for testing.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2021-02-22 17:56:19 -05:00
Henrik Brix Andersen 71d7f3f916 drivers: sensor: mcux_acmp: fix expansion-to-defined warning
Rework the checks for INPSEL, INNSEL, and C0_OFFSET_BIT presence to
avoid warnings when -Wexpansion-to-defined is enabled.

The warning was enabled in c7bc6380bd.

Fixes #32475.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-02-19 13:15:47 -05:00
Ioannis Glaropoulos 95e6da4716 drivers: sensor: nrf: fix dependencies for QDEC_NRFX
QDEC_NRFX shall depend on either HAS_HW_NRF_QDEC,
or HAS_HW_NRF_QDEC0, since in the nRF5340 Application
core definition we select HAS_HW_NRF_QDEC0 instead of
HAS_HW_NRF_QDEC.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-02-17 22:34:20 +03:00
Gerard Marull-Paretas cbc340c10c drivers: sensor: add support for MAX6675
Add support for MAX6675 cold-junction-compensated K-thermocouple to
digital converter.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2021-02-17 14:33:29 +01:00
Clotilde Sattler be170fb619 sensor/lsm6dsl: add missing ODR FIFO bit in mask
This fixes a missing bit in the registers description
which results to wrong FIFO ODR configuration
when trying to configure a FIFO ODR higher than 833Hz

Signed-off-by: Clotilde Sattler <clotilde.sattler@stimio.fr>
2021-02-16 16:33:00 -06:00
Jacob Siverskog 503f572227 drivers: sensor: icm42605: initialize variables
initialize variables to avoid or:ing with uninitialized variable.

Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
2021-02-16 16:04:02 -06:00
Steven Daglish 5427d6bbc7 sensor: mcp9808: Adding temperature resolution to MCP9808 sensor driver
During the driver init, the function will set the sensor resolution
based on the driver's dts variable "resolution"

The driver's device tree has been updated to include the value
"resolution".

The default is set to the highest resolution of 0.0625C.

Moved mcp9808_reg_write from mcp9808_trigger.c to mcp9808.c

This allows resue of the same function in both the trigger and
resolution functions.

Function name changed to xxx_16bit to distinquish it from the 8
bit write function that will added.

Signed-off-by: Steven Daglish <s.c.daglish@gmail.com>
2021-02-15 08:13:17 -05:00
Armando Visconti 69269c52e8 drivers/sensor: iis2iclx: Move odr Kconfig property into dts
Move iis2iclx odr options from Kconfigs to Device Tree.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-02-15 07:58:36 -05:00
Armando Visconti 5ebada58a7 drivers/sensor: iis2iclx: Move range Kconfig property into dts
Converts iis2iclx range options (500mg, 1g, 2g, 3g) from Kconfigs
to Device Tree.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-02-15 07:58:36 -05:00
Kumar Gala 0944d07b55 drivers: sensor: icm42605: Fix use of deprecated API
Driver uses DEVICE_AND_API_INIT which is deprecated so convert
to using DEVICE_DT_INST_DEFINE instead.

Fixes #32151

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-10 18:21:20 -05:00
Kumar Gala 651898e13d drivers: sensor: icm42605: Fix build issues
There are several different issues when trying to build the icm42605
sensor driver:

* Missing entry in drivers/sensor/CMakeLists.txt
* Issues with #ifndef in header files
* Issues with const usage
* Missing function prototypes in headers
* Fix use of LOG_MODULE_REGISTER v LOG_MODULE_DECLARE
* Add missing dts node to tests/drivers/build_all/spi.dtsi

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-10 18:21:20 -05:00
Christoph Reiter 1b5f134477 drivers: sensor: dps310 fix out of bounds write
Fixes a copy-paste error which results in an out of bounds write on the
stack.

Signed-off-by: Christoph Reiter <christoph.reiter@infineon.com>
2021-02-09 10:44:43 -05:00
Jan Tore Guggedal e7a335fb9d drivers: sensor: adxl362: Fix unused variable warnings
This patch fixes warnings for unused variables when acceleremoter
range and sampling frequency are set to values different from
the defaults.

Signed-off-by: Jan Tore Guggedal <jantore.guggedal@nordicsemi.no>
2021-02-04 10:36:38 -05:00
Flavio Ceolin 9c55e2b551 drivers: bme280: Replace deprecated Kconfig option
Use CONFIG_PM_DEVICE instead of using CONFIG_DEVICE_POWER_MANAGEMENT.

Fixes: #31920

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-02-03 16:13:44 -05:00
Hayden Ball 893857b48a max17055: Fix current conversion from MAX17055 unit to milliamps
`SENSOR_CHAN_GAUGE_AVG_CURRENT` is currently treated as a capacity
by the MAX17055 driver, however the unit conversion is different
for current and must be calculated separately.

Add a separate method to convert a current reading to milliamps
from 1.5625 uV/R_SENSE units, instead of the 5uVH/R_SENSE conversion
that was previously used.

Tested by comparing value read and converted from MAX17055 with
value from an external power profiling kit.

Signed-off-by: Hayden Ball <hayden@playerdata.co.uk>
2021-01-30 10:45:39 -05:00
Armando Visconti 4141705ad3 drivers/sensor: Fix typos in iis2dlpc/iis2iclx/lsm6dso
The ',' character was used as line terminator instead of ';'
in SPI routines. The three affected drivers were not showing
any issue, but the typo is fixed for clarity.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-01-28 13:56:42 -05:00
Rubin Gerritsen 4f034740eb sensor: nrf5: temp: Allow alternative temp driver
This allows out-of-tree libraries to implement their own temperature
driver.

We allow selecting TEMP_NRF5 to aviod dependency loops

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-01-28 08:19:34 -05:00
Armando Visconti 45d0508bdf drivers/sensor: iis2dlpc: Add multi-instance support
Make this driver multi-instance and use the new API.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-01-21 16:49:55 -05:00
JuHyun Kim cc56fb5247 drivers: sensor: Initial driver of Invensense ICM42605
Initial driver and sample application of
TDK Invensense ICM42605 6-axis motion sensor.
This driver provide DTS for nRF52 DK board DTS setting.

Providing features are below.

Sensor data streaming - Accel, gyro
Tap, Double tap triggering.
Set/Get FSR, ODR by set attr API
Support multi instance feature.

Signed-off-by: JuHyun Kim <jkim@invensense.com>
2021-01-20 10:41:04 -06:00
Jacob Siverskog 290d64cb4e sensor: shell: add missing va_ends
each call to va_start must have a corresponding call to va_end.

Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
2021-01-18 19:08:04 +01:00
Armando Visconti e4f95863f9 drivers/sensor: iis2dlpc: Move trigger pulse Kconfig property into DT
Move iis2dlpc trigger pulse configurations from Kconfigs to Device Tree.
Moreover the dts properties have been renamed as 'tap', which sounds a
better name to immediately catch the feature behind it. Since tap
threshold cannot be zero, this value (which is the default in dts
binding) is used to enable/disable the device feature per each axis.
The event can be generated on INT1 only.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-01-18 09:21:00 -06:00
Armando Visconti 6ceffe8a94 drivers/sensor: iis2dlpc: Simplify the switch on trigger type
Simplify the switch case on trigger types (SENSOR_TRIG_DRDY and
SENSOR_TRIG_TAP) inside iis2dlpc_enable_int().

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-01-18 09:21:00 -06:00
Armando Visconti d2e8b0cc6e drivers/sensor: iis2dlpc: Move drdy_int info into DT
The IIS2DLPC drdy interrupt can be routed to either INT1 or
INT2 pin. Currently the selection is done by Kconfig configuration.
This commit is instead moving it into Device Tree as 'drdy-int'.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-01-18 09:21:00 -06:00
Kumar Gala 02703e60d9 device: Remove DEVICE_DT_DECLARE / DEVICE_DT_INST_DECLARE
Now that we generate a header that extern's all possible devicetree
based device struct we can remove DEVICE_DT_DECLARE and
DEVICE_DT_INST_DECLARE as they aren't needed anymore.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-01-15 07:16:21 -06:00
Maciej Kurc 086503abd5 drv: BME280 driver power management
Support for the OFF device power state to the BME280 sensor driver.

Signed-off-by: Maciej Kurc <mkurc1234@gmail.com>
2021-01-11 10:13:26 -06:00
Armando Visconti 34a677d05a drivers/sensor: iis2dlpc: Move power Kconfig property into dts
Move iis2dlpc power-mode option from Kconfigs to Device Tree.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-01-08 09:16:35 -06:00
Armando Visconti e9b93f99a5 drivers/sensor: iis2dlpc: Remove odr values from Kconfig
Remove all odr values from Kconfig and always init it
at 12.5Hz. It is responsibility of application to set
the rate to a different value using SENSOR_ATTR_SAMPLING_FREQUENCY.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-01-08 09:16:35 -06:00
Armando Visconti e8bbcb9284 drivers/sensor: iis2dlpc: Move range Kconfig property into dts
Converts iis2dlpc range options (2g, 4g, 8g, 16g) from Kconfigs
to Device Tree.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2021-01-08 09:16:35 -06:00
Xavier Naveira bb18fa0b35 drivers: sensor: adxl362: make time configurable via KConfig
The thresholds for activity/inactivity in the adxl362 acceleromter have
two parameters that can be configured. Currently the threshold is
configurable via the KConfig variables CONFIG_ADXL362_ACTIVITY_THRESHOLD
and CONFIG_ADXL362_INACTIVITY_THRESHOLD which configure repectively the
value in the THRESH_ACT and THRESH_INACT registers.
The other parameter that can be configured is the time by changing the
values in the registers TIME_ACT and TIME_INACT, but this values are
hardcoded to 1 (see lines 653 and 675 in adxl362.c), this patch adds
support for configuring those values in KConfig as
CONFIG_ADXL362_ACTIVITY_TIME and CONFIG_ADXL362_INACTIVITY_TIME.

Signed-off-by: Xavier Naveira <xnaveira@gmail.com>
2021-01-04 09:57:14 -06:00
Puranjay Mohan d31ed3be04 drivers: sensor: tmp116: Add support for SENSOR_ATTR_OFFSET.
TMP117 from TI is a sensor similar to tmp116, but it has more precision
and it also supports the offset register.
Add support for SENSOR_ATTR_OFFSET, which is used by TMP117 to the
pre-exisiting tmp116 driver.

This commit also enables multiple instances and adds TMP117 to Kconfig.

Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
2020-12-20 13:02:21 -05:00
Henrik Brix Andersen a3629990ea drivers: sensor: add NXP MCUX ACMP driver
Add driver for the NXP MCUX Analog Comparator (ACMP) IP.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-12-17 08:54:33 -06:00
Kumar Gala 5f605fd5ab drivers: sensor: Convert drivers to new DT device macros
Convert sensor drivers from:

    DEVICE_AND_API_INIT -> DEVICE_DT_INST_DEFINE
    DEVICE_GET -> DEVICE_DT_INST_GET
    DEVICE_DECLARE -> DEVICE_DT_INST_DECLARE

etc..

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-16 12:19:32 -05:00
Puranjay Mohan acfb2ace1d drivers: sensor: tmp116: Correct dev_name to tmp116
The dev_name field in DEVICE_AND_API_INIT() call should match the
driver's name. Tmp116 driver had a wrong dev_name field.

Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
2020-12-15 11:21:04 +01:00
Maureen Helm b0653e13dc drivers: sensor: Fix fxas21002 gyro units
Fixes the fxas21002 sensor driver to provide gyro channel data in
radians/sec instead of degrees/sec.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-12-13 19:26:10 -05:00
Gaspard Rigolot 2e024f5ed9 drivers: sensor: dps310 fix pressure and temperature registers
The two registers were inverted.

Signed-off-by: Gaspard Rigolot <gaspard.rigolot@stimio.fr>
2020-12-10 08:59:32 -06:00
Anas Nashif dd931f93a2 power: standarize PM Kconfigs and cleanup
- Remove SYS_ prefix
- shorten POWER_MANAGEMENT to just PM
- DEVICE_POWER_MANAGEMENT -> PM_DEVICE

and use PM_ as the prefix for all PM related Kconfigs

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-09 15:18:29 -05:00
Kumar Gala 06a5946266 drivers: Convert to use new DEVICE_DT_INST_* macros
Move users that are DEVICE_DT_DECLARE(DT_DRV_INST(n, ...)) to
DEVICE_DT_INST_DECLARE(n, ...) and similar for DEVICE_DT_DEFINE.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-09 14:06:48 -06:00
Tomasz Bursztyka 8d694d11b6 drivers/sensor: Fix device attribute names for lis2mdl and fxos8700
Found it via running coccinelle script found in:
af6140cc0d
and 98d9b01322

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-12-03 09:42:26 -05:00
Tomasz Bursztyka e2847552fc drivers/sensor: Fix constant qualifier for lis2mdl PM function
Found it via running coccinelle script in:
e18fcbba5a

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-12-03 09:42:26 -05:00
Yuval Peress beaf0230ba drivers: sensors: bmi160: Fix issue with sample read
When testing the bmi160 I've come across an issue where the readings
didn't make sense to me. The issue comes from reading the
BMI160_SAMPLE_BURST_READ_ADDR which is 0x0C assuming both accelerometer
and gyroscope. At this point we would normally read 12 bytes
(2 bytes per sample * 3 axes * 2 sensors). This reading takes place in
bmi160_sample_fetch and begins writing to data->sample.raw

Without this change, the first byte written is actually to the dummy
byte which effectively gets tossed. The issue is that this is the
GYR_X<7:0>(LSB) according to the BMI160 data sheet. When we later call
either bmi160_gyr_channel_get or bmi160_acc_channel_get we're looking
at sample.gyr and sample.acc (which is effectively shiften by 1 byte).

This change gets rid of the dummy byte which re-alignes gyr with the
start of the raw buffer.

Signed-off-by: Yuval Peress <peress@chromium.org>
2020-12-01 17:58:06 -05:00
Peter Bigot f3db8f5acc drivers: sensor: ccs811: convert to dt device defines
Use the devicetree node as the source of object name and other
information used when defining the device structure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Maureen Helm 18d7058ac8 drivers: sensor: Rework fxos8700 driver to use DT_INST_FOREACH
Reworks the fxos8700 sensor driver to use DT_INST_FOREACH_STATUS_OKAY.
This allows it to support multiple instances, however only a single
instance was tested with the frdm_k64f board.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-11-17 16:51:50 -05:00
Maureen Helm e015561c44 drivers: sensor: Fix fxos8700 device driver_api/data attributes
Fixes the fxos8700 sensor driver to reflect recent changes in the
generic device driver structure, renaming driver_data and config_info to
data and config respectively. These instances in the fxos8700 sensor
driver were missed because we haven't enabled the magnetic vector
magnitude function in CI.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-11-17 16:51:50 -05:00
Maureen Helm 84cc60e53c drivers: sensor: Convert fxos8700 vector mag Kconfigs to dts properties
Converts fxos8700 magnetic vector magnitude options from Kconfigs to
optional device tree properties.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-11-17 16:51:50 -05:00
Maureen Helm cb98e9aa11 drivers: sensor: Convert fxos8700 power mode Kconfigs to dts property
Converts fxos8700 power mode options (normal, low noise low power, high
resolution, low power) from Kconfigs to an optional device tree
property.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-11-17 16:51:50 -05:00
Maureen Helm 6199de14c4 drivers: sensor: Convert fxos8700 range Kconfigs to dts property
Converts fxos8700 range options (2g, 4g, 8g mode) from Kconfigs to an
optional device tree property.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-11-17 16:51:50 -05:00
Maureen Helm d4b9d197f3 drivers: sensor: Convert fxos8700 pulse Kconfigs to dts properties
Converts fxos8700 pulse detection options from Kconfigs to optional
device tree properties.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-11-17 16:51:50 -05:00
Peter Bigot ab9f7497ba shell: shell: select FP formatting support
This module needs to format floating point values in shell print
statements, which requires FP format support.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-17 14:44:59 -06:00
Armando Visconti 46b12406de drivers/sensor: lis2dh: Fix multi-instance leftovers
Introduced two per instance booleans, which get set using DT info:

  1. is_lsm303agr_dev: if the device is a LSM303AGR_ACCEL, then
     the scale values have to be changed.

  2. Handle disconnect-sdo-sa0-pull-up if present in ntsnace DT.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-11-17 14:44:18 -06:00
Armando Visconti d962e3590f drivers/sensor: lis2dh: Fix interrupt handling for multi instance
Handle interrupts correctly for multi instance, checking per
device DT bindings instead of global Kconfig definitions.

The old interrupt behaviour has been maintained, fixing DRDY to
be on INT1 and Any Motion event on INT2.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-11-17 14:44:18 -06:00
Armando Visconti c380142920 drivers/sensor: iis2iclx: add multi-instance
Make this driver multi-instance and use the new API.

Notes for sensorhub mode:
In case of multiples devices it is possible that some of them
has i2c slaves attached to it (sensorhub mode) but not the
others. Since the driver is configured in the same way for
all the instances (CONFIG_SENSORHUB=y), the routine that initialize
the sensorhub part does not fail anymore in case no slaves
are found for a particular instance. Instead, those non-sensorhub
driver instances will set the shub_inited flag to false and
will totally ignore the feature.

Notes for triggers:
In case of multiples devices the device pin the interrupt wire is
attached to can be different (INT1 or INT2 pin). So, this
information has been moved in DTS and then stored in the
specific instance config structure.
Currently the driver is able to handle a sngle interrupt line
at a time attached to either INT1 or INT2.
MOreover, the interrupt initialization for a driver instance proceed
only if the drdy has been configured in its DT, else it returns ok.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-11-11 13:17:18 +01:00
Yurii Gubin f700d74884 drivers: sensor: lsm6dsl: fixed irq_pin for interrupt handling
Obtaining irq_pin from dev leads to disabling interrupts
on unpredictable pin, as dev points to GPIO, not LSM6DSL.

Fixes #29721

Signed-off-by: Yurii Gubin <y.gubin@gmail.com>
2020-11-06 12:48:33 -06:00
Kumar Gala b4a3880a75 drivers: remove unnecessary use of DEVICE_AND_API_INIT
For drivers that support CONFIG_DEVICE_POWER_MANAGEMENT there are some
cases that look like:

  #ifdef CONFIG_DEVICE_POWER_MANAGEMENT
    DEVICE_DEFINE()
  #else
    DEVICE_AND_API_INIT()
  #endif

There is no need to special case this as the pm_control_fn argument to
DEVICE_DEFINE will just be ignored in the
!CONFIG_DEVICE_POWER_MANAGEMENT case.  So we can cleanup the code a
little and remove the #else cases for the drivers that do this.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-11-06 09:42:47 -06:00
Armando Visconti 667db2db88 drivers/sensor: lsm6dsl: Fix build when irq_gpios is not in DT
In case of h/w setup with multiples device instances it is possible
that some of them wants to use triggers but not the others (no
interrupt line.

Since Kconfig configuration is the same way for all the instances
(CONFIG_LSM6DSL_TRIGGER=y), the driver behaves differently according
to how the device instance has been configured in the DT.
If irq-gpios is present, then the driver initialize the interrupt
part, else it skip irq init and returns ok, but data->gpio != NULL
xis checked in trigger_set() API.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-11-02 10:00:07 -06:00
Stephane D'Alu 61b0009bdf sensor_shell: added missing sensor channel.
Synchronized with list of channel defined in sensor.h

Signed-off-by: Stephane D'Alu <sdalu@sdalu.com>
2020-11-02 09:52:54 -06:00
Simon Glass 0b1a7d109d drivers: sensor: bmi160: Add support for I2C
At present this driver only supports SPI. Add support for I2C as well,
following the model of BME280.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-27 16:41:30 +01:00
Simon Glass 0de655e371 drivers: sensor: bmi160: Prepare to support I2C
At present this driver only supports SPI. Refactor it so that SPI is
just one of the options. This does not change any functionality.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-27 16:41:30 +01:00
Simon Glass 1f1f695ae2 drivers: sensor: bmi160: Rename 'spi' to 'bus'
This member holds the SPI bus pointer. Change its name to make that
more obvious and so that it can be used for an I2C bus also.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-27 16:41:30 +01:00
Simon Glass 28f8ddae0b drivers: sensor: bmi160: Use only one read/write function
At present there are three separate read functions and two write
functions. This makes it harder to provide an interface that can work
with either SPI or I2C.

Use bmi160_read() for all reads and create a new bmi160_write()
function for all writes.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-27 16:41:30 +01:00
Simon Glass 226cacbc3d drivers: sensor: bmi160: Move SPI config to config
At present this driver only supports a single instance. It sets up some
of its config in the init routine. It is better to put config in
constant data so that multiple instances can be supported and RAM space
is minimised.

Update the driver accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-27 16:41:30 +01:00
Simon Glass 57fdcd4018 drivers: sensor: bmi160: Use 'data' for the data pointer
Currently a 'bmi160' pointer is used to point to the driver data. This
confusing, as the driver uses both data and config. Rename the variable
to 'data' like the bme280 driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-27 16:41:30 +01:00
Simon Glass a32f87b1e0 drivers: sensor: bmi160: Define accessors for the bmi160
Add inline functions to obtain the data and configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-27 16:41:30 +01:00
Simon Glass c3823b9144 drivers: sensor: bmi160: Shorten the structs a bit
This driver uses verbose names for the config and data structures, which
makes it harder to see which one we are talking about. Shorten it, like
the bme280 driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-27 16:41:30 +01:00
Philémon Jaermann cbed8815a2 drivers: sensor: Use macro parameter to dereference device
The TACH_XEC_DATA macro was not using its parameter
to retrieve the data structure.
It was working by chance so far.

Signed-off-by: Philémon Jaermann <p.jaermann@gmail.com>
2020-10-21 08:29:36 -04:00
Armando Visconti 1921a2d84e drivers/sensor: add support to IIS2ICLX accelerometer
The IIS2ICLX is a high-accuracy. ultra-low noise, low-power
two-axis linear accelerometer which can be interfaced through
either I2C or SPI bus.
Its high accuracy, stability over temperature and repeatability
make IIS2ICLX particularly suitable for inclination measurement
for industrial applications (inclinometers).

https://www.st.com/resource/en/datasheet/iis2iclx.pdf

This driver is based on stmemsc i/f v1.03.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-10-15 09:57:47 -05:00
Armando Visconti de5135b05e modules/hal_st: Align sensor drivers to stmemsc HAL i/f v1.03
Align all sensor drivers that are using stmemsc (STdC) HAL i/f
to new APIs of stmemsc v1.03.

Requires https://github.com/zephyrproject-rtos/hal_st/pull/5
(merged as b52fdbf4b62439be9fab9bb4bae9690a42d2fb14)

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-10-13 09:46:08 -05:00
Armando Visconti 4250028483 drivers/sensor: iis2mdc: Fix the temperature in celsius
Fix the formula to translate raw temperature read from
register to Celsius.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-10-13 09:46:08 -05:00
Armando Visconti 99b97f5ff4 drivers/sensor: ism330dhcx: Fix init routines order
The interrupt enabling routine was called before the
chip enabling routine resulting in a runtime failure
when triggers are set.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-10-13 09:46:08 -05:00
Simon Glass 442f38d610 emul: Add an emulator for the Bosch BMI160 accelerometer
This emulator supports enable functionality to start up the device and
read a few samples. It connects itself to any BMI160 device it finds in
the device tree. The SPI emulation controller driver is used to direct
SPI messages from the BMI160 driver to the BMI160 emulator.

Add a few more definitions to the header file, as needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-05 15:33:00 -04:00
Simon Glass 5a9f389159 drivers: sensor: bmi160: Use more constants for reg access
At present register access is a mix of constants and open-coded values
in the driver. Add a few more constants to clean this up.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-05 15:33:00 -04:00
Simon Glass 2c73f3ed4c drivers: sensor: bmi160: Add a constant for number of axes
Define a constant instead of using an open-coded value.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-05 15:33:00 -04:00
Simon Glass e944855bbc drivers: sensor: bmi160: Move the ready bit into the header
This should be accessible to all files that need register access. Move
it into the header.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-05 15:33:00 -04:00
Emil Hammarstrom 7743b1e553 drivers: sensor: lis2mdl: Add device power management
The power draw of this magnetometer is significant,
device power management is needed for our use-cases.

Signed-off-by: Emil Hammarstrom <emil.hammarstrom@assaabloy.com>
Change-Id: I71158e629e93b491c6d673aa81001b7a7099f654
2020-10-02 11:32:59 +02:00
Armando Visconti fe6a73669d drivers: sensor: hts221: Add checks for drdy_gpios macros
To avoid build errors enable the trigger only if DRDY gpio is
defined in DTS. Fix #28443

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-09-24 09:51:08 -05:00
Armando Visconti 4df0d019fd drivers/sensor/lsm6dsl: Fix read/write bus API in shub code
The ce0cc3a7 commit (lsm6dsl: make the driver multi-instance) changes
all bus API signature, which now requires a "const struct device *dev"
and not a "struct lsm6dsl_data *data". By mistake the shub part was
left unchanged. Fix: #28565

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-09-23 13:17:06 -05:00
Armando Visconti ce0cc3a7cc drivers: sensor: lsm6dsl: make the driver multi-instance
Make this driver multi-instance and use the new API.
Fixes #28390

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-09-18 22:08:44 -04:00
Erwan Gouriou 8b47e563e2 dts/Kconfig: Remove HAS_DTS_I2C
HAS_DTS_I2C is now selected by I2C and
always used as I2C && HAS_DTS_I2C.

It could then be purely removed.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-09-18 13:34:44 -05:00
Armando Visconti 4ea9a8bd95 drivers: sensor: lis2dh: make the driver multi-instance
Make this driver multi-instance and use the new API.
Fixes #27753.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-09-14 13:28:45 -05:00
Richard Osterloh 0a0026afe2 drivers: sensor: Add VCNL4040 driver
Add support for Vishay VCNL4040 proximity and light sensor

Signed-off-by: Richard Osterloh <richard.osterloh@gmail.com>
2020-09-04 13:03:12 -05:00
Tomasz Bursztyka d00d86972a drivers: sensor: Fix device instance const qualifier loss
It is necessary to wrap the device pointer into data.
Which was done already on most of them when global trigger is enabled.

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +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
Flavio Ceolin 0aaae4a039 guideline: Make explicit fallthrough cases
-Wimplicit-fallthrough=2 requires a fallthrough comment or a compiler
to tells gcc that this happens intentionally.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-08-24 20:28:47 -04:00
Jamie McCrae 4cf1832fa8 drivers: sensors: sm351lt: Add new driver
Adds sm351lt magnetoresitive sensor driver.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2020-08-24 16:48:47 -05:00
Matija Tudan efae88ce3a sensor: fxos8700: implement magnetic vector magnitude function
The magnetometer vector-magnitude function will generate an interrupt
when magnitude is greater than specified threshold value. The user
may program the threshold value to establish the conditions needed
to detect a magnetic vector-magnitude change event. Depending on the
values chosen for the reference values, this function may be
configured to detect a magnetic field magnitude that is above
a preset threshold (with reference values = 0), or a change in magnitude
between two magnetic vectors greater than the preset threshold
(with reference values non-zero).

Default configuration of M_VECM_CFG register (address 0x69) is 0x4e.

Signed-off-by: Matija Tudan <mtudan@mobilisis.hr>
2020-08-21 12:30:50 -05:00
Tomasz Bursztyka 98d9b01322 device: Apply driver_api/data attributes rename everywhere
Via coccinelle:

@r_device_driver_api_and_data_1@
struct device *D;
@@
(
D->
-	driver_api
+	api
|
D->
-	driver_data
+	data
)

@r_device_driver_api_and_data_2@
expression E;
@@
(
net_if_get_device(E)->
-	driver_api
+	api
|
net_if_get_device(E)->
-	driver_data
+	data
)

And grep/sed rules for macros:

git grep -rlz 'dev)->driver_data' |
	xargs -0 sed -i 's/dev)->driver_data/dev)->data/g'

git grep -rlz 'dev->driver_data' |
	xargs -0 sed -i 's/dev->driver_data/dev->data/g'

git grep -rlz 'device->driver_data' |
	xargs -0 sed -i 's/device->driver_data/device->data/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Tomasz Bursztyka af6140cc0d device: Apply config_info rename everywhere
Via coccinelle:

@r_device_config@
struct device *D;
@@

D->
-	config_info
+	config

And 2 grep/sed rules for macros:

git grep -rlz 'dev)->config_info' |
	xargs -0 sed -i 's/dev)->config_info/dev)->config/g'

git grep -rlz 'dev->config_info' |
	xargs -0 sed -i 's/dev->config_info/dev->config/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Sven Herrmann 001ff9ffab Sensor: mpr: Fix indentation in comment
Fix indentation in ascii-style formula for register to value conversion.

Signed-off-by: Sven Herrmann <sven.herrmann@posteo.de>
2020-08-06 11:50:04 +02:00
Sven Herrmann 7e8759b9fa Sensor: mpr: Fix integer handling issue
Fixes #27044

Signed-off-by: Sven Herrmann <sven.herrmann@posteo.de>
2020-08-06 11:50:04 +02:00
Greg Leach 41da0769c1 sensor: Add Silabs SI7055 support
Add support for the Silabs SI7055 temperature sensor

Signed-off-by: Greg Leach <greg.leach@lairdconnect.com>
2020-08-05 14:50:52 -05:00
Andrew Boie 7d920ba39b drivers: use K_KERNEL_STACK macros
None of these threads run in user mode and we can save some
memory.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-08-04 12:16:43 -04:00
Rihards Skuja 4a16095e8a drivers: sensor: nrf5: only assert on errors
After changes made in ff089217cb, clock control release can now return
non-negative values on success.

Signed-off-by: Rihards Skuja <rihardssk@mikrotik.com>
2020-08-03 13:50:08 +02:00
Simon Glass 5afdceee8c sensor: shell: Add a 'battery' command
It is useful to show sensor channels for a battery in cohesive block as
it is easier to read. Add a 'battery' command to handle this. It only
supports a single battery, relying on the device-tree alias to select
it.

uart:~$ battery
Temp:  23.55 C
V:     4.31 V
V-desired: 4.40 V
I:    574 mA (CHG)
I-desired:  2000 mA
Charging: Not Allowed
Charge: 100 %
V-design: 3.86 V
Remaining: 6764 mA
Cap-full: 6764 mA
Design: 6910 mA
Time full: 0h:00
Time empty: 0h:00

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-23 12:12:09 -04:00
Simon Glass ee34aced6a sensor: max17055: Add MAX17055 driver
Add support for the Maxim MAX17055 fueld-gauge sensor.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-23 12:12:09 -04:00
Simon Glass 9b8c04401d sensor: shell: Show the error code when reading fails
The error code may give a clue as to what is wrong. Add it to the error
message.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-23 12:12:09 -04:00
Simon Glass 122d8fa6a9 sensor: shell: Allow output for fuel-gauge channels
Add names for more channels so that they can be shown, e.g.:

$ sensor get MAX17055
channel idx=38 gauge_voltage =   4.313906
channel idx=39 gauge_avg_current = 558.000000
channel idx=42 gauge_temp =  23.558558
channel idx=43 gauge_state_of_charge = 100.000003
channel idx=44 gauge_full_cap = 6766.000000
channel idx=45 gauge_remaining_cap = 6766.000000
channel idx=46 gauge_nominal_cap = 6910.000000
channel idx=50 gauge_time_to_empty =   0.000000
channel idx=51 gauge_time_to_full =   0.000000
channel idx=52 gauge_cycle_count =   0.100000
channel idx=53 gauge_design_voltage =   3.860000
channel idx=55 gauge_desired_charging_current = 2000.000000

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-23 12:12:09 -04:00
Krzysztof Chruscinski ff089217cb drivers: sensor: nrf5: Adapt temp driver to use onoff for clock
Adapted driver to use onoff service for clock control.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-07-20 16:22:21 +02:00
Saravanan Sekar 9ac3c9d42a drivers: sensors: itds: Add support for WSEN-ITDS 3-axis accel sensor
Add support for wsen-itds 3-axis accel sensor, provides acceleration,
temperature data reading and supports configuring of output data rate,
operating mode and scale.

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
2020-07-20 12:45:56 +02:00
Armando Visconti 485f2d410c drivers/sensors: Add iis2dh accelerometer sensor support
Add support to STM IIS2DH the ultra-low-power highperformance
three-axis linear accelerometer.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-07-10 11:49:40 -05:00
Peter Bigot 2036bbcde4 drivers: sensor: bme280: respect devicetree cs-gpios flags
Forward flags cell from cs-gpios devicetree property into device SPI
configuration.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-07-09 06:07:07 -05:00
Krzysztof Chruscinski 157f6f65d9 drivers: sensor: nrf5: temp_nrf5: Add mutex to temp_nrf5_sample_fetch
Added mutex to protect against access from various contexts.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-07-07 16:27:32 -04:00
Jordan Yates ac66b76934 sensor: ms5607: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates f7e2265fb8 sensor: lsm6dsl: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates adf1c1cfe9 sensor: lis2ds12: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates 3d490e0f6e sensor: adxl372: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates 1dffc2870f sensor: adxl362: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates a04d2f3989 sensor: lsm6dso: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates e186dcb34e sensor: lps22hh: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates 9a6ec94aa7 sensor: lis2mdl: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates fc2783a017 sensor: lis2dh: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates f92714ecec sensor: ism330dhcx: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates 88e4ddbbd4 sensor: lis2dw12: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates f622dcb1ec sensor: iis3dhhc: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates 369f64f6ff sensor: iis2mdc: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Jordan Yates 4f0a370c7f sensor: iis2dlpc: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
laurence pasteau 0388a26a19 lis2dw12 : remove useless semi-colons
cleaning commit to remove useless semi-colons in lis2dw12 trigger

Signed-off-by: laurence pasteau <laurence.pasteau@stimio.fr>
2020-06-26 11:18:38 -05:00
laurence pasteau ba3a6dce95 sensors : fix bad pin value when disabling interruption
In sensors drivers, in gpio callback function :
The device structure in parameter is related to the gpio device.

Signed-off-by: laurence pasteau <laurence.pasteau@stimio.fr>
2020-06-26 11:18:38 -05:00
Tomasz Bursztyka 8260736268 drivers: Remove useless device start/end pointers
Commit id a538dcd8f8 got rid of the usage of these pointers so they are
useless now and can be removed in this drivers.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-06-26 11:09:28 -05:00
Peter Bigot a538dcd8f8 shell: refactor device_name_get implementation
Several shell modules use cloned code to iterate over all devices and
identify the nth instance that meets some criteria.  The code was
repetitive and included various errors.  Abstract to a helper function
that performs the check consistently.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-06-23 13:27:14 +02:00
Henrik Brix Andersen 696fc3afbf drivers: sensor: add api function for getting a sensor attribute
Add an API function for getting the value of a sensor attribute.

Fixes #26167.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-06-17 17:13:14 +02:00
Maureen Helm 4475959285 drivers: sensor: Check i2c device pointer is non-null in bq274xx
Fixes the bq274xx sensor driver to check the i2c device pointer is
non-null, rather than the bq274xx sensor device pointer. This appears to
be the originally intended check based on the LOG_ERR message.

Coverity CID: 210035

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-06-17 09:31:16 +02:00
Henrik Brix Andersen 05da68c7cb drivers: sensor: shell: allow passing channel as number
Allow passing the channel as a number instead of a string in order to
support sensor-specific channels (channel SENSOR_CHAN_PRIV_START and
up).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-06-15 12:59:20 -05: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
Andrzej Głąbek f766a3e18b sensor: temp_nrf5: Allow use only when the TEMP peripheral is present
Correct dependency of the TEMP_NRF5 Kconfig option so that it can be
enabled only on nRF SoCs that feature the TEMP peripheral.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-05-25 16:03:02 +02:00
Christoph Reiter d49e7da7da sensor: add sensor driver for Infineon DPS310
Add driver for Infineon DPS310 temperature and pressure sensor.

Signed-off-by: Christoph Reiter <christoph.reiter@infineon.com>
2020-05-14 11:02:29 +02:00
Martí Bolívar 6e8775ff84 devicetree: remove DT_HAS_NODE_STATUS_OKAY
Several reviewers agreed that DT_HAS_NODE_STATUS_OKAY(...) was an
undesirable API for the following reasons:

- it's inconsistent with the rest of the DT_NODE_HAS_FOO names
- DT_NODE_HAS_FOO_BAR_BAZ(node) was agreed upon as a shorthand
  for macros which are equivalent to
  DT_NODE_HAS_FOO(node) && DT_NODE_HAS_BAR(node) &&
- DT_NODE_HAS_BAZ(node), and DT_HAS_NODE_STATUS_OKAY is an odd duck
- DT_NODE_HAS_STATUS(..., okay) was viewed as more readable anyway
- it is seen as a somewhat aesthetically challenged name

Replace all users with DT_NODE_HAS_STATUS(..., okay), which is
semantically equivalent.

This is mostly done with sed, but a few remaining cases were done by
hand, along with whitespace, docs, and comment changes. These special
cases include the Nordic SOC static assert files.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 18:24:42 +02:00
Martí Bolívar 7e0eed9235 devicetree: allow access to all nodes
Usually, we want to operate only on "available" device
nodes ("available" means "status is okay and a matching binding is
found"), but that's not true in all cases.

Sometimes we want to operate on special nodes without matching
bindings, such as those describing memory.

To handle the distinction, change various additional devicetree APIs
making it clear that they operate only on available device nodes,
adjusting gen_defines and devicetree.h implementation details
accordingly:

- emit macros for all existing nodes in gen_defines.py, regardless
  of status or matching binding
- rename DT_NUM_INST to DT_NUM_INST_STATUS_OKAY
- rename DT_NODE_HAS_COMPAT to DT_NODE_HAS_COMPAT_STATUS_OKAY
- rename DT_INST_FOREACH to DT_INST_FOREACH_STATUS_OKAY
- rename DT_ANY_INST_ON_BUS to DT_ANY_INST_ON_BUS_STATUS_OKAY
- rewrite DT_HAS_NODE_STATUS_OKAY in terms of a new DT_NODE_HAS_STATUS
- resurrect DT_HAS_NODE in the form of DT_NODE_EXISTS
- remove DT_COMPAT_ON_BUS as a public API
- use the new default_prop_types edtlib parameter

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-08 19:37:18 -05:00
Kumar Gala 5cf85fa229 drivers: move nxp_kinetis_temp to for-each style
Move to FOREACH to prepare for an upcoming patch.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-08 19:37:18 -05:00
Tomasz Bursztyka 97326c0445 device: Fix structure attributes access
Since struct devconfig was merged earlier into struct device, let's fix
accessing config_info, name, ... attributes everywhere via:

grep -rlZ 'dev->config->' | xargs -0 sed -i 's/dev->config->/dev->/g'

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-08 23:07:44 +02:00
Tomasz Bursztyka 8d7bb8ffd8 device: Refactor device structures
When the device driver model got introduced, there were no concept of
SYS_INIT() which can be seen as software service. These were introduced
afterwards and reusing the device infrastructure for simplicity.
However, it meant to allocate a bit too much for something that only
required an initialization function to be called at right time.

Thus refactoring the devices structures relevantly:
- introducing struct init_entry which is a generic init end-point
- struct deviceconfig is removed and struct device owns everything now.
- SYS_INIT() generates only a struct init_entry via calling
  INIT_ENTRY_DEFINE()
- DEVICE_AND_API_INIT() generates a struct device and calls
  INIT_ENTRY_DEFINE()
- init objects sections are in ROM
- device objects sections are in RAM (but will end up in ROM once they
  will be 'constified')

It also generate a tiny memory gain on both ROM and RAM, which is nice.

Perhaps kernel/device.c could be renamed to something more relevant.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-08 23:07:44 +02:00
Kumar Gala 0a7d4e2135 devicetree: Change DT_FOREACH_IMPL_ to not insert semicolon
Remove semicolon between instance invocations of DT_FOREACH_IMPL_ and
thus DT_INST_FOREACH.  This provides more flexibility to the user.  This
requires we fixup in tree users to add semicolon where needed.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-07 20:03:56 -05:00
Martí Bolívar 87e1743ae0 devicetree: replace DT_HAS_DRV_INST with DT_INST_FOREACH
Make drivers multi-instance wherever possible using DT_INST_FOREACH.
This allows removing DT_HAS_DRV_INST in favor of making drivers just
do the right thing regardless of how many instances there are.

There are a few exceptions:

- SoC drivers which use CMake input files (like i2c_dw.c) or otherwise
  would require more time to convert than I have at the moment. For the
  sake of expediency, just inline the DT_HAS_DRV_INST expansion for
  now in these cases.

- SoC drivers which are explicitly single-instance (like the nRF SAADC
  driver). Again for the sake of expediency, drop a BUILD_ASSERT in
  those cases to make sure the assumption that all supported SoCs have
  at most one available instance is valid, failing fast otherwise.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-06 17:35:08 -05:00
Armando Visconti fb815c65eb drivers/sensors: ism330dhcx: use endop bit in shub wait_completed
Use the endop bit in the status register (instead of using a k_sleep)
to wait until the current shub operation is completed.

Please note that the recent changes to k_sleep() API was also
breaking the compilation.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-05-06 10:33:07 -05:00
Kumar Gala fdd85d5ad7 dts: Rename DT_HAS_NODE macro to DT_HAS_NODE_STATUS_OKAY
Rename DT_HAS_NODE to DT_HAS_NODE_STATUS_OKAY so the semantics are
clear.  As going forward DT_HAS_NODE will report if a NODE exists
regardless of its status.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-06 05:25:41 -05:00
Kumar Gala aba7d63860 drivers: sensor: lis2dh: Rename defines to remove DT_ prefix
We want to limit DT_ prefix to macros from devicetree.h and generation.
So rename DT_LIS2DH_INT* to just LIS2DH_INT*.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-30 04:46:11 -05:00
Anthony Brandon 7dd4cc5821 sensor: si7006: combined RH/T measurements
The Si7006-A20 rev. 1.2 datasheet, section 5.1.2. Measuring Temperature
says that:

"Each time a relative humidity measurement is made a temperature
measurement is also made for the purposes of temperature compensation of
the relative humidity measurement. If the temperature value is required,
it can be read using command 0xE0; this avoids having to perform a
second temperature measurement."

Respective improvement is implemented.

Signed-off-by: Max Payne <forgge@gmail.com>
Signed-off-by: Anthony Brandon <anthony@amarulasolutions.com>
2020-04-22 15:51:15 -05:00
Max Payne 0bc4370689 sensor: si7006: fixed temperature conversion
The driver was incorrectly converting the temperature samples. According
to Si7006-A20 rev. 1.2 datasheet, section 5.1.2. Measuring Temperature,
the offset -46.85 must be applied.

Signed-off-by: Max Payne <forgge@gmail.com>
Signed-off-by: Anthony Brandon <anthony@amarulasolutions.com>
2020-04-22 15:51:15 -05:00
Kamil Rakoczy 415065a5f3 Sensor: ADXL345: Fix ADXL345 driver
Fixes problems with ADXL345 3-axis I2C accelerometer
reported in #23577, #23581 and #23584.

Signed-off-by: Kamil Rakoczy <krakoczy@antmicro.com>
2020-04-22 19:28:47 +02:00
Kamil Rakoczy f0ffe33dfe Sensor: ADXL345: Fix ADXL345 device address
Fixes bad device address passed to i2c_reg_write_byte/i2c_reg_read_byte.

Signed-off-by: Kamil Rakoczy <krakoczy@antmicro.com>
2020-04-22 19:28:47 +02:00
Sven Herrmann bded58cee5 Sensor: mpr: Add Honeywell MPR driver
The Honeywell MPR sensor is a piezoresistive silicon pressure sensor,
which can be accessed via i2c.

https://sensing.honeywell.com/micropressure-mpr-series

Signed-off-by: Sven Herrmann <sven.herrmann@posteo.de>
2020-04-22 17:39:31 +02:00
Flavio Ceolin 1572106e68 sensor: lis3mdl: Check possible error in trigger_set
Check the return of i2c_burst_read return and in case of error return
early and propagate the error.

Fixes: #23294

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-04-20 15:43:23 +02:00
Martí Bolívar cd1387d6cf drivers: sensor: qdec_nrfx: move to new DT API
And add "quadrature decoder" to the binding description just have it
written down.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-04-20 15:43:01 +02:00
Kumar Gala 762b521931 drivers: sensor: Fix missing DT_DRV_COMPAT
Some sensor drivers modify there struct's based on DT defines.  In those
cases we need to make sure that DT_DRV_COMPAT is set on all the source
files associated with that driver.  This updates any such files.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-17 03:32:19 -05:00
Martí Bolívar 8aadf89579 drivers: sensor: bme280: convert to new DT API
Make this multi-instance and use the new API.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-04-14 10:38:10 -05:00
Parthiban Nallathambi e65b14c2b6 sensor: bq274xx: Add BQ27421 driver
Add support for TI BQ27421 fuel gauge sensor

Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
Signed-off-by: NavinSankar Velliangiri <navin@linumiz.com>
2020-04-13 11:50:41 -05:00
Francisco Munoz 4185da0a7e drivers: sensors: tach: Configurable pulses per cycle
Introduce a Kconfig option to be able to interpret rpm
values from several fans.

Signed-off-by: Francisco Munoz <francisco.munoz.ruiz@intel.com>
2020-04-13 11:34:13 -05:00
Henrik Brix Andersen c8d26b4b14 drivers: sensor: nxp_kinetis_temp: add weighted average filter
Add an optional weighted average filter to the ADC readings in the NXP
Kinetis temperature sensor driver as recommended in NXP AN3031.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-04-06 15:39:36 -05:00
Henrik Brix Andersen 2a6aa0be88 drivers: sensor: nxp_temp_kinetis: fix potential overflow
Fix a potential 32 bit multiplication overflow (muliplying by 10000
instead of 1000000) and change the calculations and units accordingly.

Improve the code readability and traceability towards NXP AN3031 by
using the same variable name as in the application note.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-04-06 15:39:36 -05:00
Kumar Gala e268368fd4 drivers: sensor: st: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-06 12:41:43 -05:00
Kumar Gala 9872dc16b5 drivers: sensors: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-03 16:42:01 -05:00
Peter Bigot ecf3bdb5b3 coccinelle: re-run timeout conversion semantic patch
Run the int_literal_to_timeout Coccinelle script to fix places where
it is clear that an integer duration is being passed where a timeout
value is required.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-04-02 19:47:51 +03:00
Andy Ross 32bb2395c2 timeout: Fix up API usage
Kernel timeouts have always been a 32 bit integer despite the
existence of generation macros, and existing code has been
inconsistent about using them.  Upcoming commits are going to make the
timeout arguments opaque, so fix things up to be rigorously correct.
Changes include:

+ Adding a K_TIMEOUT_EQ() macro for code that needs to compare timeout
  values for equality (e.g. with K_FOREVER or K_NO_WAIT).

+ Adding a k_msleep() synonym for k_sleep() which can continue to take
  integral arguments as k_sleep() moves away to timeout arguments.

+ Pervasively using the K_MSEC(), K_SECONDS(), et. al. macros to
  generate timeout arguments.

+ Removing the usage of K_NO_WAIT as the final argument to
  K_THREAD_DEFINE().  This is just a count of milliseconds and we need
  to use a zero.

This patch include no logic changes and should not affect generated
code at all.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
Christian Hirsch d85b672368 drivers: sensor: ENS210: add single shot mode
Add possibility to change the measurement modes
of the temperature and humidity measurements to
continuous or single-shot mode or switch them off.

Signed-off-by: Christian Hirsch <christian.hirsch@tuwien.ac.at>
2020-03-31 15:11:43 +02:00
Oleg Zhurakivskyy b1e1f64d14 global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()
Replace all occurences of BUILD_ASSERT_MSG() with BUILD_ASSERT()
as a result of merging BUILD_ASSERT() and BUILD_ASSERT_MSG().

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-31 07:18:06 +02:00
Christian Hirsch 6380c24626 drivers: sensor: BME280: add forced sampling mode
add the forced sampling mode, to take just a single
measurement when fatching a sample

Signed-off-by: Christian Hirsch <christian.hirsch@tuwien.ac.at>
2020-03-25 14:52:07 -05:00
Kumar Gala 8d2f22f9ea drivers: sensor: fxos8700: convert to new DT API
Use the new devicetree.h API instead of the legacy macros.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-24 10:11:20 -05:00
Armando Visconti a302786e9b drivers/sensor: add support to IIS2MDC magnetometer sensor
The IIS2MDC is a 3D digital magnetometer ultra-low power sensor
for industrial applications, which can be interfaced through
either I2C or SPI bus.

https://www.st.com/resource/en/datasheet/iis2mdc.pdf

This driver is based on stmemsc i/f v1.02.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-03-20 14:53:42 -05:00
Carles Cufi 4b37a8f3a4 Revert "global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()"
This reverts commit 8739517107.

Pull Request #23437 was merged by mistake with an invalid manifest.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-03-19 18:45:13 +01:00
Oleg Zhurakivskyy 8739517107 global: Replace BUILD_ASSERT_MSG() with BUILD_ASSERT()
Replace all occurences of BUILD_ASSERT_MSG() with BUILD_ASSERT()
as a result of merging BUILD_ASSERT() and BUILD_ASSERT_MSG().

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2020-03-19 15:47:53 +01:00
Armando Visconti c0f7a1ac6f drivers/sensor: add support to ISM330DHCX IMU sensor
The ISM330DHCX is a ultra-low power IMU with a 3D digital accelerometer
and 3D digital gyroscope tailored for Industry 4.0 applications, which
can be interfaced through either I2C or SPI bus.

https://www.st.com/resource/en/datasheet/ism330dhcx.pdf

This driver is based on stmemsc i/f v1.02.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-03-18 16:14:47 -05:00
Armando Visconti e13205b256 drivers/sensor: add support to IIS2DLPC accelerometer sensor
The IIS2DLPC is a 3D digital accelerometer ultra-low power sensor
for industrial applications, which can be interfaced through either
I2C or SPI bus.

https://www.st.com/resource/en/datasheet/iis2dlpc.pdf

This driver is based on stmemsc i/f v1.02

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2020-03-16 10:42:28 -05:00
Kamil Rakoczy 687d1040ac Sensor: ADXL345: Add ADXL345 driver
Add support for Analog Devices ADXL345 3-axis I2C accelerometer.

Signed-off-by: Kamil Rakoczy <krakoczy@antmicro.com>
2020-03-13 08:53:43 -05:00
Francisco Munoz 7357ae974f drivers: sensors: Add tachometer driver for MEC family
Introduce the tach driver for the microchip XEC SoCs.

Signed-off-by: Francisco Munoz <francisco.munoz.ruiz@intel.com>
2020-03-13 08:49:21 -05:00