Commit graph

1951 commits

Author SHA1 Message Date
Jackie Yang c8c67feab0 drivers: sensor: lsm6dsl: Added support for lis3mdl as a external sensor
Added code to support lis3mdl to be used as an external sensor for
lsm6dsl in sensorhub mode

Signed-off-by: Jackie Yang <jackie@jackieyang.me>
2023-04-20 10:48:03 +02:00
Hiroki Tada 943158326c drivers: sensor: Support Hamamatsu Photonics S11059 Color Sensor
DataSheet:
https://datasheetspdf.com/pdf/1323325/Hamamatsu/S11059-02DT/1

Testing Environment:
esp32

Signed-off-by: Hiroki Tada <tada.hiroki@fujitsu.com>
2023-04-18 17:07:48 -05:00
Andriy Gelman b8244fdabd drivers: sensor: Add adt7310 temperature sensor
Adds adt7310 temperature controlled via spi.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2023-04-17 10:06:04 -05:00
Matthias Hauser 6789c0d400 drivers: sensor: Added driver for the Würth Elektronik WSEN-PADS sensor
Added driver for the absolute pressure sensor WSEN-PADS

Signed-off-by: Matthias Hauser <Matthias.Hauser@we-online.de>
2023-04-17 11:49:35 +02:00
Peter Johanson 1432b6e870 drivers: sensor: qdec_nrfx: Typo fix from trigger work.
Fix a typo introduced during move to store pointer to the
user supplied trigger.

Signed-off-by: Peter Johanson <peter@peterjohanson.com>
2023-04-17 10:20:06 +02:00
Alberto Escolar Piedras 83377046ba drivers: temp_nrf5: Fix warning in ISR prototype
The ISR prototype was changed some time ago
(6df8b3995e)
to (const void*) => fix isr function definition
to avoid a compile warning.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-04-17 10:19:33 +02:00
Armando Visconti 15389ea902 modules/hal_st: Align sensor drivers to stmemsc HAL i/f v2.02
Align all sensor drivers that are using stmemsc (STdC) HAL i/f
to new APIs of stmemsc v2.02. Please note that now a new function
callback, mdelay(), must be provided in case the stmemsc HAL requires
to wait for a certain amount of milliseconds before or after some
special operations.

Requires https://github.com/zephyrproject-rtos/hal_st/pull/13
(merged as 5948f7b3304f1628a45ee928cd607619a7f53bbb)

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2023-04-14 10:51:15 -05:00
Gerard Marull-Paretas 667eeb11fb shell: fix MISRA 5.7 violations on struct shell
MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Guillaume Gautier b323c0f227 drivers: sensor: stm32_temp: add negative temperature coefficient
Add support for negative temperature coefficient for single calibration
chips in the STM32 temperature driver.
That feature is necessary for STM32F0x0.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-04-13 09:11:45 -05:00
Benjamin Björnsson 818738b366 drivers: sensor: stm32_temp: Add support for STM32C0-series
Add new compatible to separate production calibrated sensors
with single and dual calibration temperatures. Also update
stm32_temp driver to support single calibration sensors.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2023-04-13 09:59:52 +02:00
Benjamin Björnsson 2f20bcfa0a drivers: sensor: stm32_temp: Remove multi-instancing
STM32 only has one temp instance in hardware.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2023-04-13 09:59:52 +02:00
Gerard Marull-Paretas a5fd0d184a init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:

- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices

They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:

```c
struct init_entry {
	int (*init)(const struct device *dev);
	/* only set by DEVICE_*, otherwise NULL */
	const struct device *dev;
}
```

As a result, we end up with such weird/ugly pattern:

```c
static int my_init(const struct device *dev)
{
	/* always NULL! add ARG_UNUSED to avoid compiler warning */
	ARG_UNUSED(dev);
	...
}
```

This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:

```c
static int my_init(void)
{
	...
}
```

This is achieved using a union:

```c
union init_function {
	/* for SYS_INIT, used when init_entry.dev == NULL */
	int (*sys)(void);
	/* for DEVICE*, used when init_entry.dev != NULL */
	int (*dev)(const struct device *dev);
};

struct init_entry {
	/* stores init function (either for SYS_INIT or DEVICE*)
	union init_function init_fn;
	/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
	 * to know which union entry to call.
	 */
	const struct device *dev;
}
```

This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.

**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

init: convert SYS_INIT functions to the new signature

Conversion scripted using scripts/utils/migrate_sys_init.py.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

manifest: update projects for SYS_INIT changes

Update modules with updated SYS_INIT calls:

- hal_ti
- lvgl
- sof
- TraceRecorderSource

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: devicetree: devices: adjust test

Adjust test according to the recently introduced SYS_INIT
infrastructure.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: kernel: threads: adjust SYS_INIT call

Adjust to the new signature: int (*init_fn)(void);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 14:28:07 +00:00
Zhang Lixu 9c9304218b drivers: sensor: lsm6dso: round up to the nearest odr
It was too strict to require the caller to pass in an accurate odr as a
parameter. This patch is to round the odr up to the nearest one, when odr
does not match.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2023-04-12 09:17:05 -05:00
Maureen Helm e0915eb6ac drivers: sensor: Fix sx9500 build with trigger disabled
Extending tests/drivers/build_all/sensor/ to include missing driver
trigger configurations revealed that some sensor drivers failed to build
with triggers disabled.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-11 19:25:46 -04:00
Maureen Helm 4c6478dcea drivers: sensor: Fix bmg160 build with trigger disabled
Extending tests/drivers/build_all/sensor/ to include missing driver
trigger configurations revealed that some sensor drivers failed to build
with triggers disabled.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-11 19:25:46 -04:00
Maureen Helm ca3e667ac2 drivers: sensor: Fix icm42688 build with trigger enabled
Extending tests/drivers/build_all/sensor/ to include missing driver
trigger configurations revealed that some sensor drivers failed to build
with triggers enabled.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-11 19:25:46 -04:00
Maureen Helm 6643733f26 drivers: sensor: Fix ccs811 build with trigger enabled
Extending tests/drivers/build_all/sensor/ to include missing driver
trigger configurations revealed that some sensor drivers failed to build
with triggers enabled.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-11 19:25:46 -04:00
Maureen Helm b562807d4f drivers: sensor: Fix bmi270 build with trigger enabled
Extending tests/drivers/build_all/sensor/ to include missing driver
trigger configurations revealed that some sensor drivers failed to build
with triggers enabled.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-11 19:25:46 -04:00
Weiwei Guo 08ece57b9e sensor: bmm150: Add I2C-base or SPI-base interface in build time
move DT_DRV_COMPAT to bmm150.h. so that can be decide which interface
to use.

define struct bmm150_bus_io interface for bmm150_i2c.c and bmm150_spi.c
in bmm150.h.

redefined bus operation interface in bmm150.c, this allow the driver
to decide which interface to use during construction.

