Commit graph

2428 commits

Author SHA1 Message Date
David Leach
50a044a33d drivers: sensor: fxls8974: fix size misalignment memory access
Coverity identified out-of-bounds access. A uint8_t being cast to
an enum is undefined in that the enum can be allocated 4bytes.

Change the internal function to use the base type of the variable,
uint8_t to avoid potential compiler size alignement problems.

Fixes #81927

Signed-off-by: David Leach <david.leach@nxp.com>
2025-02-07 02:24:17 +01:00
Wajdi ELMuhtadi
03b075d35a drivers: sensor: wsen_pads_2511020213301: add sensor driver
Add wsen_pads_2511020213301 driver with
the corrected name and compatibility with
the hal update as well as added new features.

Signed-off-by: Wajdi ELMuhtadi <wajdi.elmuhtadi@we-online.com>
2025-02-06 07:45:13 +01:00
Konrad Sikora
6487b217ea drivers: sensor: Fix typos in TMAG5170 driver
Correct a couple of misspellings in the TMAG5170 sensor driver

Signed-off-by: Konrad Sikora <kontakt@konradsikora.pl>
2025-02-05 23:48:52 +01:00
Jonas Spinner
90b989cf0e drivers: sensor: st: add missing buffer size config
Previously, the Kconfig option CONFIG_STMEMSC_I3C_I2C_WRITE_BUFFER_SIZE
has been introduced to replace i2c_burst_write with i2c_write using a
buffer combining the address and data.
See commit 5f8da77ad3eaf0593107fd99253c1c13b3a98de0

Add missing buffer size config to stmemsc_i2c_write_incr to replace
fixed buffer size.

