The accel and magn full-scale setters used an undeclared data pointer
when the respective FULL_SCALE_RUNTIME options are enabled. Declare
it from dev->data.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
lsm9ds0_gyro_set_fs_raw() used an undeclared data pointer when
CONFIG_LSM9DS0_GYRO_FULLSCALE_RUNTIME is enabled. Declare it from
dev->data.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
lsm9ds0_mfd_magn_set_odr() iterated the accelerometer ODR map instead
of the dedicated magnetometer map, producing out-of-range M_ODR codes
for frequencies above 100 Hz.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The sample rate was shifted with the bandwidth field shift, so the
value never intersected the DR mask and the requested ODR was always
programmed as zero. Use the DR field shift.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Add a driver for the Hamamatsu S9706 digital RGB sensor using plain
GPIOs. All parameters (e.g. integration time and sensor range) are
runtime-configurable via sensor attributes.
Signed-off-by: Anton Puppe <anton-noel-flynn.puppe@zeiss.com>
Setting the gender attribute wrote sub-index 0x08, which belongs to
age (height 0x06, weight 0x07, age 0x08), overwriting the age
setting. Use sub-index 0x09.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The full-scale attribute passed MAX31875_DATA_FORMAT_SHIFT (a bit
position) as the register mask, clearing the conversion-rate bits and
never setting the data format. Use BIT(MAX31875_DATA_FORMAT_SHIFT).
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
buffer_size was set to the size of the whole data struct instead of
the uint16_t buffer member. Use sizeof of the member.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The SPI read command buffer was 2 bytes but described with a length
of 3, reading past the stack array and clocking out an indeterminate
byte. Size the buffer to match.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The trigger setup wrote the FF_MT_THS register address (0x17) as the
threshold instead of the maximum. Write FXOS8700_FF_MT_THS_MASK as
the comment describes.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
adxl345_submit_fetch() requests sizeof(struct adxl345_dev_data) bytes
from the RTIO buffer pool, but only writes sizeof(struct adxl345_sample)
into it. The decoder also casts the buffer to struct adxl345_sample *.
This over-allocation wastes memory and prevents callers from using
reasonably-sized read buffers (e.g. 128 bytes) since adxl345_dev_data
can exceed 200 bytes when triggers or streaming are enabled.
Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Maureen Helm <maureen.helm@analog.com>
icm40627_init() logged a failed bus check through an undeclared
'config' pointer and a nonexistent bus.bus member, breaking the build
when the driver is compiled. Point LOG_ERR_DEVICE_NOT_READY at the
underlying I2C bus device.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The SENSOR_CHAN_DIE_TEMP case sat inside the CONFIG_MPU9250_MAGN_EN
guard, so temperature reads returned -ENOTSUP with the magnetometer
disabled even though the register is always fetched.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The angle conversion divided by 65635 instead of the 16-bit full
scale 65535, and raw_val * 36000 overflows signed 32-bit for large
readings. Use 65535 and widen to uint32_t.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
CFG2 was written with the CFG1 bit pattern so the AGAINMAX/AGAINL
bits were never programmed, and the 128x case loaded the CFG2
register value (20) into the lux gain instead of TSL2540_AGAIN_S128
(140).
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The 2000G A3-A5 OTP addresses jumped from 0x29 to 0x30-0x32 instead
of continuing at 0x2A-0x2C, pointing at the wrong registers.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The reconfigure path detected an auto_sr change but programmed the
old value, so the attribute never took effect. Pass the new value.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The dual-frequency assertion placed '== 0' inside the DT_INST_PROP
property-name argument. Move the comparison outside the macro call,
matching the assertion below it.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
So it is only built when needed, and we avoid a compiler warning:
bmp581.c:59:19: error: unused function 'bmp581_pm_busy_check'
The issue was there since c68a25e4d5
but only became apparent in CI when its test was added in
f0802b645b
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Add a bus emulator for the BMP581 so the driver can be exercised on
native_sim without hardware. It models the register file, the soft-reset
power-on-complete handshake, the chip-id and NVM-ready status, and the
temperature/pressure data registers, and implements the emul_sensor
backend (set_channel / get_sample_range) for the pressure and ambient
temperature channels.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Add driver for the ADIS16477 6-axis IMU sensor family.
Supports polling, trigger (DRDY interrupt), RTIO async, and
streaming modes. Includes SPI bus access, burst read, decoder,
temperature and inertial data channels, decimation rate
configuration via devicetree, hardware reset, and diagnostic
status checking.
Signed-off-by: Iustin Stolniceanu <iustin.stolniceanu@analog.com>
The syscall handler functions forward parameters with identical casts
that are redundant since the variables already have those types. Drop
the casts to let the compiler type-check the arguments unobstructed.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
The BMI270 exposes an on-chip temperature sensor in registers
TEMPERATURE_0/1 (0x22/0x23). Add support for SENSOR_CHAN_DIE_TEMP so
applications can read it through the standard sensor API.
bmi270_init() now sets PWR_CTRL.temp_en, bmi270_sample_fetch() reads
the 16-bit value, and bmi270_channel_get() converts it using the
datasheet formula T = raw / 512 + 23 degrees C, returned in micro-
degrees through val1/val2.
Signed-off-by: Vignesh Pandian <vignesh@aerlync.com>
Adjust base_timestamp_ns backward from the trigger timestamp by
(N-1)*period so it reflects the time of the first FIFO sample,
matching the lsm6dsv16x reference implementation.
Fixes: #98720
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
(cherry picked from commit f73d9b122431cd7bcfeb24b67c170241a1a61d98)
Pre-count FIFO frames for the requested channel and adjust
base_timestamp_ns backward from trigger time by (N-1)*period so it
reflects the time of the first sample, matching the lsm6dsv16x
reference implementation.
Fixes: #98720
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
(cherry picked from commit 750d08206d5ec13a7c171ede9cea00dcc8aab9f6)
adxl362 hardcoded reading_count = 1 despite its decode loop being
capable of filling multiple readings[] entries up to max_count.
The memset and header initialization were also inside the loop body,
which zeroed previously decoded readings on each iteration. Split the
decode into separate SENSOR_CHAN_DIE_TEMP and accel loops, moving the
memset and header setup (base_timestamp_ns, shift) before each loop and
setting reading_count to the actual decoded sample count afterwards.
While here, fix two coupled bugs exposed once multiple readings are
reported:
- the temperature path memset used sizeof(struct sensor_three_axis_data)
on a struct sensor_q31_data buffer, zeroing past the end of the
smaller struct; use sizeof(struct sensor_q31_data) instead.
- sample_num was never incremented in the loop, so every reading was
given an identical timestamp_delta; increment it per decoded sample.
Assisted-by: Claude:claude-sonnet-4.6
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
adxl372 hardcoded reading_count = 1 despite its decode loop being
capable of filling multiple readings[] entries up to max_count.
Set reading_count to the actual decoded sample count after the loop
completes.
Assisted-by: Claude:claude-sonnet-4.6
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
adxl355 hardcoded reading_count = 1 despite its decode loop being
capable of filling multiple readings[] entries up to max_count.
Set reading_count to the actual decoded sample count after the loop
completes.
Assisted-by: Claude:claude-sonnet-4.6
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
adxl345 hardcoded reading_count = 1 despite its decode loop being
capable of filling multiple readings[] entries up to max_count.
Set reading_count to the actual decoded sample count after the loop
completes.
Assisted-by: Claude:claude-sonnet-4.6
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Avoid silently reporting an invalid pressure value when pressure
compensation encounters a division-by-zero condition.
Use the existing return value 0 from bme280_compensate_press() to
detect a compensation failure in bme280_sample_fetch_helper(), Log an
error, and return -EIO instead of storing an invalid pressure reading.
This ensures callers to receive an appropriate error when pressure
compensation cannot be completed successfully.
Signed-off-by: Gobi M <gobi@aerlync.com>
The COND_CASE_1() allows writing chained/nested COND_CODE_1() checks in
a simpler way. Replace such patterns in the STM32 drivers with this new
utility macro.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Add gyro_odr to the encoded header so the decoder knows the sample
rate. Fix base_timestamp_ns to reflect the time of the first FIFO
sample (trigger_time - (N-1)*period) and add timestamp_delta per
sample, matching the lsm6dsv16x reference implementation.
Fixes: #98720
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
(cherry picked from commit 396a5615ee758c156fc340b3e2a496b6d1590ffc)
Add accel_odr to the encoded header so the decoder knows the sample
rate. Fix base_timestamp_ns to reflect the time of the first FIFO
sample (trigger_time - (N-1)*period) and add timestamp_delta per
sample, matching the lsm6dsv16x reference implementation.
Fixes: #98720
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
(cherry picked from commit 674f1aff9143bbd8191eff4844fd5d84c938e421)
Adjust base_timestamp_ns backward from the trigger timestamp by
(N-1)*period so it reflects the time of the first FIFO sample,
matching the lsm6dsv16x reference implementation.
Fixes: #98720
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
(cherry picked from commit 6fa8569d5ded7c6a2578ea3b30a5033861224497)
Adjust base_timestamp_ns backward from the trigger timestamp by
(N-1)*period so it reflects the time of the first FIFO sample,
matching the lsm6dsv16x reference implementation.
Fixes: #98720
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
(cherry picked from commit beb67e32e8e91250ec1ed877c89e4b140fd95673)
Adjust base_timestamp_ns backward from the trigger timestamp by
(N-1)*period so it reflects the time of the first FIFO sample,
matching the lsm6dsv16x reference implementation.
Fixes: #98720
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
(cherry picked from commit 31e23771424d99a99392a94ae459be836d91dc3c)
Record base_timestamp_ns as the time of the first sample in the FIFO
by adjusting backward from the trigger timestamp using the total frame
count and ODR period, matching the lsm6dsv16x reference implementation.
Fixes: #98720
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
(cherry picked from commit 36386844a6a0da009cca6bc730034f849e4b9dcf)
Lis2dh interrupts were only fired for up events. Fixed it by adding
down event enable bits to the ANYM_CFG.
Signed-off-by: Matthias Alleman <matthias.alleman@basalte.be>
Extend the VBAT driver to support VDDCORE channel on more STM32 series:
- STM32H7R/S
- STM32MP2
- STM32N6
- STM32U3
This is achieved by using different LL APIs which seem more portable
(with the exception of STM32H5 series on which they are not available!)
Adding actual DTSI nodes for the sensors will be done in other commits.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Add a sensor driver for the NXP MCUX Enhanced Quadrature Decoder (EQDC)
using the fsl_eqdc HAL. The PHASEA/PHASEB decoder inputs are routed
through the on-chip INPUTMUX, described by an "inputmux-connections"
phandle-array following the nxp,inputmux convention.
The driver exposes SENSOR_CHAN_ROTATION, SENSOR_CHAN_RPM,
SENSOR_CHAN_ENCODER_COUNT and SENSOR_CHAN_ENCODER_REVOLUTIONS; the last
channel is added to the sensor API. Velocity uses the EQDC period
measurement (POSDH/POSDPERH), so a prescaler keeps the 16-bit period
counter from saturating at the sample rate.
A single-phase-mode property selects single-phase decode (one count per
PHASEA pulse, with the direction taken from PHASEB) instead of the
default quadrature X4 decoding, with the counts-per-revolution scaling
adjusted accordingly.
Co-authored-by: bnina-ayoub <ouba.bnina@gmail.com>
Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
Based on the DS18B20 driver. Only the temperature sensor functionality is
exposed by this driver, not eeprom access nor parasite power configuration.
Signed-off-by: Tomas Groth Christensen <tgc@foss.dk>
Add Hall-effect pulse-output flow meter driver. An ISR increments a
64-bit pulse counter implemented as two 32-bit atomics (low word and
high word) with wraparound detection.
Volume thresholds are stored as a snapshot of the low pulse counter at
arm time plus a delta in pulses. The ISR fires when the unsigned 32-bit
difference (current - snapshot) reaches the delta, which is inherently
wraparound-safe. Sub-pulse thresholds are clamped to one pulse. The
threshold trigger is one-shot: it disarms on firing or when a NULL
handler is registered. Work is deferred to the system workqueue to avoid
running the handler in ISR context.
SENSOR_CHAN_VOLUME reports accumulated volume in liters since boot.
SENSOR_CHAN_FLOW_RATE reports instantaneous flow in L/min, computed at
sample_fetch time from the delta pulse count and elapsed time since the
previous fetch. SENSOR_ATTR_CALIBRATION provides a runtime override for
the pulses-per-liter calibration value. An optional power GPIO can be
asserted at init to enable the sensor module.
Signed-off-by: Nicolas Belin <nbelin@baylibre.com>
Transition the driver over to one-shot operation by default unless
`CONFIG_LPS22HH_TRIGGER` is enabled to actually make use of periodic
measurements. By using one-shot mode and polling on the status register,
this fixes the following code flow, which is currently broken due to
no periodic samples being available immediately after resuming.
```
pm_device_runtime_get(dev);
sensor_sample_fetch(dev);
sensor_channel_get(dev, ...);
pm_device_runtime_put(dev);
```
Signed-off-by: Jordan Yates <jordan@embeint.com>
Use <> operator to include a Zephyr header file instead of "" that
is intended to local header files, not header files relative to
specifically defined search paths.
This change was made running the sed shell command below:
$ sed -i -E 's/#include "zephyr\/([^"]+)\.h"/#include <zephyr\/\1.h>/g' \
`grep -rsl "#include \"zephyr/" drivers/`
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
The `thread` field is not initialized, if it's being animated via
k_work_queue_run instead of k_work_queue_start.
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
INA228_DRIVER_INIT sets CAL with
`.cal = (INA237_DT_CAL(inst) * 16)`, where INA237_DT_CAL ends in
`/ 10000000ULL`. C operator precedence runs the divide before the
*16, so the truncation residual gets amplified 16x — and for small
current_lsb * rshunt products (e.g. 191 nA LSB, 5 mOhm shunt) the
numerator is below 1e10 and CAL collapses to 0, leaving the CURRENT
register stuck at zero (datasheet section 8.1.2).
Replace both CAL macros with a single parameterized
INA2XX_DT_CAL(inst, scaling) so the *16 (folded into
INA228_CAL_SCALING) happens inside the product, and the divide is the
last operation. INA237 path is functionally unchanged.
Signed-off-by: Noah Luskey <luskey@meta.com>
Adds Driver emulation tests to validate configuration,
data fetching and temperature edge case checks.
Signed-off-by: Jan Carlo Roleda <jancarlo.roleda@analog.com>
Fixes a computation issue that causes negative temperature values
to be erroneously parsed from the device driver.
Signed-off-by: Jan Carlo Roleda <jancarlo.roleda@analog.com>