Signed-off-by: Weiwei Guo <guoweiwei@syriusrobotics.com>
2023-04-11 11:26:47 +02:00
Maureen Helm da633c6148 drivers: sensor: wsen_tids: Store sensor trigger as a pointer
Fixes the wsen_tids sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm a392d8727c drivers: sensor: wsen_itds: Store sensor trigger as a pointer
Fixes the wsen_itds sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm cb28e8321e drivers: sensor: wsen_hids: Store sensor trigger as a pointer
Fixes the wsen_hids sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 078024515b drivers: sensor: vcnl4040: Store sensor trigger as a pointer
Fixes the vcnl4040 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 07632a931f drivers: sensor: tmp108: Store sensor trigger as a pointer
Fixes the tmp108 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm e43edc95d5 drivers: sensor: tmp007: Store sensor trigger as a pointer
Fixes the tmp007 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 56927686b3 drivers: sensor: sx9500: Store sensor trigger as a pointer
Fixes the sx9500 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 5ca231ae91 drivers: sensor: stts751: Store sensor trigger as a pointer
Fixes the stts751 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 4a97373f15 drivers: sensor: sm351lt: Store sensor trigger as a pointer
Fixes the sm351lt sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 0c1c77889c drivers: sensor: sht3xd: Store sensor trigger as a pointer
Fixes the sht3xd sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 6836d03dc0 drivers: sensor: qdec_nrfx: Store sensor trigger as a pointer
Fixes the qdec_nrfx sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm ddf78eb7b8 drivers: sensor: pcnt_esp32: Store sensor trigger as a pointer
Fixes the pcnt_esp32 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 19b9bb800a drivers: sensor: mpu9250: Store sensor trigger as a pointer
Fixes the mpu9250 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm b7e97e2807 drivers: sensor: mpu6050: Store sensor trigger as a pointer
Fixes the mpu6050 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 6ae88621d2 drivers: sensor: mcux_acmp: Store sensor trigger as a pointer
Fixes the mcux_acmp sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 958b7abd26 drivers: sensor: mcp9808: Store sensor trigger as a pointer
Fixes the mcp9808 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Al Semjonovs 5d4352f322 sensor: Generic driver for NTC Thermistor
Driver for NTC Thermistors attached to ADC

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2023-04-07 16:23:17 -05:00
Benjamin Lindqvist 7d23e03566 drivers: sensor: bmi270: Add support for motion, DRDY triggers
This commit adds support for ANY_MOTION and DATA_READY interrupts for
the BMI270. To implement this, a different config blob than the
"max_fifo" blob has to be used.

Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
2023-04-07 18:58:16 +02:00
Nick Ward 162c47ffc4 drivers: sensor: add mcp970x thermistor IC
Add driver for:
  MCP9700/9700A and MCP9701/9701A
  Low-Power Linear Active Thermistor ICs

http://ww1.microchip.com/downloads/en/devicedoc/20001942g.pdf

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-04-07 13:30:59 +02:00
Weiwei Guo 88f0793025 sensor: bmp388: Add I2C-base or SPI-base interface in build time
move DT_DRV_COMPAT to bmp388.h. so that can be decide which
interface to use.

define struct bmp388_bus_io interface bmp388_i2c.c and bmp388_spi.c.

redefined bus operation interface in bmp388.c, this allow the driver
to decide which interface to use during construction

Signed-off-by: Weiwei Guo <guoweiwei@syriusrobotics.com>
2023-04-07 13:14:00 +02:00
Marc Reilly d485824926 sensor: ms5837: support -02 variant
This adds support for the -02 variant, as well as the existing -30.
The sensor type is automatically read from configuration register at
device init, an appropriate compensation func is set up

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
2023-04-07 13:13:01 +02:00
Marc Reilly 99ce8cf910 sensor: ms5837. fix unsigned underflow in compensation calc
This fixes a bug where the temperature difference was being done as
unsigned and so could underflow.

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
2023-04-07 13:13:01 +02:00
Marc Reilly b4c31fd438 sensor: ms5837: pressure values in kPa
The sensor interface specifies pressure values in units of kPa, so change
here to be consistent.

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
2023-04-07 13:13:01 +02:00
Pieter De Gendt 6b532ff43e treewide: Update clock control API usage
Replace all (clock_control_subsys_t *) casts with (clock_control_subsys_t)

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-05 10:55:46 +02:00
Jeppe Odgaard 1ef0649825 drivers: sensor: mcux qdec add filter parameters
Add optional filter value properties. The filter is disabled by default
but can be enabled by setting the filter-sample-period > 0 in the dts
file. A latency is introduced if the filter is enabled. The latency can
be printed by setting sensor log level to debug.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-04-04 08:54:43 +00:00
Jeppe Odgaard 8820f95199 drivers: sensor: mcux qdec improve counts_per_revolution checks
Fix inconsistency between compile-time and runtime check on
counts_per_revolution. Add macro to simplify compile-time prop value
checks.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-04-04 08:54:43 +00:00
Fin Maaß cabc30c725 drivers: sensors: Implement MAX31865 sensor
This commit implements the temperature sensor interface for
the Maxim MAX31865 SPI Temperature Sensor.

Signed-off-by: Fin Maaß <fin.maass@haw-hamburg.de>
Co-authored-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-04-03 12:32:50 -04:00
Madhurima Paruchuri 9727cafb41 drivers: sbs_gauge: Add support for AtRate properties
BatteryMode(w), AtRate(r/w), AtRateTimeToFull(r), AtRateTimeToEmpty(r)
and AtRateOK(r)

Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
2023-04-03 17:53:42 +02:00
Peter Fecher 924ac2265d drivers: sensor: Add tmd2620 driver
Adds tmd2620 driver and devicetree bindings to work in
trigger and polling mode supporting Power management.

Signed-off-by: Peter Fecher <p.fecher@phytec.de>
2023-03-31 09:20:36 +02:00
Tom Burdick 171e5159b8 sensor: bmi160: Runtime power management support
Add support for device runtime power management. When suspended sampling
is suspended. When active sampling resumes at the configured rate.

When suspended fetch/get will return an errno and 0'ed out samples.

