Commit Graph

2500 Commits

Author SHA1 Message Date
Armando Visconti
792b7e3570 rtio: add helper function rtio_read_transaction()
Add a helper function that constructs a rtio SQE chain with the purpose
to perform a bus read operation on a list of registers.

Usage:

  struct rtio_regs regs;
  struct rtio_reg_list regs_list[] = {{regs_addr1, mem_addr_1, mem_len_1},
                                      {regs_addr2, mem_addr_2, mem_len_2},
                                      ...
                                     };
  regs.rtio_regs_list = regs_list;
  regs.rtio_regs_num = ARRAY_SIZE(regs_list);

  rtio_read_regs_async(rtio,
                       iodev,
                       RTIO_BUS_SPI,
                       &regs,
                       sqe,
                       dev,
                       op_cb);

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2025-07-28 16:44:17 -04:00
Luis Ubieda
49a1b2417e icm4268x: Fix typos on has_trigger API
Missed during icm42688 to icm4268x refactoring as it was mispelled
in the first-place.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-28 16:38:52 -04:00
Luis Ubieda
4e1add203f icm4268x: fix typo on ODR attribute for 16k
Otherwise this setting will be ineligible through run-time
attribute configuration.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-28 16:38:52 -04:00
Luis Ubieda
b9099918fa paa3905: Send led-control disabled sequence
Otherwise, a previous firmware build could have run into the chip and
keep led control enabled in spite of disabling it through
dts-property.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-28 08:55:56 -04:00
Luis Ubieda
1725408b59 bmp581: code-style improvements
Remove extra-parentheses when operator precedence is implicit.
Eliminate implicit integer to boolean conversions.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-25 23:33:47 +02:00
Luis Ubieda
e7395a90f6 bmp581: stream: Add FIFO Watermark support
Configurable through dts property: fifo-watermark.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-25 23:33:47 +02:00
Luis Ubieda
7e3d5679d9 bmp581: Add LOG_ERR if initialization fails
Usually, drivers failing to initialize throw a message in the log,
signaling the cause of failure. Add it to this driver so the user
isn't confused by no message yet the device being marked as disabled.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-25 23:33:47 +02:00
Luis Ubieda
d2c4d0c34e bmp581: fix: Add parenthesis to macro arguments
Otherwise it leads to potential incorrect expansions.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-25 23:33:47 +02:00
sudarsan N
7312715975 drivers: sensor: fcx_mldx5: Fix potential buffer overflow in UART frame
Fix Coverity issue CID 363738 (CWE-120): A potential buffer overflow could
occur in fcx_mldx5_uart_send() due to unchecked memcpy() when copying
command data into a fixed-size frame buffer.

This patch ensures that the length of the data being copied validated
against the remaining buffer size to prevent overruns. Also replaces a
redundant strlen() call with the precomputed cmd_data_len.

Fixes: #92634

Signed-off-by: sudarsan N <sudarsansamy2002@gmail.com>
2025-07-25 23:29:04 +02:00
Luis Ubieda
216fc8f5de sensor: icm4268x: Add support for ICM42686 variant
Now this driver supports both ICM42688 and ICM42686.
Tested with read-decode as well as streaming mode.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-25 23:28:47 +02:00
Luis Ubieda
8b30d11785 sensor: icm4568x: Address existing code issues by static analysis
Addressing low-hanging fruits.

Put in a separate commit in order to make it easier to keep track of
changes.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-25 23:28:47 +02:00
Luis Ubieda
8db851ff57 general: icm4268x: Refactor ICM42688 driver to ICM4268X
As a first step to enable the similar variants (e.g: ICM42686),
refactor common functionality into icm4268x files. As a result,
applications using the icm42688 will need to have both compatible
properties: "invensense,icm42688" and "invensense,icm4268x" defined.
In-tree boards have been modified to comply with this pattern.

This patch does not contain functional changes. The driver should
work the same as before.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-25 23:28:47 +02:00
Zhaoxiang Jin
1564438d17 drivers: acmp: Updated driver to be compatible with nxp_rt7xx
1. Fixed the bug that DAC value was set incorrectly.
2. The MIMXRT700 does not have windowed mode and
'enableSample' controls, code added for compatibility
on this platform.

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2025-07-24 16:56:55 +01:00
Nick Ward
38c3225af6 drivers: sensor: bmi323: use sensor_value_from_micro()
Use sensor_value_from_micro() helper.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2025-07-23 09:33:59 +02:00
Sabrina Simkhovich
b591d141a2 drivers: sensor: mb7040: add support for MB7040 ultrasonic sensor
This commit adds a new driver for the MaxBotix MB7040 ultrasonic
rangefinder. The driver uses I2C communication to read range data
from the sensor and exposes it via the Zephyr sensor API.

Tested on an esp32-s3 board using I2C bus. Verified readings at multiple
distances to confirm accuracy.

Signed-off-by: Sabrina Simkhovich <sabrinasimkhovich@gmail.com>
2025-07-22 19:37:18 -04:00
Benjamin Cabé
5c95ff509f drivers: sensor: paj7620: use LOG_MODULE_DECLARE across driver files
paj7620 log module was being registered twice ; use LOG_MODULE_DECLARE
instead in paj7620_trigger.c

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-07-22 08:16:06 -04:00
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