Commit graph

2534 commits

Author SHA1 Message Date
Mark Geiger
edbce504b0 sensor: nrf-qdec: Allow sampleper register configurable through dts
Allow for users to define the sampling period via the sampleper
register on a per instance basis through device-tree properties.
The previous value was hard coded. The same value is now the default
value.

Signed-off-by: Mark Geiger <MarkGeiger@posteo.de>
2025-07-19 15:45:27 -04:00
Armando Visconti
0d38a88666 drivers/sensor/: lis2dux12: fix ODR setting
In lis2dux12_freq_to_odr_val, the loop through the array of possible ODR
frequencies can break sooner than expected if power-mode is
set to High Performance mode and the requested ODR is less than or
equal to 25Hz.

Moreover, move the "odr |= 0x10" statement used for HP mode in the
chip_api set_odr_raw() API, so that we enter the HP mode even when the
ODR is set from DT only.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2025-07-19 15:44:26 -04:00
Luis Ubieda
d35d199253 sensor: adxl345: Add ability to use Streaming and Trigger with INT1
Prioritized over INT2 if both are defined.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-19 15:37:24 -04:00
Ruben Völl
9007a4fd8e sensor: lis2dw12: handle SENSOR_CHAN_ALL in sample_fetch callback
Handle `SENSOR_CHAN_ALL` case of the sample_fetch callback of the
lis2dw12 driver. Without this, `sensor_sample_fetch()` does not work
correctly for this device, e.g. rendering the rtio and the sensor shell
unusable.

Signed-off-by: Ruben Völl <ruben.voell@sevenlab.de>
2025-07-19 13:51:20 -04:00
Samuel Tardieu
226011b8e1 Drivers: max17055: retrieve the current value
The MAX17055 peripheral allows measuring the current
value (which corresponds to the instantaneous value). Respond to
the `SENSOR_CHAN_CURRENT` command, and retrieve the data
from the `0x0a` device register.

Signed-off-by: Samuel Tardieu <sam@rfc1149.net>
2025-07-19 13:46:19 -04:00
Luis Ubieda
4eaaf3c0ea bmm350: Add streaming mode
Supported for DRDY interrupts.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-19 13:45:38 -04:00
Luis Ubieda
0e9a018a3e bmm350: Add read-decode support
One-shot reads are now supported through the v2 model API.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-19 13:45:38 -04:00
Luis Ubieda
e92552275a bmm350: isolate data fetching from conversion
In order to allow decoupling these two operations.
No functional changes, sensor returns same readings through shell.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-19 13:45:38 -04:00
Luis Ubieda
6c13181efc bmm350: Refactor bus transfers to use RTIO
To easily further extend it to other transports and be able to
implement streaming mode.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-19 13:45:38 -04:00
Luis Ubieda
98ab8f0873 bmm350: scrub axis_en functionality
As this isn't effectively providing any value to the driver, instead
wastes cycles on every sample-fetch. Scrubbing this simplifies the
code.

Also, remove fix_sign() and replace it for the in-tree helper
sign_extend().

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-19 13:45:38 -04:00
Luis Ubieda
cf4a16e09c bmp581: Add Streaming support
Working only with DRDY Interrupts. FIFO watermark not added yet.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-19 13:26:42 -04:00
Luis Ubieda
5671129f1a bmp581: Add One-shot Read-Decode support
Decoding one-shot reads through submit API.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-19 13:26:42 -04:00
Luis Ubieda
a32d5c15fe bmp581: Move bus transfers to work over RTIO
In order to abstract details of the transport itself, improving
portability.

No functional changes at this point. Driver works the same as far
as my local testing goes.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-19 13:26:42 -04:00
Luis Ubieda
c62e4b5a88 bmp581: Add dts-properties to set default configuration
The existing driver requires setting multiple attributes in order to
work basic fetch/get reads. Simplify this by allowing the user to set
dts node properties based on the use-case.

As a result, basic settings results in the driver being up and running
from the start, one can just get sensor readings out of the box.

These still can be overriden at run-time if need be.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-19 13:26:42 -04:00
Tahsin Mutlugun
f9d35e2e8b drivers: sensor: adxl367: Fix log module declaration
Resolve a compilation issue caused by incorrect logging state
declaration for ADXL367.

Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
2025-07-19 10:11:43 +02:00
Filip Stojanovic
f0b5911d0a sensor: bme280: Fix bad chip id read after power cycle
Fix an issue where the BME280 sometimes returns an incorrect chip ID
immediately after a power cycle. This causes sensor initialization to fail.