By default the device will start in a suspended state when
PM_DEVICE_RUNTIME is enabled.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-03-30 17:33:22 -04:00
Henrik Brix Andersen c41dd36de2 drivers: kconfig: unify menuconfig title strings
Unify the drivers/*/Kconfig menuconfig title strings to the format
"<class> [(acronym)] [bus] drivers".

Including both the full name of the driver class and an acronym makes
menuconfig more user friendly as some of the acronyms are less well-known
than others. It also improves Kconfig search, both via menuconfig and via
the generated Kconfig documentation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-28 15:06:06 +02:00
Jeppe Odgaard 40ec70fd2a drivers: sensor: mcux qdec single-phase option
Add binding and sensor attribute to allow single phase
mode where only one signal is required from the encoder.
The signal must be connected to Phase A input.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-03-27 22:13:56 +00:00
Maureen Helm 59fe77a6b4 drivers: sensor: lsm9ds0_gyro: Store sensor trigger as a pointer
Fixes the lsm9ds0_gyro sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-23 12:56:20 +01:00
Maureen Helm 0d4f0deaad drivers: sensor: lsm6dso: Store sensor trigger as a pointer
Fixes the lsm6dso sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-23 12:56:20 +01:00
Maureen Helm 1157df85a7 drivers: sensor: lsm6dsl: Store sensor trigger as a pointer
Fixes the lsm6dsl sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-23 12:56:20 +01:00
Maureen Helm 5354bffc6b drivers: sensor: lps22hh: Store sensor trigger as a pointer
Fixes the lps22hh sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-23 12:56:20 +01:00
Maureen Helm 54433a9610 drivers: sensor: lis3mdl: Store sensor trigger as a pointer
Fixes the lis3mdl sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-23 12:56:20 +01:00
Maureen Helm 8cb81ff371 drivers: sensor: lis2mdl: Store sensor trigger as a pointer
Fixes the lis2mdl sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-23 12:56:20 +01:00
Maureen Helm 363b1876f8 drivers: sensor: lis2dw12: Store sensor trigger as a pointer
Fixes the lis2dw12 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-23 12:56:20 +01:00
Maureen Helm 281f61672b drivers: sensor: lis2ds12: Store sensor trigger as a pointer
Fixes the lis2ds12 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-23 12:56:20 +01:00
Maureen Helm 5bb2323435 drivers: sensor: lis2dh: Store sensor trigger as a pointer
Fixes the lis2dh sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-23 12:56:20 +01:00
Maureen Helm 0461ff22d5 drivers: sensor: ite_vcmp_it8xxx2: Store sensor trigger as a pointer
Fixes the ite_vcmp_it8xxx2 sensor driver to store the user-supplied
sensor trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-23 12:56:20 +01:00
Maureen Helm 0ed618c609 drivers: sensor: ism330dhcx: Store sensor trigger as a pointer
Fixes the ism330dhcx sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-23 12:56:20 +01:00
Maureen Helm 16140bf485 drivers: sensor: isl29035: Store sensor trigger as a pointer
Fixes the isl29035 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-23 12:56:20 +01:00
Maureen Helm 0c3bfc2762 drivers: sensor: ina23x: Store sensor trigger as a pointer
Fixes the ina23x sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-23 12:56:20 +01:00
Maureen Helm c2951ef7c6 drivers: sensor: iis3dhhc: Store sensor trigger as a pointer
Fixes the iis3dhhc sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-23 12:56:20 +01:00
Gerson Fernando Budke dc45d7a922 drivers: sensors: qdec_sam: Update to use clock control
This update Atmel SAM QDEC driver to use clock control driver.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2023-03-21 14:12:25 -07:00
Maureen Helm b079316b4e drivers: sensor: iis2mdc: Store sensor trigger as a pointer
Fixes the iis2mdc sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm 99f9ef36af drivers: sensor: iis2iclx: Store sensor trigger as a pointer
Fixes the iis2iclx sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm 7b4ea85a0b drivers: sensor: iis2dlpc: Store sensor trigger as a pointer
Fixes the iis2dlpc sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm e0e4fa5d43 drivers: sensor: iis2dh: Store sensor trigger as a pointer
Fixes the iis2dh sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm 1ea5bb32f3 drivers: sensor: icm42605: Store sensor trigger as a pointer
Fixes the icm42605 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm 466c5501bc drivers: sensor: hts221: Store sensor trigger as a pointer
Fixes the hts221 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm 73ddc98ea0 drivers: sensor: hmc5883l: Store sensor trigger as a pointer
Fixes the hmc5883l sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm 1b05a2ce8b drivers: sensor: grow_r502a: Store sensor trigger as a pointer
Fixes the grow_r502a sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm e20357e7ac drivers: sensor: fxos8700: Store sensor trigger as a pointer
Fixes the fxos8700 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm 2a72e0eaf3 drivers: sensor: fxas21002: Store sensor trigger as a pointer
Fixes the fxas21002 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm 77cb3aeeb5 drivers: sensor: fdc2x1x: Store sensor trigger as a pointer
Fixes the fdc2x1x sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm c45595e164 drivers: sensor: ccs811: Store sensor trigger as a pointer
Fixes the ccs811 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm 9024a3cf97 drivers: sensor: bq274xx: Store sensor trigger as a pointer
Fixes the bq274xx sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm 7f59286f98 drivers: sensor: bmp388: Store sensor trigger as a pointer
Fixes the bmp388 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm eac3ac2d87 drivers: sensor: bmi160: Store sensor trigger as a pointer
Fixes the bmi160 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm 666a0dffd2 drivers: sensor: bmg160: Store sensor trigger as a pointer
Fixes the bmg160 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm 7875025cdb drivers: sensor: bmc150_magn: Store sensor trigger as a pointer
Fixes the bmc150_magn sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm ad07044679 drivers: sensor: bma280: Store sensor trigger as a pointer
Fixes the bma280 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm 9d74370e74 drivers: sensor: amg88xx: Store sensor trigger as a pointer
Fixes the amg88xx sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm a8b74ff5e7 drivers: sensor: adxl372: Store sensor trigger as a pointer
Fixes the adxl372 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm cb51090d3a drivers: sensor: adxl362: Store sensor trigger as a pointer
Fixes the adxl362 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Maureen Helm ae5342afba drivers: sensor: adt7420: Store sensor trigger as a pointer
Fixes the adt7420 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-03-20 09:52:35 +01:00
Oleg Ryjkov c194cb76ad drivers: sensor: bmi270: Use bulk SPI reads
BMI270 supports bulk register reads, use them to make
trasnfers faster.
See the discussion on
6cbb84c3ee (r104543405)
Tested on an nrf52840 board connected to a bmi270 sensor via SPI.

Signed-off-by: Oleg Ryjkov <oryjkov@gmail.com>
2023-03-17 13:17:08 -05:00
Nick Ward f3cbd34d3f drivers: sensor: bq274xx: add CONFIG_BQ274XX_PM
This symbol allows users of the driver to disable the
power management feature of just this sensor if they are
not using the int_gpios pin of the BQ274XX.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-03-16 21:40:18 -04:00
Michael Kaplan a818d06cf2 drivers: sensors: apds9960 fix trigger callback context
In the current implementation, the apds9960 trigger callback function
is called with the pointer of a driver-internal allocated trigger
structure. This structure is not initialized anywhere, so essentially
the trigger callback gets called with junk data.

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

Signed-off-by: Michael Kaplan <m.kaplan@evva.com>
2023-03-15 22:39:45 +00:00
Andrei Emeltchenko 4bb9ad929f drivers: fxos8700: Remove unneeded assignment
Remove unneeded assignment fixing issue with using uninitialized
variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-03-15 09:12:22 +01:00
Yuval Peress d6c45ad27b sensor: implement drdy trigger for icm42688
Add support for the data ready trigger in the icm42688 driver.

Signed-off-by: Yuval Peress <peress@google.com>
2023-03-06 10:44:52 -06:00
Mark Watson 1f178ca935 drivers: sensor: VL53L1X time-of-flight sensor.
The driver utilizes ST Microelectronics library (which
exists in modules\hal\st\sensor\vl53l1x. Platform specific
headers and source files used by the library are included
and adapted for Zephyr.

The driver can be configured in proj.conf to use a
interrupt/polling methods and the use of the XSHUT pin on
the VL53L1X. All uses were tested successfully.

Signed-off-by: Mark Watson <mwatson@prosaris.ca>
2023-03-03 10:01:55 -06:00
Matthias Hauser d4e9e5f46c drivers: sensor: Added driver for the Würth Elektronik WSEN-TIDS sensor
Added sample for the WSEN-TIDS temperature sensor.

Signed-off-by: Matthias Hauser <Matthias.Hauser@we-online.de>
2023-03-03 11:01:10 +01:00
Jeppe Odgaard 9a2997fac9 drivers: sensor: mcux qdec rework rotation
Remove modulus feature and return degrees larger than
count_per_revolution.
This makes it possible to detect if a full rotation has occured.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-03-03 10:59:55 +01:00
Aaron Massey 1657860320 emul: Fix endianness fault in sbs gauge emulator
The sbs gauge emulator intercepts SMBus messages for an sbs gauge
compatible IC. However, it was incorrectly interpreting the byte order of
received register write values based on the endianness of the SoC
architecture instead of SMBus' defined little-endianness. This fault was
not caught earlier because native posix and the majority of qemu
architectures use little-endian.

Explicitly interpret the write values as little-endian.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-03-02 21:14:44 +01:00
Ruibin Chang f77f02c032 ITE drivers/sensor/vcmp/it8xxx2: add work queue for voltage comparator
Voltage comparator driver submits notifications into system work queue,
this change will make driver to use dedicated work queue, and priority
of dedicated work queue are configurable as well.

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2023-03-01 09:12:49 -06:00
Benjamin Cabé ca90bdacf3 drivers: sensor: th02: Handle unsupported channels
Fixed th02_channel_get() code to return -ENOTSUP when the channel is not
supported.
Fixes #55160.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-02-28 10:58:52 -06:00
Gerard Marull-Paretas 27b73a116f soc: arm: nordic_nrf: replace NRF_DT_CHECK_PIN_ASSIGNMENTS
Since PINCTRL and pinctrl-0 is now required, there's no point in doing
extra validation at driver level. Modify the macro to just check that
sleep state is present when needed, since it was the only remaining
assertion that was not covered. Renamed the macro to make it more clear
what it does: NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-02-28 08:42:05 -08:00
Gerard Marull-Paretas 401334446d drivers: sensor: qdec_nrfx: drop -pin support
QDEC driver will only use pinctrl now.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-02-28 08:42:05 -08:00
Yuval Peress ebfd9aaba5 sensor: Implement driver and tests for akm09918c
Add the implementation for the akm09918c magnetometer driver.
Additionally, add the appropriate node to the TDK robokit1 device
tree. In order to prevent regressions, add the sensor to the sensor
build_all tests and specific tests using an emulator.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 17:00:14 -05:00
Yuval Peress 0e003cdbee test: verify accel/gyro data for icm42688
Verify the conversion of register values in both accel and gyro to
sensor_value for the icm42688.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress e6514d4dc9 icm42688: Add test for data read and temperature regisers
Add tests that verify the behavior of the REG_INT_STATUS, REG_TEMP_DATA1,
and REG_TEMP_DATA0 registers

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress 591958752a icm42688: fix configure call
The icm42688 introduced a safe configure function to make the
configuration more atomic, but the main driver was never updated
to call it so the new config values were discarded.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress a3f59fd86f icm42688: Fix temperature calculation
Fix the calculation which was adding the 25 degree offset too late.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress 8ac822e69c emul: Cleanup emul directory
Avoid implementations in the subsys emul directory to keep the directory
focused on emulator subsystem instead of consumers. Consumers should be
implemented side-by-side to their drivers

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress a6326f1f7f bmi160: move emulator to driver directory
Allow the emulator to sit in the same directory as the driver
implementation. This will make working on the emulator much easier and
keep the emulator subsystem directory clean by allowing it to focus on
the actual subsystem and not the use cases of the subsystem.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress 2bb4de9a0b emul: Add emulator for icm426888
Add an implementation for the icm42688 emulator that supports reading
any registers.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Garrett Battaglia 65e3f5b23d drivers: sensor: add MAX31855
add MAX31855 cold-junction compensated thermocouple-to-digital
converter sensor driver and sample

Signed-off-by: Garrett Battaglia <garrett@garrettbattaglia.com>
2023-02-23 09:06:28 +01:00
Tim Lin 00e6c19ab5 ITE: drivers/adc: Add config of ADC reference voltage full-scale 3300mV
This option can enable ADC internal reference voltage as
full-scale 3300mV.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-02-23 08:59:54 +01:00
Tom Burdick 2ae6b7bd75 sensor: icm42688 configuration and regmap fixes
The int config and fifo config register addresses were wrong, fix those.

Adds lots of debug information (when LOG_DBG=y) to the configuration of the
device which is incredibly helpful for diagnosing configuration issues.

Disables the device interrupts while reconfiguring. Adds a safely
reconfigure function which will rollback to previous configuration
on misconfiguration.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-02-22 08:51:30 +01:00
Andriy Gelman 0079cabb49 drivers: sensor: Add infineon xmc4xxx die temperature sensor
Adds die temperature driver for infineon xmc4xxx SoCs.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2023-02-20 11:14:15 +01:00
Giuliano Franchetto 67767df8c0 drivers: iis2dlpc: adding activity interrupt
This commit adds the activity/inactivity recognition as well as the
stationary/motion detection as defined in the IIS2DLPC application
note.

For now, there is no possibility to configure this interrupt using
device tree binding, as I would like to keep the configuration updatable
and not set at boot time. This behaviour is fine for prototypes and
samples, but is too restrictive on products that may want to change the
interrupt configuration at run-time.

The interrupt is configured using the attributes SENSOR_ATTR_SLOPE_TH and
SENSOR_ATTR_SLOPE_DUR.

Signed-off-by: Giuliano Franchetto <giuliano.franchetto@intellinium.com>
2023-02-19 20:55:09 -05:00
Michal morsisko 2e4d8761be drivers: sensor: Add support for BH1750 ambient light sensor
This commit adds support for BH1750 ambient light sensor.
The driver works using I2C peripheral in one-time mode.

Signed-off-by: Michal morsisko <morsisko@gmail.com>
2023-02-19 20:44:34 -05:00
Zhang Lixu b67e33fc50 sensor: bmi160: fix the issue of missing gpio cfg for i2c
Add BMI160_TRIGGER_CFG in bmi160_cfg for i2c instance when
trigger mode enabled.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2023-02-19 20:41:56 -05:00
Zhang Lixu 21436b27bf sensor: bmi160: fix the issue with interrupt status
When enabling trigger mode of bmi160 on i2c bus, I've come across
an issue where the readings register STATUS. The issue comes from
the dummy byte in the beginning of the buf.raw which is not necessary.
In addition, for bmi160 on spi bus, the dummy byte has already been
handled in bmi160_transceive while reading register.
So the dummy byte should be removed.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2023-02-19 20:41:56 -05:00
Wouter Cappelle 0934f705eb sensor: SHT3x: Fix low repeatability in single shot mode
Fix the low readability read command which was swapped with high
readability. This should fix an issue which caused a sensor fetch
fail in low repeatability single shot mode (no data ready)

Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
2023-01-27 18:11:02 +09:00
Yuval Peress e7443bb203 sensors: Add attribute configuration for icm42688
Implement the attribute get/set for the icm426888

Signed-off-by: Yuval Peress <peress@google.com>
2023-01-25 09:48:05 -06:00
Yuval Peress ad4cb88494 sensor_shell: add attribute support
Add 2 new sub-commands to the sensor command (attr_get and attr_set).
These commands can be used to access the driver's attr_set and attr_get
functions.

Signed-off-by: Yuval Peress <peress@google.com>
2023-01-25 09:48:05 -06:00
Yuval Peress 3f4c568f71 sensor_shell: run clang-format
Run clang-format on the sensor_shell.c to make diffs easier for the
next commit.

Signed-off-by: Yuval Peress <peress@google.com>
2023-01-25 09:48:05 -06:00
Jeppe Odgaard a76b908f4c drivers: sensor: add mcux quadrature encoder
Add a driver for the NXP MCUX Quadrature Decoder. The driver
is simple and only implements the phase a and phase b inputs. The
module has additional features which can be added in future PRs.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-01-24 10:21:39 -06:00
Benjamin Lindqvist 7ffc200820 drivers: sensor: bmi270: don't force val2 > 0
The struct sensor_value type does NOT require val2 to be positive. The
removed code is in fact a rather serious bug, probably put in place
because it makes printing sensor_values easier.

Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
2023-01-23 12:02:30 -08:00
Trent Piepho c45bc68e5c drivers/sensor: lsm6dso: Remove busy wait on bank change
It's not necessary to busy wait 150 µs after changing register banks.
Nothing in the data sheet nor app note suggests this.  ST's own HAL,
which is used by this driver, does not delay when changing banks.  It
does a bank change around every function that accesses a non-user bank
register (it's quite inefficient).

So if it was necessary it would be broken now, as most of the bank
changes have no delay.

One of the few page changes that did have this delay are the those done
before and after reading a sensor sample.  Which is where the speed is
significant and is limiting the update rate the driver is capable of.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho 0cfe9560d9 drivers/sensor: lsm6dso: Remove unneeded read/modify/write in shub read
The code in the ST HAL does a read/modify/write to change the bits in
the LSM6DSO_FUNC_CFG_ACCESS register that control which register bank is
active.

All the other bits in the register are defined as zero.  It's possible
to simply set the register to the desired value without reading the
contents first.

This bank switch needs to be done twice for every sensor read when the
sensor hub is used.  The driver as it is can not keep up with the higher
update rates of the lsm6dso.  So any speed increase in this code allows
for a higher update rate as well as reduced latency.

Previously, a read of the lsm6dso's accel and gyro on a 400 kHz I2C bus
with a 3-axis magnetometer on the sensor hub takes 2.69 ms.  This drops
that to 2.26 ms.  This is enough to support the 417 Hz ODR.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho 8e80661db7 drivers/sensor: lsm6dso: Fix shub init and configuration failures
There is a flaw with I2C communication to peripherals behind the shub
that causes sporadic failures.  Especially calls to configure a device
after the lsm6dso initialization is finished, e.g. to set the ODR, can
fail to work correctly.

Access to shub peripheral registers is done by putting the parameters of
the operation into SLV0 and then waiting for the lsm6dso to perform the
xfer on the shub I2C bus.  The lsm6dso does this in sync with the
accelerometer update rate.  Once the shub is enabled, it peforms the
xfer repeatedly as the accelermeter is sampled.

The wait has a problem:  It might detect that a previous shub xfer has
finished, which was done before SLV0 was programmed with new parameters.

The shub status register is read-to-clear.  This isn't in the data sheet
or app note, but it is.  By reading the status before enabling the
sensor and after programming SLV0, we can be sure when it becomes set it
has finished the current operation and not a previous one.

Also set the write-once flag before shub init.  This causes the shub to
only perform I2C writes once instead of continuously.  This was set at
the end of init, so any writes done during it would repeat until the
shub was disabled.

Put a timeout in the code that polls for the sensor hub op complete.  It
could possibly poll forever.  More importantly, if there is no device
connected to the sensor hub, the lsm6dso does not timeout on the
operation for ~13 seconds.  Since the shub init does a probe for devices
on startup, this will happen if shub support is enabled but a lsm6dso
has no sensor hub devices.  There could be multiple devices, some with
additional sensors and some without.  Initialization of the devices
without additional sensors takes tens of seconds without this timeout
being added.

Add a 300 µs wait after disabling the sensor hub.  This is necessary
according to the ST app note AN5192 §7.2.1.

Read the shub status from the main bank register instead of the shub
bank register.  This avoids an extra bank switch before and after each
status poll.  Actually two bank switches on each side, since the lsm6dso
driver switched banks and then the ST HAL function to get the status
register switches again.

The wait for the shub I2C transaction to finish is not needed when the
shub is enabled at the end of init.  We aren't starting a new I2C write
or reading the result of a read.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho c379f86dbd drivers/sensor: lsm6dso: Set to user bank on init
The lsm6dso initialization will fail if the device is not already set to
the user register bank.  All the registers used will be the wrong ones
from whatever bank it is in, e.g. sensor hub bank.  This includes the
registers to reset the device!

The bank will default to the user bank on reset, but the chip has no
hardware reset line.  On a reboot it will be in whatever bank it was
last in.  If the sensor hub is enabled, it will switch banks on every
sample, so it's entirely possible to reset or reboot when it happens
to be set to the sensor hub bank, which will cause the driver to
fail to initialize.  It will not work again until the lsm6dso is power
cycled.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho 25579d95b1 drivers/sensor: lsm6dso: Disable sensor hub before reset
Per an ST app note, the sensor hub I2C controller should be disabled
before doing a software reset.  Possibly, this is because the sensor hub
could be in the middle of the an I2C transaction to a sensor when it is
reset.  Disabling it and then waiting makes sure it has quiesced before
resetting.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho 7cf6d75a11 drivers/sensor: lsm6dso: Move interrupt config to after chip reset
The initialization code would configure the lsm6dso interrupt, then
configure the rest of the chip.  The chip init includes a reset that
would undo the register setting done during interrupt configuration.

It's also not a good idea to enable the interrupt on the SoC when the
lsm6dso has not yet been reset or configured.  It might be generating
interrupts.

The lsm6dso has no hardware reset line, so it will not be reset on
reboot unless a power cycle is involved.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho d14732b541 drivers/sensor: lsm6dso: Set thread name
When the driver creates its own thread, set the name.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
TOKITA Hiroshi 10ef1a7cba drivers: sensors: Add support for RaspberryPi Pico CPU temperature
Support for the measuring the CPU die temperature
for the RaspberryPi Pico.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-01-19 15:32:41 -06:00
Felipe Neves cd04926d6b sensors: as5600: added as5600
magnetic angle sensor driver.

Signed-off-by: Felipe Neves <felipe.neves@linaro.org>
2023-01-19 15:18:24 -06:00
Tom Burdick 15786ce648 sensor: tdk 42688 driver
Adds a driver for TDK InvenSense 42688 six axis IMU. Verified using
the sensor shell sample app via:

- sensor info
- sensor get icm42688p@0

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Signed-off-by: Yuval Peress <peress@google.com>
2023-01-10 14:45:36 -06:00
Mizuki Agawa 687d1f0ae5 drivers: sensor: Add support ICP10125 pressure and temperature sensor
Product Homepage:
https://invensense.tdk.com/products/1-axis/icp-10125/

DataSheet:
https://3cfeqx1hf82y3xcoull08ihx-wpengine.netdna-ssl.com/wp-content/uploads/2021/04/DS-000329-ICP-10125-v1.1.pdf

Testing Environment:
STMicroelectronics NUCLEO-F401RE

Signed-off-by: Mizuki Agawa <agawa.mizuki@fujitsu.com>
2022-12-28 10:44:16 +01:00
Marek Matej 45d55205db drivers: esp32: temp: CPU die temperature sensor
Support for the measuring the CPU die temperature
for the ESP32 targets S2,C3. The ESP32 support
was ommited due to lack of offset calibration.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2022-12-15 18:21:39 +01:00
Dinesh Kumar K f050e18798 drivers: sensor: Add support for grow_r502a fingerprint sensor
Add driver support for grow_r502a fingerprint sensor

Signed-off-by: Dinesh Kumar K <dinesh@linumiz.com>
2022-12-14 18:44:29 +01:00
Marco Argiolas 3540ae1df9 drivers: sensor: bmm150: fix mispelling
Build error appearing only when enabling CONFIG_BMM150_PRESET_LOW_POWER

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2022-12-12 10:54:40 -06:00
Bartosz Bilas e077fb73ec drivers: tests: replace usage of spi_is_ready with spi_is_ready_dt
`spi_is_ready` function is being deprecated in favor of
`spi_is_ready_dt` so let's replace the old usage in the tree.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-12-07 09:40:23 -06:00
Armando Visconti 20ea61be35 drivers/sensor: lsm6dso: Add drdy_pulsed property in DT
Add drdy_pulsed property in Device Tree in order to select how
data ready irq should behave (either pulsed or latched mode).
Moreover change/fix the API called to set drdy irq mode.
(fix #51944)

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2022-11-25 20:03:21 +01:00
Anas Nashif cffe98d9de crc: Make the build of crc function dependent on a Kconfig
Add CONFIG_CRC for building CRC related routines.
CRC routines are now being built for each application, whether used or
not and are add in the build system unconditionally.

Keep CONFIG_CRC enabled by default for now and until all users have
converted to use the new option.

Partial fix for #50654

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-23 13:30:00 +01:00
Philipp Schilk 6a93975dd7 drivers: sensors: Fix MAX30101 Kconfig description.
Fixes a small typo in the MAX30101 Kconfig file.
The MAX30101_LED3_PA config option mistakenly referd to LED2 in it's
comment.

Signed-off-by: Philipp Schilk <schilk.philipp@gmail.com>
2022-11-22 13:07:03 +09:00
Nick Ward de9a665b31 drivers: sensor: vcnl4040: other small improvements
Fixes the double up test of int_gpio.port.
Addition of VCNL4040_ALS_INT_EN macros.
Use of BIT() macro where it makes sense.
MISRA improvements.

Signed-off-by: Nick Ward <nick.ward@ftpsolutions.com.au>
2022-11-20 12:12:23 +01:00
Nick Ward 3abd63c093 drivers: sensor: vcnl4040: use mutex for locking
Saves some flash and we get priority inheritance.

Also removes lock from vcnl4040_handle_int() as it
is always called from the same thread.

Signed-off-by: Nick Ward <nick.ward@ftpsolutions.com.au>
2022-11-20 12:12:23 +01:00
Nick Ward db8ecd5ec8 drivers: sensor: vcnl4040: fix sensor register init
The driver has a read register, modify value, write value flow due to
needing to modify nibbles of registers at different times.  The issue
this driver previously had was new incoming configurations from the
driver would be corrupted by previous configurations written into the
vcnl4040 (when there's been no power off). This would be in the case
when a device continuously power on and a developer is tweaking the
vcnl4040's configuration or when deploying firmware updates with
a new vcnl4040 configuration.

Signed-off-by: Nick Ward <nick.ward@ftpsolutions.com.au>
2022-11-20 12:12:23 +01:00
Nick Ward d8c107e166 drivers: sensor: vcnl4040: fix I2C write function
The driver was using the i2c_transfer_dt() API incorrectly by not using the
I2C_MSG_STOP flag in the flags field.

The I2C write function can be written more simply with the basic I2C write
API so this commit also switches the code to the basic I2C write API to fix
this bug.

Signed-off-by: Nick Ward <nick.ward@ftpsolutions.com.au>
2022-11-20 12:12:23 +01:00
Kiril Petrov 5801ab2231 drivers: sensors: lis2dh: add attr to set HP filters
Add ability to set High Pass filter on AOI function on interrupt 1 or 2.

Signed-off-by: Kiril Petrov <retfie@gmail.com>
2022-11-18 10:46:52 -06:00
Benjamin Perseghetti 3906860a8f drivers: fxas21002 enablement for SPI and I2C
Added support for fxas21002 sensor over SPI and I2C.
Made the fxas driver APIs generic for I2C and SPI.
Tested with fxas21002 sensor on RDDRONE.

Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
Co-authored-by: Sumit Batra <sumit.batra@nxp.com>
2022-11-16 10:18:46 -06:00
Benjamin Perseghetti 2870b38379 drivers: fxos8700 enablement for SPI and I2C
Added support for fxos8700 sensor over SPI and I2C.
Made the fxos driver APIs generic for I2C and SPI.
Tested with fxos8700 sensor on RDDRONE.

Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
Co-authored-by: Sumit Batra <sumit.batra@nxp.com>
2022-11-16 10:18:46 -06:00
Gerard Marull-Paretas af722062c1 drivers: sensor: ina23x: s/irq-gpios/alert-gpios
The sensor uses the ALERT terminology (pin can be configured to trigger
on certain events such as conversion ready or overvoltage alerts). The
"IRQ" name is not clear.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-15 10:23:17 +01:00
Gerard Marull-Paretas d5734bc003 drivers: sensor: ina23x: specify current LSB in uA and fix units
Specify the units of the current LSB in microamperes, so that we can
measure low maximum currents. Right now it was specified in
milliamperes, but ignored and always hardcoded to 1mA in the driver.
This makes the driver pretty much useless when the maximum current to be
measured is in a range of e.g. 20-50mA.

This patch also removes some unnecessary ifdeffery: since we write the
calibration register, we can always provice measurements with the right
units. It is also wrong to provide sensor readings that do not match
with the units specified by the channel. After this change voltage is
always reported in V, current in A and power in W.

Note that power measurement had the current LSB hardcoded in the
calculation (assuming 1mA/LSB), this has been fixed as well.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-15 10:23:17 +01:00
Gerard Marull-Paretas d7e1e44320 drivers: sensor: ina23x: improve voltage reading code
Adjusted LSB factor to be un uV/LSB to make calculations more clear.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-15 10:23:17 +01:00
Gerard Marull-Paretas a79f5b87c0 drivers: sensor: ina23x: s/rshunt/rshunt-milliohms
Following dtschema practices, add phyisical units to the shunt resistor
value: milliohms.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-15 10:23:17 +01:00
Gerard Marull-Paretas af03ad33e1 drivers: sensor: ina23x: remove redundant build asserts
With the recent introduction of DT_HAS* Kconfig helpers, such build
asserts are highly unlikely, so just remove them.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-15 10:23:17 +01:00
Gerard Marull-Paretas a34158f386 drivers: sensor: ina23x: delete redundant Doxygen docs
Driver had Doxygen stubs for sensor interface calls. First, most were
incomplete, outdated or just wrong. Second, implementations just need to
make sure to adhere to the error codes documented in the public
interface (sensor API in this case).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-15 10:23:17 +01:00
Gerard Marull-Paretas 35eabfcdf0 drivers: ina23x: fix includes
- Add many missing includes so that headers are self-contained
- Sort includes properly (locals first, stdc, zephyr, etc.)

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-15 10:23:17 +01:00
Marco Argiolas be4ee1edef drivers: sensor: sensor_shell: fix channel name collision
Channel SENSOR_CHAN_GAUGE_FULL_CHARGE_CAPACITY was returned in place of
SENSOR_CHAN_GAUGE_FULL_AVAIL_CAPACITY, due to their matching names.
Ensuring that the channel names are unique fixes the issue.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2022-11-09 09:44:27 -06:00
Armando Visconti 2217608c1c drivers/sensor: Call the correct stmemc API to set drdy_pulsed
Call lis2dw12_data_ready_mode_set() API in order to properly
set CLTR7.drdy_pulsed bit.
(Fix #51488)

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2022-11-08 10:45:32 +01:00
Maureen Helm 0ddc2a9b65 drivers: sensor: Remove brackets from sensor info shell command output
Brackets were originally used in the sensor info shell command output to
make it obvious when a field is a null string, however they incorrectly
suggest that a field is an array. Remove the brackets and conditionally
print "(null)" instead.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-11-02 15:40:24 +09:00
Erdem Efe 0e05686d52 sensor: freefall added to lis2dw12 sensor driver.
lis2dw12 supports freefall detection and set related parameters

Signed-off-by: Erdem Efe <erdemefe1@gmail.com>
2022-11-01 08:25:24 -05:00
Parthiban Nallathambi 12eb38c5a5 sensor: dht: fix code stlying
fix indent, change space to tab

Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
2022-10-31 09:28:05 -05:00
Maureen Helm 97defe7095 drivers: sensor: Add shell command to get sensor info iterable section
Adds a new conditional shell command to the sensor shell to get data
from the sensor info iterable section, such as vendor and model name,
for all sensors.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-10-31 11:21:37 +01:00
Maureen Helm eee3d8f566 drivers: sensor: Add sensor info iterable section
Adds an iterable section in ROM to hold constant information, such as
vendor and model name, for all enabled sensor driver instances. This
will be used by the future sensor subsystem to enumerate all available
sensors in the system.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-10-31 11:21:37 +01:00
Maureen Helm a9b223b26b drivers: sensor: Refactor drivers to use SENSOR_DEVICE_DT_INST_DEFINE
Refactors all sensor drivers to use SENSOR_DEVICE_DT_INST_DEFINE, which
is a sensor-specific variant of DEVICE_DT_INST_DEFINE that provides a
common place to instantiate additional data structures for the future
sensor subsystem and/or sensor driver stats.

This approach was inspired by I2C_DEVICE_DT_INST_DEFINE to streamline
adding I2C stats support across all I2C drivers.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-10-27 09:27:14 +00:00
Mehdi Zemzem e8457de662 drivers: sensor: iis2dh: Add macro DT_DRV_COMPAT to iis2dh_trigger.c
Without this define, the structure iis2dh_device_config
is defined incorrectly.

The structure is defined in iis2dh.h file as follows:
struct iis2dh_device_config {
	struct spi_dt_spec spi;
	struct i2c_dt_spec i2c;
	uint8_t pm;
	struct gpio_dt_spec int_gpio;
};

without the macro

the structure is defined as
struct iis2dh_device_config {
 uint8_t pm;
 struct gpio_dt_spec int_gpio;
};

which results in accessing the wrong data when
calling iis2dh_init_interrupt
function (or any other functions in this file)

Signed-off-by: Mehdi Zemzem <mehdi.zemzem2@gmail.com>
2022-10-26 15:58:26 -05:00
Bernardo Perez Priego 810809f96b driver: adc: npcx: enable adding work queue for adc comparator
ADC comparator driver submits notifications into system work queue, this
change will make driver to use dedicated work queue instead by using
`CONFIG_ADC_CMP_NPCX_WORKQUEUE`.

Dedicated work queue and priority are configurable as well.

Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
2022-10-21 10:29:30 -05:00
Simen S. Røstad b231415343 ADXL362: Do not clear last bits of 16-bit inactivity time value
The inactivity time registers identified by `ADXL362_REG_TIME_INACT_L`
and `ADXL362_REG_TIME_INACT_H` accepts a 16-bit value. (8 in each).
Without this change the last 5 bits of the register value
will be cleared.

Clearing the last bits of the register value greatly reduces the maximum
inactivity time that can be set.

Signed-off-by: Simen S. Røstad <simen.rostad@nordicsemi.no>
2022-10-18 14:11:53 +02:00
Gerard Marull-Paretas 178bdc4afc include: add missing zephyr/irq.h include
Change automated searching for files using "IRQ_CONNECT()" API not
including <zephyr/irq.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 22:57:39 +09:00
Anas Nashif 3d85ae37b6 arm: add missing includes
Add missing includes that were previously included indirectly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-11 18:37:53 -04:00
Gerard Marull-Paretas 6a0f554ffa include: add missing kernel.h include
Some files make use of Kernel APIs without including kernel.h, fix this
problem.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Carles Cufi e50a859625 drivers: sensor: qdec_nrfx: Fix build with no optimizations
The build of this driver fails when `CONFIG_NO_OPTIMIZATIONS=y` is set:

error: expression in static assertion is not constant
   98 |  BUILD_ASSERT(steps > 0, "only positive number valid");

error: expression in static assertion is not constant
   99 |  BUILD_ASSERT(steps <= 2048, "overflow possible");

Fix this by using a simple macro to avoid the compiler from getting
confused.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-10-11 11:07:28 +02:00
James Johnson 0eaff5a11d drivers: sensor: add ams AS621x Temperature Sensor driver support
Added support for the AMS AS621x series of temperature sensors as a
variant of the TI TMP108 temperature sensor.

Signed-off-by: Jared Baumann <jared.baumann8@t-mobile.com>
Signed-off-by: James Johnson <james.johnson672@t-mobile.com>
2022-10-07 10:01:47 +02:00
Pieter De Gendt 70e99fe575 drivers: sensor: lis2dh: Configurable latch and mode for any movement
Add 2 properties to configure the "any movement" event.
* Ability to disable the interrupt latch
* Select movement mode

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-10-03 10:11:45 +02:00
Valerio Setti 1b78f2dfbd drivers: sensor: adding driver for STM32 quadrature encoder
This driver configures STM32's internal timers in order to use
the quadrature encoder mode.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2022-10-03 10:10:31 +02:00
Dominik Chat 67c6f26c93 sensor: Refactor bmi270 driver data names
Make driver data names consistent in code.

Signed-off-by: Dominik Chat <dominik.chat@nordicsemi.no>
2022-10-03 10:06:46 +02:00
Dominik Chat 6cbb84c3ee sensor: dts: Add SPI capability to bmi270 driver
Added SPI bus support for BMI270 gyroscope driver.

Signed-off-by: Dominik Chat <dominik.chat@nordicsemi.no>
2022-10-03 10:06:46 +02:00
William MARTIN 8bbe016f46 drivers: Fix BMI270 initialization
On power on reset, after disable advanced power safe mode,
you need to wait a delay before write again in the device.
The missing wait produce random initialization failure.
See §4.4 of the datasheet "bst-bmi270-ds000.pdf"

Signed-off-by: William MARTIN <william.martin@power-lan.com>
2022-09-23 12:08:24 +02:00
Antoniu Miclaus 9dda350e24 drivers: sensor: adxl372: update driver
Handle SPI/I2c interface in the dts.

Support multiple instances.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
2022-09-21 18:40:06 +00:00
Daniel Leung 34ccd88c12 sensor: lps22hh: extend to support being on I3C bus
This extends the lps22hh driver to support being on I3C bus.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-09-09 17:42:33 -04:00
Daniel Leung eb9cd9242c sensors: stmemsc: add I3C access functions
This adds I3C access functions so that STM sensors connected
on I3C bus can utilize I3C.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-09-09 17:42:33 -04:00
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Adrian Wojak fb57a4876f drivers: sensor: lsm6dsl: disable high performance in initialization
To reduce energy consumption for accel and gyro frequencies 52 Hz and
lower, disable high performance mode by default.
It doesn't affect for higher frequencies.

Signed-off-by: Adrian Wojak <adrian.wojak@grinn-global.com>
2022-09-01 13:19:08 -05:00
Erwan Gouriou aa8a89a216 drivers: sensors: hts221: Fix trigger mode
1. Use #ifdef around CONFIG_HTS221_TRIGGER instead of #if

2. According to binding (which is in line with datasheet), name of the pin
used for trigger mode should be drdy, not irq.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-09-01 13:15:14 -05:00
Bartosz Bilas d6cf6e7bb2 dt-bindings: sensor: ina237: rename the operating modes
Adjust the names of the operating modes to match them
with the datasheet and INA230 pattern. While at it add
the missing INA237_OPER_MODE_TEMP_TRIG mode.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2022-08-31 21:51:14 +00:00
Yannick Thesen 754c578d79 drivers: sensor: Added driver for the Würth Elektronik WSEN-HIDS sensor.
Added driver for the WSEN-HIDS humidity and temperature sensor.

Signed-off-by: Yannick Thesen <Yannick.Thesen@we-online.de>
2022-08-31 21:47:58 +00:00
Holger Schurig 331572b3f2 drivers: sensors: fix DRDY usage
hts221_trigger.c is pulled in by the CMakeLists.txt file when
CONFIG_HTS221_TRIGGER is defined. Therefore make the source in hts221.c use
the some define.

This removes also the (wrong) warning

    <inf> HTS221: Cannot enable trigger without drdy-gpios

even when "drdy-gpios" is defined in the device-tree.

Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
2022-08-30 10:26:09 +02:00
TLIG Dhaou 546218ad2b drivers: sensor: stm32_temp add the ts cal resolution to the driver
Add the ts cal resolution in the driver in order to calculate temperature
value.

Signed-off-by: TLIG Dhaou <dhaou.tlig-ext@st.com>
2022-08-24 11:35:45 +02:00
Bartosz Bilas 755c0d57e8 drivers: sensor: ina237: add support for triggered mode
Add missing support for the triggered mode using GPIO
interrupt alert pin. It uses mode detection at runtime
which allows working multiple sensors with different
modes simultaneously.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2022-08-22 19:38:06 +02:00
Gerard Marull-Paretas a202341958 devices: constify device pointers initialized at compile time
Many device pointers are initialized at compile and never changed. This
means that the device pointer can be constified (immutable).

Automated using:

```
perl -i -pe 's/const struct device \*(?!const)(.*)= DEVICE/const struct
device *const $1= DEVICE/g' **/*.c
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-22 17:08:26 +02:00
Andrzej Głąbek ca4d8cf4ab drivers: sensor: mpu9250: Fix initialization routine
Fix a call that writes Register 29 - Accelerometer Configuration 2.
Due to an obvious copy-paste mistake in the code, this register was
written with a DLPF setting from devicetree intended for gyroscope,
not for accelerometer (and the latter was effectively ignored).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-08-18 16:08:23 +02:00
Jan Kuliga 2ddd221120 bme680: Rework setting the spi_mem_page accordingly to the datasheet
According to the BME680 datasheet, only the spi_mem_page bit can be
changed in its 8-bit register. Therefore we shouldn't just write 0s
to the remaining bits, but update the register content in read-modify-write
fashion instead.
Rework the bme680_set_mem_page(), bme680_init() and register-access
macros.