Signed-off-by: Jonas Spinner <jonas.spinner@burkert.com>
2025-02-05 21:01:34 +01:00
Armando Visconti
b6604f160c drivers/sensor: lis3mdl: fix lis3mdl_sample_fetch API
Fix a runtime bug when both CONFIG_LIS3MDL_TRIGGER and CONFIG_ASSERT
are set. The correct assertion should verify that sensor channel is
either SENSOR_CHAN_ALL or SENSOR_CHAN_MAGN_XYZ.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2025-02-05 21:01:18 +01:00
Mohammed Billoo
2850be690d drivers: sensor: ams/tsl2591: Don't check return code of initial reset
The TSL2591 driver fails to initialize because the sensor responds with a
NACK on the initial RESET. Although the datasheet from Adafruit claims that
this is operation should be valid (RESET is part of the CONTROL register),
other sample non-Zephyr drivers provided by Arduino don't explicitly reset
the sensor on initialization (see
https://github.com/adafruit/Adafruit_TSL2591_Library/blob/master/Adafruit_TSL2591.cpp).
Thus, the assumption is that when the sensor is reset via software, it
doesn't respond to an ACK.

After removing the check for this initial RESET, the driver initializes
successfully.

Signed-off-by: Mohammed Billoo <mab@mab-labs.com>
2025-02-05 21:00:36 +01:00
Stephan Linz
98cf437d7a drivers: sensor: maxim,ds3231: avoid compilation error
As the C language treats 'cases' similar to 'labels' the following
error can also occur when using switch statements when it encounters
a declaration immediately after a label:

drivers/sensor/maxim/ds3231/ds3231.c:77:3: error: a label can only
        be part of a statement and a declaration is not a statement
   77 |   const uint16_t raw_temp = data->raw_temp;
      |   ^~~~~

Signed-off-by: Stephan Linz <linz@li-pro.net>
2025-02-05 01:16:03 +01:00
Aurelie Fontaine
262008a4a4 drivers: sensor: icm42670: fix serif type
Fix correct use of serif_type if the driver is compiled with both SPI
and I2C enabled by storing it in device config.

Signed-off-by: Aurelie Fontaine <aurelie.fontaine@tdk.com>
2025-02-04 15:05:40 +00:00
Mayank Narang
6c85423086 drivers: sensor: kconfig: Explicitly add default trigger mode as none
Explicitly add default trigger mode as none in the kconfig trigger
template for better readability.

Signed-off-by: Mayank Narang <narang.may77@gmail.com>
2025-02-04 09:17:48 +01:00
Jamie McCrae
560db8509a drivers: kconfig: Fix bleeding options
Fixes a multitude of Kconfigs that wrongly appear on devices
where support is literally impossible

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-01-31 11:50:12 +01:00
Fabian Barraez
9c993bd0e3 sensor: grow_r502a: fix: untrusted array index read
- Fixed Coverity CID 366275 by adding bounds check on
packet length.

Signed-off-by: Fabian Barraez <fabianbarraez@gmail.com>
2025-01-30 07:20:29 +01:00
Ryan McClelland
8f0ffbbb34 drivers: sensor: st: replace i2/3c_burst_write
i2/3c_burst_write comes with a warning where this combined write
synthesized by thsi API may not be supported by all I2/3C
devices. Replace with i2c_write instead with a buffer combining
the address and data.

The Kconfig STMEMSC_I2C_WRITE_BUFFER_SIZE was added to set the
size of the buffer pushed to the stack.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-01-29 22:30:25 +01:00
Benjamin Perseghetti
e399c168a1 sensor: icm42688: Fix broken build and streaming.
Makes driver actually build again.
Fixes scaling, q32 encoding, bit shifts, and register mappings.
Also enables High Resolution mode (a unique and beneficial
feature of the chip when used with streaming).

Co-authored-by: James Goppert <james.goppert@gmail.com>
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
2025-01-29 15:17:44 +01:00
Fabio Baltieri
e93118f906 sensor: add few missing shell device filters
Add shell device filtering using the existing sensor_device_check to all
remaining sensor shell commands.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-01-29 04:17:47 +01:00
Yishai Jaffe
6686d82a7f drivers: si7006: add support for vin supply
Added support for vin supply which seems to be needed for the radio
boards in order to power on the sensor.

Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
2025-01-28 18:14:09 +01:00
Fabian Barraez
3585c37437 sensor: bmp180: fix: untrusted divisor caught by coverity
- Checking the value before applying it as a divisor

Signed-off-by: Fabian Barraez <fabianbarraez@gmail.com>
2025-01-27 04:16:45 +01:00
Wajdi ELMuhtadi
4068d41d4b drivers: sensor: wsen_tids_2521020222501: add sensor driver
Add wsen_tids_2521020222501 driver with
the corrected name and compatibility with
the hal update as well as added new features.

Signed-off-by: Wajdi ELMuhtadi <wajdi.elmuhtadi@we-online.com>
2025-01-24 19:16:17 +01:00
Mayank Narang
cb608812cf drivers: sensor: lis2de12: add length check in spi write incr routine
Added a length check in the spi write incr routine to handle both
single and multi byte write operations properly.

Signed-off-by: Mayank Narang <narang.may77@gmail.com>
2025-01-24 15:42:21 +01:00
Mayank Narang
7b062f5b09 drivers: sensor: lis2de12: fix read accel via spi
The lis2de12 sensor driver spi interface was calling spi read api.
This leads to a single byte operation on reading acceleration data
which is a multi byte operation. Fix it by adding a call to spi read
incr api instead. Added a length check to handle both single and multi
byte read properly.

Signed-off-by: Mayank Narang <narang.may77@gmail.com>
2025-01-24 15:42:21 +01:00
Fredrik Gihl
904089ddc5 driver: sensor: tmp116: oversample attribute
Add oversample attribute

Signed-off-by: Fredrik Gihl <fgihl@hotmail.com>
2025-01-24 15:41:50 +01:00
Pieter De Gendt
f1c4760304 drivers: Update APIs to use DEVICE_API macro
Some drivers APIs were not wrapped using the DEVICE_API macro.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-01-24 01:15:19 +01:00
Jaakko Rautiainen
516e5d61c6 drivers: sensor: ti: tmp435: added driver for TMP435
The TMP435 is a remote temperature sensor monitor
with a built-in local temperature sensor.

Signed-off-by: Jaakko Rautiainen <jaakko.rautiainen@bittium.com>
2025-01-21 19:26:32 +01:00
Armando Visconti
8bcaf732ee drivers/sensor: ism330dhcx: toggle device_conf bit
Set ctrl9_xl.device_conf bit to 1 in ism330dhcx_init_chip()
prior to start device configuration, as stated in paragraph
9.20 of the datasheet.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2025-01-21 15:13:46 +01:00
Florian Weber
432c0cdc35 drivers: sensor: mlx90394: added driver
Added driver for Melexis MLX90394 magnetometer.

Signed-off-by: Florian Weber <Florian.Weber@live.de>
2025-01-21 09:12:41 +01:00
Luis Ubieda
e453a0ca4d sensor: adxl345: Disable Sensor Streaming by default
Have the application enable this feature explicitcly, so that
simple applications do not need to disable this to get the
expected behavior.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-01-20 20:56:19 +01:00
Luis Ubieda
2a59a0282c sensor: adxl345: Only enable FIFO Stream with Sensor Stream is enabled
Otherwise with its default configuration (25-Hz, 32-level FIFO),
getting individual samples could be up to 1-second old.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-01-20 20:56:19 +01:00
Luis Ubieda
283b5197e6 sensor: adxl345: Fix decoder for non-streaming mode
The following fixes have been applied to this decoder:
- The Q-scale factor was fixed, both for full-scale and non
full-scale modes.
- The data-type decoded is struct sensor_three_axis_data, as
it should for read/decode API.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-01-20 20:56:19 +01:00
Luis Ubieda
2dba777432 sensor: adxl345: Add get_size_info API
Used by the sensor-shell in order to retrieve values, otherwise
it crashes.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-01-20 20:56:19 +01:00
Michal Piekos
d318726209 drivers: sensor: vl53l0x: Add private channels
Added private channels for metadata associated with
distance measurement according to datasheet and API manual.

Signed-off-by: Michal Piekos <michal.piekos@wp.pl>
2025-01-17 23:07:54 +01:00
Tarang Raval
e338c7a807 drivers: sensor: fxls8974: remove redundant error check
The function fxls8974_get_temp_data always returns zero, indicating
success.Therefore, the error checking if condition is unnecessary and
can be removed.

Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
2025-01-17 23:07:40 +01:00
Maarten Nieuwenhuize
86a7e29b50 drivers: sensors: lis2dh: added full high-pass filter capabilities
The lis2dh driver has the ability to enable the hp filter.
However it was only possible to set the first 2 bits of the hp register.
These bits indicate wether the hp filter is enabled for the interrupts.
This commit moves lis2dh_acc_hp_filter_set to lis2dh.
 It also removes the mask so that all bits are able to be set.

Signed-off-by: Maarten Nieuwenhuize <maarten.nieuwenhuize@picoo.nl>
2025-01-16 22:37:01 +01:00
Jilay Pandya
01852b555e drivers: sensor: adltc2990: refactor sample_fetch function
sample_fetch function has quite a high cyclomatic complexity, this
refactoring aims to reduce cyclomatic complexity by refactoring.
- introduce fetch current on pin function
- introduce fetch voltage on pin function
- introduce fetch temperature on pin

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-01-16 22:36:30 +01:00
Jilay Pandya
5c0b85d00f drivers: sensor: adltc2990 expose functions to public api
This commit replaces a hack where is_busy status of adltc2990 was
checked by fetching SENSOR_CHAN_ALL with a dedicated function
expose adltc2990_trigger_measurement function to public api

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-01-16 22:36:30 +01:00
Jilay Pandya
831b732554 drivers: sensor: adltc2990 return explicit -EIO errors
return explicit -EIO errors from i2c_reg_<read/write>_byte_dt

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-01-16 22:36:30 +01:00
Jilay Pandya
23c23eae41 drivers: sensor: adltc2990 remove curly braces
unify switch case coding style with that of linx kernel and
other in-tree drivers

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-01-16 22:36:30 +01:00
Wajdi ELMuhtadi
01d9861d71 drivers: sensor: wsen_pdus_25131308XXXXX: add sensor driver
Add wsen_pdus_25131308XXXXX driver with
the corrected name and compatibility with
the hal update as well as added new features..

Signed-off-by: Wajdi ELMuhtadi <wajdi.elmuhtadi@we-online.com>
2025-01-16 22:35:47 +01:00
Luis Ubieda
5a9ff03c21 sensor: adxl3xx: Move run-time modification of ODR from cfg to data
Config struct is constant and attempting to modify it triggers a fault.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-01-15 19:05:45 +01:00
Wenxi Xu
a490c90dc3 drivers: sensor: bmi08x: fix interfaceand trigger
1. Temperature Interface
According to BMI08x datasheet, temperature reading
requires both MSB and LSB bytes to be read and
processed correctly.

Temp data processing should follow the formula:
Temp in °C = (temp_msb * 8) + (temp_lsb / 32)

This patch implements the correct reading
sequence and calculation method as specified
in the datasheet.

2. Trigger Setting
Previously we set handler and then trigger struct.
However under some situation, as long as we set
the handler, we get into ISR immediately and never
set trigger struct.
I simply changed the sequence.

Testing:
- Verified temperature readings match datasheet
- Tested on stm32f407igh board with BMI08x sensor

Fixes: #82375

Signed-off-by: Wenxi Xu <xuwenxi0517@gmail.com>
2025-01-15 19:04:06 +01:00
Jordan Yates
d36334a08c sensor: tmp108: optimize resource usage
Optimize the resource usage of the driver for the case where
`CONFIG_TMP108_ALERT_INTERRUPTS=n`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-01-15 19:03:40 +01:00
Jordan Yates
093f66fe55 sensor: tmp108: fix sample_fetch API conformance
`sensor_sample_fetch` is documented as blocking until the fetch
operation is complete. Update the implementation so that this is true.

Since the fetch operation now blocks, there is no need for the data
ready trigger.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-01-15 19:03:40 +01:00
Jordan Yates
faf912d404 sensor: tmp108: fix one-shot mode for as6212
When configuring the device to run in one-shot mode, the AS6212 requires
the sleep mode bit to be set. From the datasheet:

```
The sleep mode is activated by setting the bit SM in the configuration
register to 1. This shuts the device down immediately and reduces the
power consumption to a minimum value.

Entering the sleep mode will take some time (120 ms maximum) and the
first conversion after the sleep mode has been entered takes longer than
the values specified in Figure 7. It is therefore recommended when
entering sleep mode to trigger a single shot conversion at the same
time. After 150 ms (max), the device has then entered the sleep mode and
subsequent conversion times are as specified in Figure 7.
```

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-01-15 19:03:40 +01:00
Jordan Yates
f5434c133f sensor: tmp108: use common sensor_value_ helpers
Use the common `sensor_value_*` helper functions instead of implementing
the conversions again in the driver.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-01-15 19:03:40 +01:00
Mark Chen
f4da9b9705 drivers: sensor: Add sensor clock API support
This commit introduces a new Sensor Clock API, enabling the retrieval
of cycle counts and conversion to nanoseconds based on the system or
external clock. The API includes:

- `sensor_clock_get_cycles()` to get the current cycle count from the
  sensor clock.
- `sensor_clock_cycles_to_ns()` to convert cycles to nanoseconds using
  the clock's frequency.

The implementation supports both system clocks and external clocks
defined in the device tree, making the sensor clock integration more
flexible for various sensor use cases.

Signed-off-by: Mark Chen <mark.chen@cienet.com>
2025-01-15 19:03:13 +01:00
Patrick Günzel
2a999e14e8 sensors: reconfig adc for channel
Some ADCs (e.g. SAM0) can only convert one channel at a time
    and therefore need to be reconfigured for every voltage
    divider prior to startin the conversion

Signed-off-by: Patrick Günzel <patrick.guenzel@kinexon.com>
2025-01-14 22:55:07 +01:00
Gerson Fernando Budke
ac579a8f89 drivers: sensors: Add SENSOR_CHAN_FREQUENCY channel
Add new SENSOR_CHAN_FREQUENCY constant to allow implement sensors that
output frequency values in Hertz.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2025-01-14 17:58:41 +01:00
Luis Ubieda
5a1dfc82c3 sensor: default_rtio_sensor: fix: Treat individual axis data as q31_t
Instead of assuming that an individual axis must contain all
data-values. Additionally, for determining that there's XYZ data, all
three channels must be present in the header.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-01-09 08:20:32 +01:00
Luis Ubieda
36dfea121d sensor: shell: Allow individual axis data to be processed
For the supported channels, instead of just allowing 3-axis data being
printed out, allow individual channels to be processed (e.g: accel_x,
gyro_y, etc).

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-01-09 08:20:32 +01:00
Emilio Aguila Escalante
4c9b6b6ff7 Sensor: VCNL4040: Update to lux/step constants
Right now, the driver uses the lux/step constants from the datasheet
https://www.vishay.com/docs/84307/designingvcnl4040.pdf
However, the newest datasheet from 2024
indicates that the lux/step have changed (page 12)
https://www.vishay.com/docs/84274/vcnl4040.pdf

Signed-off-by: Emilio Aguila Escalante <emilio.aguila@hotmail.com>
2025-01-09 08:20:22 +01:00
Jordan Yates
1201c2404d sensor: bme280: wait for sampling period before checking
Wait until the typical time that the sample would be ready before
starting to poll the status register.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-01-09 08:20:10 +01:00
Yiding Jia
2bf61e51fe drivers: sensor: Fix TMAG5273/TMAG3001 by adding a TMAG3001 compatible
Fixes issue introduced in #76460

The previous code attempted to detect whether TMAG5273 or TMAG3001 was
connected based on DEVICE ID register. This doesn't work as the bits that
denote the version on one part are undefined on the other part, and cannot
be relied on to be zero.

This commit adds a TMAG3001 compatible which (for now) is just derived from
the TMAG5273 compatible. This allows TMAG3001 to be specified directly in
the DT. The driver code is updated to support both compatibles.

Signed-off-by: Yiding Jia <yiding.jia@gmail.com>
2025-01-08 09:33:02 +01:00