According to the datasheet, the sensor requires a 2 ms start-up delay after
power is applied. This patch introduces a sleep delay to ensure the
required start-up time is respected before reading the chip ID.

Signed-off-by: Filip Stojanovic <filipembedded@gmail.com>
2025-07-09 00:25:33 -05:00
Luis Ubieda
a2acc86429 fix: icm42688: fix: Override FSR settings when high-res is enabled
When IMU is set to stream with High-res mode, the FSR settings are
fixed for ICM42688 at 16g and 2000dps.

Unless this is enforced, the driver will provide incorrect scaling for
readings coming through streaming when the current FS setting is any
different than these.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-08 13:38:36 -05:00
Armando Visconti
0d7c751bad drivers/sensor: lis2dux12: add 'return' if data has to be dropped
In lis2dux12_read_status_cb() add a return instruction in case of
SENSOR_STREAM_DATA_NOP/SENSOR_STREAM_DATA_DROP.

Fixes: CID 529855

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2025-07-07 16:06:13 -05:00
Armando Visconti
df1832e32d drivers/sensor: lsm6dsv16x: add 'return' if data has to be dropped
In lsm6dsv16x_read_status_cb() add a return instruction in case of
SENSOR_STREAM_DATA_NOP/SENSOR_STREAM_DATA_DROP.

Fixes: CID 529864

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2025-07-07 16:06:13 -05:00
Armando Visconti
79c098a9d9 drivers/sensors: st: fix Null pointer dereferences
Fix Null pointer dereferences in lis2dux12_read_status_cb() and
lsm6dsv16x_read_status_cb().

Fixes: CID 529873
Fixes: CID 529862

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2025-07-07 16:06:13 -05:00
Armando Visconti
1d8bd6bd53 drivers/sensor: lis2dux12: fix uninitialized variable fifo_mode
Set fifo_mode structure to zero and initialize it properly according
to what interrupt event the user has selected.

Fixes: CID 529871
Fixes: CID 529865

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2025-07-07 16:06:13 -05:00
Armando Visconti
5792a429c8 drivers/sensor: lsm6dsv16x: fix unreachable code in decoder_decode()
Fix unreachable code in decoder_decode() as reported by Coverity scan.

Fixes: CID 529878

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2025-07-07 16:06:13 -05:00
Van Petrosyan
960a6f036e sensor: lis2dh: cache CTRL1 on PM_DEVICE_ACTION_TURN_ON
Cache CTRL1 into reg_ctrl1_active_val inside lis2dh_init_chip()
in the PM_DEVICE_ACTION_TURN_ON path.  This prevents the first
runtime-PM RESUME from writing 0x00 to CTRL1 and disabling the sensor
when runtime-PM is enabled.

Fixes: #92196

Signed-off-by: Van Petrosyan <van.petrosyan@sensirion.com>
2025-07-05 11:56:00 -05:00
Gaetan Perrot
9207749e83 drivers: sensor: bma4xx: Avoid potential overflow
Coverity reports a potential integer overflow in the accel_range
computation due to the use of a left shift on an int type.

CID 520269: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)

Even though the register value is constrained to 0–3 by the BMA456 spec,
and no real overflow occurs, an explicit cast to int64_t prevents false
positives and aligns with safe coding practices.

Fixes: #90517

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-07-04 15:49:09 -05:00
Gaetan Perrot
de1fa4776b drivers: sensor: bmp581: add const qualifier when casting
Add the 'const' qualifier when casting 'dev->config' to 'struct
bmp581_config *' to preserve const-correctness and fix SonarQube warning :

 "A cast shall not remove any const or volatile qualification from the
 type of a pointer or reference."

This improves maintainability by respecting the const contract and resolve
static analysis issues.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-07-04 13:06:22 -05:00
Gaetan Perrot
032c5301de drivers: sensor: bmp581: fix potential null dereference
Move null check for 'dev' before dereferencing it to access dev->config.