Signed-off-by: Jan Kuliga <jtkuliga@gmail.com>
2022-08-18 12:44:18 +02:00
Fabio Baltieri 0cba9cb8e9 drivers: sensor: max17055: add VFOCV support
Add support for reading the VFOCV register, which contains the model
estimated open circuit voltage for the cell.

Link: https://pdfserv.maximintegrated.com/en/an/AN6358.pdf
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-18 12:39:20 +02:00
Maureen Helm 0514c3b139 drivers: sensor: Fix apds9960 device pointer initialization
Fixes a bus fault observed in samples/boards/reel_board/mesh_badge
caused by dereferencing an uninitialized device pointer in the apds9960
sensor driver. The device pointer needs to be initialized regardless of
how CONFIG_APDS9960_TRIGGER is configured.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-08-16 14:11:30 +00:00
Jamie McCrae 9433555f0d drivers: sensor: adxl372: Fix default bus issue
The adxl372 device does not select the correct bus that it is on, which
causes undefined operation (usually a fault). This driver should not be
using Kconfig to determine which bus to use, that should be done by
dts, however this works as a quick fix in the interim until the driver
can be fixed properly.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-08-12 17:39:28 +02:00
TOKITA Hiroshi a70627a621 drivers: sensor: adxl345: Correct converting counts to sensor value
Sensor value unit is [m/s^2].
Currently calcs as [g/1000] unit.

