The CHT8305 is register-compatible with the TI HDC1000 family, only
IDs and conversion time differ. It can also stretch the I2C clock
during conversion, used by default instead of sleeping.
Also add a heater property for both compatibles.
Signed-off-by: Camille BAUD <mail@massdriver.space>
The one-shot decoder wrote struct sensor_value results, while callers
pass a struct sensor_three_axis_data for the accel channels as with
every other decoder, and it returned 0 instead of the number of
decoded frames.
Decode one-shot samples to q31 with the same shift as the stream
decoder, fill the header, and return 1.
Tested on an apard32690 with the eval_adxl372_ardz shield: the
one_shot_read tests of the RTIO stream suite in #123186 now get one
decoded frame, and its values match the mean of the streamed frames.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Dimitrije Lilic <dimitrije.lilic@orioninc.com>
When a stream ends with an error, for example because the RTIO
mempool has no buffer for the next FIFO drain, the FIFO is left full
and INT1 stays asserted. fifo_full_irq stays set, so the next
adxl372_submit_stream() skips the FIFO flush and reconfiguration, and
the new stream never gets an edge.
Clear fifo_full_irq on every error exit so the next stream flushes
and restarts the FIFO.
Tested on an apard32690 with the eval_adxl372_ardz shield: the
restart_after_pool_exhausted test of the RTIO stream suite in #123186
fails without this change and passes with it.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Dimitrije Lilic <dimitrije.lilic@orioninc.com>
Once a stream is cancelled the FIFO keeps filling and INT1 fires with
no stream pending. The interrupt handler and the status callback then
return without clearing fifo_full_irq, so the next
adxl372_submit_stream() skips the FIFO flush and reconfiguration,
INT1 stays high and the new stream never gets an edge.
Clear fifo_full_irq on those early returns, as the ADXL345 driver does
since commit c627cf26d1 ("drivers: sensor: adxl345: RTIO stream
fix").
Tested on an apard32690 with the eval_adxl372_ardz shield: the
restart_after_idle and restart_cycles tests of the RTIO stream suite
in #123186 fail without this change and pass with it.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Dimitrije Lilic <dimitrije.lilic@orioninc.com>
When a stream ends with an error, for example because the RTIO
mempool has no buffer for the next FIFO drain, the FIFO is left above
its watermark and the edge-triggered interrupt line stays asserted.
fifo_watermark_irq stays set, so the next adxl345_submit_stream()
skips the reconfiguration that flushes the FIFO, and the new stream
never gets an interrupt.
Clear fifo_watermark_irq on every error exit, as is already done when
an interrupt arrives with no stream pending, so the next stream
flushes and restarts the FIFO.
Tested on an apard32690 with the pmod_acl shield: the
restart_after_pool_exhausted test of the RTIO stream suite in #123186
fails without this change and passes with it; the other tests of the
suite pass either way.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Dimitrije Lilic <dimitrije.lilic@orioninc.com>
ADE7978_SHUNT_RESISTOR and ADE7978_VOLTAGE_DIVIDER had no dependency
on ADE7978, so they appeared in the .config of every build with
CONFIG_SENSOR=y, even without an adi,ade7978 devicetree node.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Martin Stumpf <finomnis@gmail.com>
The conversion from sensor_value to q31 would overflow if the value was
outside of -4294.967296-4294.967295 range, causing incorrect readings.
Signed-off-by: Mikołaj Rosowski <mrosowski@antmicro.com>
The async API path defines its iodev with I2C_DT_IODEV_DEFINE or
SPI_DT_IODEV_DEFINE, which only exist with I2C_RTIO or SPI_RTIO.
Select the backend for the bus the sensor sits on, so boards with a
BME680 build with SENSOR_ASYNC_API, e.g. the sensor shell test.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
A canceled submission now completes with -ECANCELED, so "sensor stream
<dev> off" prints "Read failed". Say the stream stopped instead.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Tom Burdick <thomas.burdick@infineon.com>
A fetch triggers a conversion and sleeps until it completes, for as
long as the configured conversion times and averaging take. Add a
continuous-mode property, with which the device converts continuously
and a fetch reads the last conversions without waiting.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
The MCXL feature headers expose the temperature sensor calibration
constants as TEMP_PARAMETER_A/B/ALPHA, without the FSL_FEATURE_LPADC_
prefix the driver expects, so the build fails with undeclared
identifiers on MCXL255.
Map the unprefixed names onto the prefixed ones when only the former
are defined. The guards make this a no-op on SoCs whose headers already
provide the prefixed macros.
Assisted-by: Vero:claude-opus-4.6
Signed-off-by: Samuel Slesar <samuel.slesar@nxp.com>
The ICM-456xx has an FIR anti-alias filter on the ADC output in
low-noise mode. It is off at power-up, and the driver had no way to
turn it on, so vibration above the output bandwidth can alias into the
data.
Add the accel-aaf and gyro-aaf properties to enable it. The
interpolator, set by the same register fields, stays off: it is only
needed with an external clock or in I3C synchronous mode.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit uses the IRQ pin's GPIO_ACTIVE_HIGH / GPIO_ACTIVE_LOW to set
the polarity in the LSM6DSO. It also introduces a device tree property
to control whether that pin is push-pull or open-drain.
Signed-off-by: Dan Collins <dan@collinsnz.com>
The magnetometer of the ICM-20948 is a separate die with its own I2C
address, reachable only through the auxiliary I2C master of the part.
Bring that master up and use slave 4, the only channel that reports
completion and failure, to identify and start the magnetometer. Then arm
slave 0 to copy its output registers into the external sensor registers
on every cycle, so that keeping them current costs the host nothing.
Those registers directly follow the temperature registers, which lets a
single burst read collect every sensor on the part.
The readout starts at ST1 and so ends on ST2. Reading ST2 is what tells
the magnetometer that the sample was taken, and a readout that leaves it
out returns the same measurement forever.
Those mirrored registers keep their last contents when the auxiliary bus
stops answering, which would make a stale sample indistinguishable from
a fresh one. Read the master status alongside them and report the
magnetometer channels as failed while slave 0 is going unacknowledged.
The magnetometer die is mounted turned half a turn about X with respect
to the rest of the part, so Y and Z are inverted to bring it into the
frame the accelerometer and the gyroscope report in.
Select the SPI interface explicitly while doing all this. The part picks
its host interface by watching the bus and the reset in the init
function throws that choice away, and the primary I2C slave holds pins
that the auxiliary master needs.
The magnetometer can be left out with CONFIG_ICM20948_MAGN_EN.
Signed-off-by: Ali Talha Yurtseven <alitqlhq@gmail.com>
The ICM-20948 is a nine-axis motion tracking device. The accelerometer
and the gyroscope sit behind the primary SPI interface, while the
magnetometer is reached through an auxiliary I2C bus of the device.
Add support for the accelerometer, the gyroscope and the die
temperature over SPI. The magnetometer is left for later.
The registers of the part are spread over four user banks that are
paged in through a select register. Encode the bank in the high byte
of every register constant and let the bus layer page it in when it
differs from the last one selected, so that the body of the driver
never deals with banks.
The full scale range and the bandwidth of the low pass filter of both
sensors are taken from the devicetree.
Signed-off-by: Ali Talha Yurtseven <alitqlhq@gmail.com>
Introduce a bus abstraction for the ICM42605 sensor driver to support
multiple bus implementations.
Move bus-specific register access out of the core driver and add support
for both SPI and I2C backends.
fixes: #118030
Signed-off-by: Ahmed Ashraf NourEldeen <a.programmer55559@gmail.com>
The RTIO submit path set has_temp purely from the requested channels,
but mmc56x3_sample_fetch_helper() only reads the temperature when the
device is not in continuous mode, so the decoder converted an
uninitialised value from the RTIO buffer. Gate has_temp on the device
mode so the decoder reports no data instead.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
In one-shot mode the fetch path wrote the take-measurement bits to
Internal Control 0 as bare values, clearing the sticky Auto_SR_en bit
that chip init had programmed, so automatic set/reset stopped running
after the first fetch. OR the command bit onto the cached register
value instead, taking the cache from dev->data since the helper's data
argument is the RTIO encode buffer on the async path.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
mmc56x3_chip_set_decimation_filter() only ORed the BW bits into the
Internal Control 1 cache, so once set they could never be cleared, and
it committed the new configuration before checking the register write.
Use an explicit set/clear read-modify-write and only update the cache
and config on a successful write.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
mmc56x3_attr_set() built a zero-initialised configuration and only
filled in the requested field, so mmc56x3_chip_configure() saw all the
other fields as changed and reprogrammed them, e.g. dropping the part
out of continuous mode or disabling automatic set/reset. Seed the
working copy from the cached live configuration instead.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
Add initial driver support for the AMS AS7341 11-channel spectral sensor.
The driver communicates over I2C and implements the Zephyr sensor API.
- Add driver source files (ams_as7341.c, ams_as7341.h)
- Add devicetree binding (ams,as7341.yaml)
- Add Kconfig and CMakeLists.txt integration
Signed-off-by: Parin Baudhanwala <parin.baudhanwala@dnkmail.in>
BIT(11) is an unsigned long, so on 64-bit targets multiplying the
signed acceleration by it makes the conversion unsigned and negative
values end up as large positive register values. Multiply by a signed
value.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
BIT(31) is an unsigned long, so on 64-bit targets dividing the signed
temperature by it converts negative values to large positive ones and
the emulator reports the wrong temperature. Divide by a signed value.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The stream decoder stored a pointer to the next sample in the uint32_t
fit cursor. On 64-bit targets the pointer is truncated, and the casts
back to a pointer fail to build with -Werror=int-to-pointer-cast.
Store the offset of the next sample in the encoded buffer instead.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
PACs require at least 1 ms after a REFRESH per the
Microchip PAC194x/195x datasheet.
Wait 2 ms after refresh operations during channel
enablement to ensure each PAC finishes its refresh cycle
before the next channel on the same PAC is configured.
Signed-off-by: Daniel Balint <dbalint@google.com>
i3g4250d_convert() has two problems since the driver was added in
commit c9f87969c2 ("drivers: sensor: add I3G4250D Gyro driver"):
- It reports degrees per second. The sensor API defines the gyro
channels in rad/s.
- It casts raw_value * 8750 to int16_t before taking the fractional
part, which truncates the product for any |raw_value| > 3. For
example, raw_value 1000 (8.75 dps) gives val1 8 and val2 -31824.
Convert the sensitivity in udps/LSB to 10 udps and use
sensor_10udegrees_to_rad(), as the other ST gyro drivers do.
Tested on stm32f3_disco@E with samples/sensor/i3g4250d and the SPI fix
from #120319 applied: all axes read within 0.005 rad/s at rest, and a
quick quarter turn peaks near 3 rad/s. The conversion was also checked
on the host against the exact values for raw inputs from -32768 to
32767.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Seyoung Jeong <seyoungjeong@gmail.com>
commit f9de2777d9 ("drivers: sensor: i3g4250d: migrate SPI support
to stmemsc") replaced the driver's own SPI read, which set bits 7 and 6
(0xC0) of the register address, with STMEMSC_CTX_SPI, which sets only
bit 7. Without bit 6 the I3G4250D does not auto-increment the register
address, so the 6-byte read starting at OUT_X_L returns OUT_X_L six
times and all three axes report the same value.
Use STMEMSC_CTX_SPI_INCR, which sets bit 6 for multi-byte transfers.
Tested on stm32f3_disco@E: before the change, SENSOR_CHAN_GYRO_XYZ
returned the same value on all three axes; after it, each axis reads a
distinct value near zero with the board at rest.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Seyoung Jeong <seyoungjeong@gmail.com>
The decoder of the driver only decodes FIFO data, but was also given for
the samples that sensor_read() gets with the default submit, which it
can't decode. Without the stream, give no decoder, so that the default
decoder is used.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
After the soft reset, the sensor is in advanced power save mode, which
ignores accesses less than 450 us apart. Wait between the read and the
write of PWR_CONF, so that the write isn't ignored and the configuration
file is loaded.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
Interrupt connection and enabling were previously hardcoded to instance 0
inside tach_rts5912_init(), which caused any additional tach instances
enabled in devicetree to fail to register their interrupts.
Add an irq_config_func callback to struct tach_rts5912_config, define an
instance-specific IRQ configuration function in REALTEK_TACH_INIT(), and
call it during device initialization.
Tested by building for rts5912_evb with single-, dual-, and quad-instance
devicetree configurations and verifying the generated ISR table entries.
Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
VBAT raw values are divided down to lie within input range of PADC.
This must therefore be reapplied when reading the raw value. For the
case of nRF7120 this value is 5.5.
Signed-off-by: Robert Robinson <robert.robinson@nordicsemi.no>
Updates callers of rtio_sqe_cancel to use the newer opaque handle
version which takes into account the generational allocation of SQEs.
The validation of cancel is now safe in that each SQE being cancelled
must belong to the pool in struct rtio the caller has access to and
knows about. It must also be the correct generation of the SQE so that
recycled or freed SQEs are not incorrectly dereferenced with undefined
behavior.
Adds a coccinelle semantic patch to update callers both in and outside
the tree.
A migration guide was updated to include information about the API
change and the usage of the spatch to help out of tree applications
update to the new call semantics. The spatch likely won't fix all
callers but could save some time.
Assisted-by: claude:claude-opus-5 coccinelle
Signed-off-by: Tom Burdick <thomas.burdick@infineon.com>
Move several members of the struct out to the containing struct
(iodev_sqe) such that the internal rtio_sqe can be viewed as const data.
In making the containing struct const a few usages of this needed
updating to access the receive buffer through the helper
(rtio_sqe_rx_buf) rather than directly through struct members.
Assisted-by: claude:claude-opus-5 coccinelle
Signed-off-by: Tom Burdick <thomas.burdick@infineon.com>
The temperature register is a 12-bit two's complement value in
1/16 degC. The MSB was read as unsigned, so negative temperatures
were reported as 256 + T, and the fractional part was scaled by 625
instead of 62500.
Sign-extend the MSB via int8_t, combine both registers into a single
raw value and split it into val1/val2. Also print the thresholds as
signed in the trigger debug log and fix the negative low-temp value
in the MFD binding example.
Signed-off-by: Lezhi CHEN <lezhi.chen1998@outlook.com>
The FXLS8974 only latches writes to its configuration registers
(including CTRL_REG3, which holds the wake/sleep ODR fields) while the
device is in STANDBY mode. Writes performed while the device is ACTIVE
are silently ignored by the part.
fxls8974_set_odr() only wrote CTRL_REG3 directly. This worked during
init(), where the device is still in standby after the software reset,
but not at runtime: when the application changes the sampling frequency
via sensor_attr_set(SENSOR_ATTR_SAMPLING_FREQUENCY), the device is
already ACTIVE, so the register update was dropped without any error.
The reported ODR stayed at its init value (6.25 Hz) regardless of the
requested rate, producing duplicate samples when polled faster.
Save the current active state, drop to standby, update the ODR, then
restore the previous active state. During init the device is already in
standby, so the behaviour there is unchanged.
Signed-off-by: Florian Quinart <florian.quinart@nxp.com>
A one-shot read returns -EBUSY when the sensor has no new sample since
the previous read, which is expected when reading faster than the
output data rate. The RTIO path logged an error for each such read,
while sensor_sample_fetch() returns -EBUSY without logging. Only log
the other errors.
Tested with the icm42688 tests on native_sim.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Return I2C and runtime power management failures from sample fetch and
resume. Correct the sign bit used for 12-bit temperature values.
Signed-off-by: Hake Huang <hake.huang@nxp.com>
Convert sensor values directly to the LM75 register format to preserve
the native 0.0625 degree Celsius resolution.
This also fixes the conversion of negative temperatures.
Signed-off-by: Marcel Ruff <ruff@netwake.com>
bmm350_init_chip performs a soft reset, which sets the chip back to
the default i2c state. It will swap to i3c mode upon SETDASA.
Due to INIT_PRIORITY differences between I3C and sensors, this
SETDASA will come before the sensor is initialized, so the init's
soft reset will set it back to i2c mode.
Adding a self-SETDASA when the sensor is declared on an i3c bus to
put itself back into i3c mode, and thus work out of the box with
a Zephyr I3C controller.
Signed-off-by: Zayne Stites <Zayne.Stites@infineon.com>
Assisted-by: Claude:claude-opus-5
parse_sensor_value() read the fractional part of a value with a single
strtoul() and then multiplied it by 10 until it reached 100000. That
discards the leading zeros, so '50.000001' and '50.1' both produced a
val2 of 100000, and '50.005' produced 500000 instead of 5000.
That loop also never terminates when the fraction is all zeros, since
multiplying 0 by 10 never reaches 100000, so 'attr_set <dev> <chan>
sampling_frequency 50.0' hung the shell thread.
Parsing the fraction with base 0 was wrong as well: '50.08' was
rejected as an invalid octal literal, '50.0x10' was silently accepted
as hex, and strtoul() accepts a sign, so '50.-5' wrapped around to a
large unsigned value.
Accumulate the fraction one digit at a time and scale it to
micro-units based on the number of digits that were actually given,
and reject anything that is not a decimal digit. Trailing zeros beyond
six digits are accepted, while a fraction that genuinely needs finer
than micro-unit resolution is still rejected.
Fixes: #116846
Signed-off-by: Brandon Edmonds <bedmonds91@gmail.com>
SENSOR_ATTR_FULL_SCALE was compared against, and reported back as, the
measurement range in millitesla, while the SENSOR_CHAN_MAGN_* channels
are in gauss, making the attribute off by a factor of 10. Convert at the
API boundary so the attribute uses the same unit as the channels.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The MAG_GAIN_CONFIG (0x09) write sat below the early return taken for
the TMAG3001 variants, which only exists because those parts have
REG_CONFIG_3 instead of REG_T_CONFIG. As a result the mag-gain-correction
devicetree property was silently ignored on the TMAG3001. Move the write
above the early return so it applies to both parts.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The axis-bit macros applied a plain bitwise test to every value of the
`axis` devicetree property, including the pseudo-simultaneous encodings
0x8..0xB which are not bitfields. TMAG5273_DT_AXIS_XZX (0xB) has bit 1
set, so the Y channel was wrongly marked as enabled; restrict the
bitwise test to the bitfield range so those values are matched only by
the explicit comparisons.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The low 4 bits of ANGLE_RESULT hold the angle fraction in 1/16 degree
steps, but they were scaled by 1/2, making the fractional part 8x too
large and val2 exceed 1000000. Scale by 62500 per LSB instead.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
channel_get densely packed only the axes enabled via the devicetree
"axis" property, so with a partial axis set val[0..2] no longer held
X, Y and Z as required by the sensor API, and unwritten entries were
left indeterminate. Aggregate reads now use fixed slots per axis and
report deactivated axes as zero.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5