This ensures the check is meaningful and avoids undefined behavior in case
of a null device pointer.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-07-04 13:06:22 -05:00
Gaetan Perrot
7d5902dd1b drivers: akm09918c: fix null dereference in submit function
Fix a null pointer dereference in akm09918c_submit(), where writeByte_sqe
was dereferenced before checking if it was NULL.

Coverity reported this as CID 516247: the pointer returned by
i2c_rtio_copy_reg_write_byte() may be NULL, and accessing its `flags`
field before checking leads to undefined behavior.

Move the access to writeByte_sqe->flags after confirming both
writeByte_sqe and cb_sqe are valid.

Fixes: CID 516247

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-07-01 19:03:19 -05:00
Pisit Sawangvonganan
b8a8173c1f drivers: kconfig: fix typo
Utilize a code spell-checking tool to scan for and correct spelling errors
in `Kconfig` files within the `drivers` directory.
Additionally, incorporates a fix recommended by the reviewer.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2025-07-01 10:58:54 -10:00
Gaetan Perrot
6d0f1aaef8 drivers: sensors: apds9253: remove unnecessary check
gain is an unsigned int so it can't be negative.

Fixes CID 516230

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-06-27 09:04:58 -10:00
Gaetan Perrot
e13f64ac47 drivers: sensor: bmm350: fix redundant return logic in init_chip
Add an explicit log message if setting suspend mode fails during error
handling in bmm350_init_chip(), to improve debuggability.

This addresses Coverity issue CID 520279 (Incorrect expression - CWE-398),
which flagged a conditional block where both branches effectively led to
the same outcome (return -EIO), making it appear redundant.

By adding a log before returning, we clarify the purpose of the condition
and avoid the issue of "identical code for different branches", while
keeping the functional behavior unchanged.

Coverity-CID: 520279

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-06-27 09:04:32 -10:00
Miguel Gazquez
e42cfcf032 drivers: sensor: lsm9ds1: propagate errors in sample_fetch
`lsm9ds1_sample_fetch` did not propagate error codes.
Propagate them.

Signed-off-by: Miguel Gazquez <miguel.gazquez@bootlin.com>
2025-06-27 08:54:42 -10:00
Peter Wang
aa7618ba59 sensor: add nxp_lpadc_temp40 temperature sensor driver
1. add nxp_lpadc_temp40 temperature sensor driver
2. tested with frdm_mcxa166 and frdm_mcxa276 board

Signed-off-by: Peter Wang <chaoyi.wang@nxp.com>
2025-06-27 09:53:28 -05:00
Gaetan Perrot
fae619a916 drivers: sensor: lsm6dsv16x: fix uninitialized struct in enable_wake_int
Zero-initialize lsm6dsv16x_pin_int_route_t to fix Coverity warning.

CID: 516227

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-06-27 10:58:58 +02:00
Bjarki Arge Andreasen
3198db1b12 drivers: sensor: nxp: p3t1755: impl pm device runtime
Implement pm device runtime for p3t1755 sensor.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-06-26 18:51:26 -10:00
Jeppe Odgaard
dffbd4fc88 license: fix copyright owner
Change license owner to Prevas due to initially wrong owner due to company
mix-up during co-development.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2025-06-26 10:56:48 -05:00
Ryan McClelland
d0d9894070 drivers: sensor: bmm350: expose magnetic reset
This exposes a driver specific function to perform a
magentic reset by the application.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-06-26 10:55:54 -05:00
Ryan McClelland
8cdaf1db99 drivers: sensor: bmm350: run clang-format
Run clang-format on files

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-06-26 10:55:54 -05:00
Ryan McClelland
dc6594997c drivers: sensor: bmm350: nit picky cleanup
There were a lot of places where the return value was sum'ed up
which can be slightly easier to read, but can give an odd return
value in the end. This changes it to just return immediately if
an error is seen.

There was also runtime NULL checking of input arguments that are
rather programmer clown prevention. Change these to asserts.

The return value didn't have a consistant type through the file,
make it consistently an int.

This changes the name of the return value of fix_sign to be
signed_value differenating it from the ret name used elsewhere.

Use the sizeof(buffer) as the argument for reg reads and writes
rather than a hard number.