Correcting calculation to convert [m/s^2].
Store the integer part to val1, and the fractional part to val2.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2022-08-10 10:54:16 -05:00
Henrik Brix Andersen 78dd25e79e drivers: sensor: check if clock device is ready before accessing
Add check for device_is_ready() before accessing clock control devices.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-09 17:16:16 +02:00
Gerard Marull-Paretas a7c3e7e84a doxygen: remove redundant usages of def
The def command Indicates that a comment block contains documentation
for a #define macro. This is useful if the comment block documents a
macro not adjacent to it, e.g.

```c
/**
 * @def MAX(x,y)
 * @brief Computes the maximum of @a x and @a y.
 */
 #ifdef XXX
 #define MAX(x,y) ...
 #endif
```

However, it is not necessary if the comment is adjacent to the
definition, e.g.

```c
/**
 * @brief Computes the maximum of @a x and @a y.
 */
 #define MAX(x,y) ...
```

This patch removes all unnecessary def entries in-tree.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-09 12:29:28 +02:00
Lucas Tamborrino ffa1c92131 drivers: sensor: esp32: pcnt driver
Add new pcnt peripheral driver.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2022-08-08 10:51:41 +02:00
Kumar Gala df81fef944 drivers: sensor: Convert Kconfig bus 'depends on' to 'select'
This change in pattern is meant to address a misconfiguration issue
that can occur for sensors that support being on multiple busses
like I2C & SPI.

