The charge calibration extracted its two LSBs with the discharge mask
(bits 1:0) instead of the charge mask (bits 3:2), skewing charging
current readings.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
(tmp & A) != 0 || (tmp & B) != 0 is equivalent to (tmp & (A | B)) != 0.
Collapse the temperature and humidity threshold status tests into single
masked checks.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
The default "bosch,bmi270" compatible selects the max_fifo feature set,
whose anymo_1/anymo_2 registers are NULL. Enabling SENSOR_TRIG_MOTION then
made bmi270_anymo_config() pass those NULL pointers to
bmi270_feature_reg_write(); on Cortex-M address 0 is readable, so the write
silently targeted an unintended feature page and returned success, leaving
the trigger a no-op.
Return -ENOTSUP when the configured feature set does not provide the
any-motion registers, so the condition is reported instead of failing
silently.
Fixes#112938
Signed-off-by: Rupesh Majhi <zoone.rupert@gmail.com>
The channel guard combined its checks with &&, accepting any channel
type with index 0. Use ||, matching sb_tsi_emul_get_sample_range().
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The 2586 Ohm point was listed at 64 degC in a table that steps by
exactly 10 degC, skewing interpolation between 55 and 75 degC. Use
65 degC.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Operator precedence applied the scale factor to the high byte before
OR-ing in the low byte, and the 16-bit sign was lost. Assemble and
sign-extend the raw value first, as the magnetometer path does.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
set_iir_config() overwrote the whole DSP_IIR register with the raw
temperature coefficient instead of programming it through the
BMP5_SET_IIR_TEMP bitfield, corrupting the pressure IIR setting.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The heartbeat error case fell through into default and returned
-ENOTSUP, so fetching the channel always failed. Add the missing
break.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
sizeof(temp_buffer) on a pointer parameter truncated the UART receive
to the pointer size. Pass MTCH9010_INTERNAL_BUFFER_SIZE.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
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>