Some log messages ended with '\n'. Remove all these.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-06-26 10:55:54 -05:00
Ryan McClelland
e636fb2dd1 drivers: sensor: bmm350: add pad ctrl and int ctrl dts config
Add configurations for setting the pad drive strength and the
interrupt active high/low and od/pp.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-06-26 10:55:54 -05:00
Ryan McClelland
d2fdf52d43 drivers: sensor: bmm350: fix handling interrupt race condition
There is a race condition where an interrupt can fire before the
drdy_handler is registered. The drdy_handler will tradionaly
callback the sample get clearing the interrupt... but if it's not
configured and NULL, the interrupt will stay forever latched. Read
the interrupt status to clear the interrupt flag allowing it to
trigger again.

Also, move the serial api function helpers in to the header
allowing them to be used from other c files.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-06-26 10:55:54 -05:00
Ryan McClelland
c7e1f0b3da drivers: sensor: bmm350: fix no averaging val for oversampling
Fix the oversampling value to be 1 from 0 for no oversampling to be
consistant with other sensor drivers.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-06-26 10:55:54 -05:00
Ryan McClelland
b1dac48faa drivers: sensor: bmm350: add default odr/osr
Add a way to define the default odr and osr with devicetree for
the bmm350.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-06-26 10:55:54 -05:00
Ryan McClelland
8720b2368e drivers: sensor: bmm350: add attr_get
Add the attr_get api. Also rename functions where they implied
accelerometer to imply magnetometer.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-06-26 10:55:54 -05:00
Miguel Gazquez
d3cae7ee92 drivers: sensors: add driver for the magnetometer in lsm9ds1
This driver supports the magnetometer in the ST lsm9ds1 sensor, on the
I2C bus.
This driver does not support the triggers.
This driver use the stmemsc HAL.

link: https://www.st.com/resource/en/datasheet/lsm9ds1.pdf

Signed-off-by: Miguel Gazquez <miguel.gazquez@bootlin.com>
2025-06-26 10:55:11 -05:00
Oleksii Shcherbyna
35608e295d drivers: fuel_gauge: Fix incorrect variable in bq27xx chem_id switch
The bq27xx driver incorrectly uses the 'val' variable in a switch()
statement that should operate on 'chem_id'. This leads to incorrect
behavior for fuel gauges such as the BQ27427, where the chemical ID
determines how properties are interpreted.

This commit replaces 'switch(val)' with 'switch(chem_id)' to ensure
proper handling of fuel gauge behavior across supported devices.

Signed-off-by: Oleksii Shcherbyna <oleksii.shcherbyna@droid-technologies.com>
2025-06-25 10:49:10 +02:00
Daniel DeGrasse
640958de1d drivers: sensor: npm13xx_charger: fix build warnings from native_sim
Fix the following build warnings highlighted in this driver while
building with clang targeting native_sim:

- exp() expects a double, so passing a float would cause type promotion
- variable declarations within C switch statements are a C23 specific
  extension

Signed-off-by: Daniel DeGrasse <ddegrasse@tenstorrent.com>
2025-06-25 09:51:18 +02:00
Benjamin Cabé
1b93ce7226 drivers: sensor: paj7620: fix return value of paj7620_get_hw_id()
Use a local signed variable to store negative return values instead of
unsigned previously so that errors are actually detected/returned.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-24 20:13:57 -10:00
Jilay Pandya
177e7d2b6a drivers: sensor: uint8_t var cannot be greater than 0xff
SENSOR_XBR818_CLOCKRATE / val->val1 is getting assigned
to uint8_t variable which is causing the logically
dead issue, this commit is a fix for it.

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-06-24 20:08:54 -10:00
Benjamin Cabé
8186e6cc74 drivers: sensor: sht3xd: fix threshold low clear command
Fix copy-paste error causing update to SHT3XD_CMD_WRITE_TH_LOW_CLEAR to
be missing

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-24 20:06:41 -10:00
Alexander Apostolu
8fee98313e drivers: sensor: asahi_kasei: akm09918c: Null check before dereference
cb_sqe could have been NULL before being passed into the callback function,
which expects cb_sqe to be non-NULL.

Add NULL check before the callback function with cb_sqe is called. The
reordering of the callback function after the sqe drop is okay as the
sqe drop is called when cb_sqe is NULL and the callback function isn't
expected to work when cb_sqe is NULL.

Signed-off-by: Alexander Apostolu <apostolu240@gmail.com>
2025-06-24 15:39:46 -05:00