For example, you can have a configuration in which such a sensor is
on the I2C bus in the devicetree and the sensor is enabled.  However
the application configuration enables CONFIG_SPI=y and CONFIG_I2C=n
and this will cause the sensor driver to be built by default, however
since we don't have the I2C bus enabled the driver will not compile
correctly.

Previously we had been adding to board Kconfig.defconfig something
like:

	config I2C
		default y if SENSOR

This pattern doesn't scale well and may differ from what an application
specific need/use is.

So instead move to a pattern in which we leave the default enablement
up to the devicetree "status" property for the sensor.  We then have
the Kconfig move from 'depends on <BUS>' to 'select <BUS>' and in
the case of drivers that support multiple busses we have the Kconfig
be: 'select <BUS> if $(dt_compat_on_bus,$(<DT_COMPAT>),<BUS>) for
each bus type the sensor supports.

This removes the need to add Kconfig logic to each board and enables
the bus subsystem and bus controller driver if the sensor requires
it by default in the build system.

Fixes: #48518

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-08 06:58:18 +01:00
Pieter De Gendt 114c133fde drivers: sensor: bq274xx: Add interrupt trigger for data ready
Add an optional data ready trigger for the BQ274XX fuel gauge.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-08-04 14:17:55 +02:00
Fabio Baltieri 21900c4c33 drivers: sensor: max17055: fix TTE and TTF time units
The unit for SENSOR_CHAN_GAUGE_TIME_TO_EMPTY and
SENSOR_CHAN_GAUGE_TIME_TO_FULL are defined in
zephyr/drivers/sensor.h as being in minutes.

Change the max17055 implementation to match the API spec, fix the
annotation for time register units.

Link: https://datasheets.maximintegrated.com/en/ds/MAX17055.pdf
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-01 14:49:59 -05:00
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